672bc9fa3131b0ae8747e6ff226d40ca7c407238
[ldk-java] / c_sharp / bindings.c.body
1
2 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
3 #define int64_t jlong
4 #include <lightning.h>
5 #include <string.h>
6 #include <stdatomic.h>
7 #include <stdlib.h>
8
9 #define LIKELY(v) __builtin_expect(!!(v), 1)
10 #define UNLIKELY(v) __builtin_expect(!!(v), 0)
11
12 #include <stdio.h>
13 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
14 #define do_MALLOC(a, _b, _c) malloc(a)
15 #define MALLOC(a, _) malloc(a)
16 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
17 #define CHECK_ACCESS(p)
18 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
19 #define DO_ASSERT(a) (void)(a)
20 #define CHECK(a)
21
22
23 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
24 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
25 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
26 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
27
28 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
29
30 #define DECL_ARR_TYPE(ty, name) \
31         struct name##array { \
32                 uint64_t arr_len; /* uint32_t would suffice but we want to align uint64_ts as well */ \
33                 ty elems[]; \
34         }; \
35         typedef struct name##array * name##Array; \
36         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
37                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint64_t), #name" array init", lineno); \
38                 arr->arr_len = arr_len; \
39                 return arr; \
40         }
41
42 DECL_ARR_TYPE(int64_t, int64_t);
43 DECL_ARR_TYPE(uint64_t, uint64_t);
44 DECL_ARR_TYPE(int8_t, int8_t);
45 DECL_ARR_TYPE(int16_t, int16_t);
46 DECL_ARR_TYPE(uint32_t, uint32_t);
47 DECL_ARR_TYPE(void*, ptr);
48 DECL_ARR_TYPE(char, char);
49 typedef charArray jstring;
50
51 static inline jstring str_ref_to_cs(const char* chars, size_t len) {
52         charArray arr = init_charArray(len, __LINE__);
53         memcpy(arr->elems, chars, len);
54         return arr;
55 }
56 static inline LDKStr str_ref_to_owned_c(const jstring str) {
57         char* newchars = MALLOC(str->arr_len + 1, "String chars");
58         memcpy(newchars, str->elems, str->arr_len);
59         newchars[str->arr_len] = 0;
60         LDKStr res = {
61                 .chars = newchars,
62                 .len = str->arr_len,
63                 .chars_is_owned = true
64         };
65         return res;
66 }
67
68 typedef bool jboolean;
69
70 int64_t CS_LDK_allocate_buffer(int64_t len) {
71         return MALLOC(len, "C#-requested buffer");
72 }
73
74 void CS_LDK_free_buffer(int64_t buf) {
75         FREE(buf);
76 }
77
78 jstring CS_LDK_get_ldk_c_bindings_version() {
79         return str_ref_to_cs(check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
80 }
81 jstring CS_LDK_get_ldk_version() {
82         return str_ref_to_cs(check_get_ldk_version(), strlen(check_get_ldk_version()));
83 }
84 #include "version.c"
85
86 typedef int8_tArray (*invoker_l_l)(int obj_ptr, int fn_id, int64_t a);
87 static invoker_l_l js_invoke_function_l_l;
88 int CS_LDK_register_l_l_invoker(invoker_l_l invoker) {
89         js_invoke_function_l_l = invoker;
90         return 0;
91 }
92
93 typedef int64_t (*invoker_l_ll)(int obj_ptr, int fn_id, int64_t a, ptrArray b);
94 static invoker_l_ll js_invoke_function_l_ll;
95 int CS_LDK_register_l_ll_invoker(invoker_l_ll invoker) {
96         js_invoke_function_l_ll = invoker;
97         return 0;
98 }
99
100 typedef int8_tArray (*invoker_l_)(int obj_ptr, int fn_id);
101 static invoker_l_ js_invoke_function_l_;
102 int CS_LDK_register_l__invoker(invoker_l_ invoker) {
103         js_invoke_function_l_ = invoker;
104         return 0;
105 }
106
107 typedef void (*invoker_void_l)(int obj_ptr, int fn_id, int64_t a);
108 static invoker_void_l js_invoke_function_void_l;
109 int CS_LDK_register_void_l_invoker(invoker_void_l invoker) {
110         js_invoke_function_void_l = invoker;
111         return 0;
112 }
113
114 typedef int64_t (*invoker_l_llll)(int obj_ptr, int fn_id, int8_tArray a, int64_t b, int64_t c, int8_tArray d);
115 static invoker_l_llll js_invoke_function_l_llll;
116 int CS_LDK_register_l_llll_invoker(invoker_l_llll invoker) {
117         js_invoke_function_l_llll = invoker;
118         return 0;
119 }
120
121 typedef int64_t (*invoker_l_lllll)(int obj_ptr, int fn_id, int8_tArray a, int64_t b, int64_t c, int8_tArray d, int64_t e);
122 static invoker_l_lllll js_invoke_function_l_lllll;
123 int CS_LDK_register_l_lllll_invoker(invoker_l_lllll invoker) {
124         js_invoke_function_l_lllll = invoker;
125         return 0;
126 }
127
128 typedef int64_t (*invoker_l_lll)(int obj_ptr, int fn_id, int8_tArray a, int64_t b, int64_t c);
129 static invoker_l_lll js_invoke_function_l_lll;
130 int CS_LDK_register_l_lll_invoker(invoker_l_lll invoker) {
131         js_invoke_function_l_lll = invoker;
132         return 0;
133 }
134
135 typedef void (*invoker_void_ll)(int obj_ptr, int fn_id, int64_t a, int64_t b);
136 static invoker_void_ll js_invoke_function_void_ll;
137 int CS_LDK_register_void_ll_invoker(invoker_void_ll invoker) {
138         js_invoke_function_void_ll = invoker;
139         return 0;
140 }
141
142 typedef int32_t (*invoker_ChannelMonitorUpdateStatus_ll)(int obj_ptr, int fn_id, int64_t a, int64_t b);
143 static invoker_ChannelMonitorUpdateStatus_ll js_invoke_function_ChannelMonitorUpdateStatus_ll;
144 int CS_LDK_register_ChannelMonitorUpdateStatus_ll_invoker(invoker_ChannelMonitorUpdateStatus_ll invoker) {
145         js_invoke_function_ChannelMonitorUpdateStatus_ll = invoker;
146         return 0;
147 }
148
149 typedef int64_t (*invoker_l_Recipient)(int obj_ptr, int fn_id, int32_t a);
150 static invoker_l_Recipient js_invoke_function_l_Recipient;
151 int CS_LDK_register_l_Recipient_invoker(invoker_l_Recipient invoker) {
152         js_invoke_function_l_Recipient = invoker;
153         return 0;
154 }
155
156 typedef int64_t (*invoker_l_Recipientll)(int obj_ptr, int fn_id, int32_t a, int8_tArray b, int64_t c);
157 static invoker_l_Recipientll js_invoke_function_l_Recipientll;
158 int CS_LDK_register_l_Recipientll_invoker(invoker_l_Recipientll invoker) {
159         js_invoke_function_l_Recipientll = invoker;
160         return 0;
161 }
162
163 typedef int64_t (*invoker_l_llRecipient)(int obj_ptr, int fn_id, int8_tArray a, ptrArray b, int32_t c);
164 static invoker_l_llRecipient js_invoke_function_l_llRecipient;
165 int CS_LDK_register_l_llRecipient_invoker(invoker_l_llRecipient invoker) {
166         js_invoke_function_l_llRecipient = invoker;
167         return 0;
168 }
169
170 typedef int8_tArray (*invoker_l_bll)(int obj_ptr, int fn_id, jboolean a, int64_t b, int8_tArray c);
171 static invoker_l_bll js_invoke_function_l_bll;
172 int CS_LDK_register_l_bll_invoker(invoker_l_bll invoker) {
173         js_invoke_function_l_bll = invoker;
174         return 0;
175 }
176
177 typedef int32_t (*invoker_i_ConfirmationTarget)(int obj_ptr, int fn_id, int32_t a);
178 static invoker_i_ConfirmationTarget js_invoke_function_i_ConfirmationTarget;
179 int CS_LDK_register_i_ConfirmationTarget_invoker(invoker_i_ConfirmationTarget invoker) {
180         js_invoke_function_i_ConfirmationTarget = invoker;
181         return 0;
182 }
183
184 typedef int64_t (*invoker_l_llllll)(int obj_ptr, int fn_id, int8_tArray a, int64_t b, int64_tArray c, int64_t d, int8_tArray e, int8_tArray f);
185 static invoker_l_llllll js_invoke_function_l_llllll;
186 int CS_LDK_register_l_llllll_invoker(invoker_l_llllll invoker) {
187         js_invoke_function_l_llllll = invoker;
188         return 0;
189 }
190
191 typedef int16_t (*invoker_s_)(int obj_ptr, int fn_id);
192 static invoker_s_ js_invoke_function_s_;
193 int CS_LDK_register_s__invoker(invoker_s_ invoker) {
194         js_invoke_function_s_ = invoker;
195         return 0;
196 }
197
198 typedef int64_t (*invoker_l_lllb)(int obj_ptr, int fn_id, jstring a, jstring b, jstring c, jboolean d);
199 static invoker_l_lllb js_invoke_function_l_lllb;
200 int CS_LDK_register_l_lllb_invoker(invoker_l_lllb invoker) {
201         js_invoke_function_l_lllb = invoker;
202         return 0;
203 }
204
205 typedef int32_t (*invoker_ChannelMonitorUpdateStatus_lll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c);
206 static invoker_ChannelMonitorUpdateStatus_lll js_invoke_function_ChannelMonitorUpdateStatus_lll;
207 int CS_LDK_register_ChannelMonitorUpdateStatus_lll_invoker(invoker_ChannelMonitorUpdateStatus_lll invoker) {
208         js_invoke_function_ChannelMonitorUpdateStatus_lll = invoker;
209         return 0;
210 }
211
212 typedef int32_t (*invoker_ChannelMonitorUpdateStatus_llll)(int obj_ptr, int fn_id, int64_t a, int64_t b, int64_t c, int64_t d);
213 static invoker_ChannelMonitorUpdateStatus_llll js_invoke_function_ChannelMonitorUpdateStatus_llll;
214 int CS_LDK_register_ChannelMonitorUpdateStatus_llll_invoker(invoker_ChannelMonitorUpdateStatus_llll invoker) {
215         js_invoke_function_ChannelMonitorUpdateStatus_llll = invoker;
216         return 0;
217 }
218
219 typedef void (*invoker_void_)(int obj_ptr, int fn_id);
220 static invoker_void_ js_invoke_function_void_;
221 int CS_LDK_register_void__invoker(invoker_void_ invoker) {
222         js_invoke_function_void_ = invoker;
223         return 0;
224 }
225
226 typedef void (*invoker_void_lli)(int obj_ptr, int fn_id, int8_tArray a, int64_tArray b, int32_t c);
227 static invoker_void_lli js_invoke_function_void_lli;
228 int CS_LDK_register_void_lli_invoker(invoker_void_lli invoker) {
229         js_invoke_function_void_lli = invoker;
230         return 0;
231 }
232
233 typedef void (*invoker_void_li)(int obj_ptr, int fn_id, int8_tArray a, int32_t b);
234 static invoker_void_li js_invoke_function_void_li;
235 int CS_LDK_register_void_li_invoker(invoker_void_li invoker) {
236         js_invoke_function_void_li = invoker;
237         return 0;
238 }
239
240 typedef int64_t (*invoker_l_llb)(int obj_ptr, int fn_id, int8_tArray a, int64_t b, jboolean c);
241 static invoker_l_llb js_invoke_function_l_llb;
242 int CS_LDK_register_l_llb_invoker(invoker_l_llb invoker) {
243         js_invoke_function_l_llb = invoker;
244         return 0;
245 }
246
247 typedef jboolean (*invoker_b_)(int obj_ptr, int fn_id);
248 static invoker_b_ js_invoke_function_b_;
249 int CS_LDK_register_b__invoker(invoker_b_ invoker) {
250         js_invoke_function_b_ = invoker;
251         return 0;
252 }
253
254 typedef int64_t (*invoker_l_sl)(int obj_ptr, int fn_id, int16_t a, int8_tArray b);
255 static invoker_l_sl js_invoke_function_l_sl;
256 int CS_LDK_register_l_sl_invoker(invoker_l_sl invoker) {
257         js_invoke_function_l_sl = invoker;
258         return 0;
259 }
260
261 typedef int64_t (*invoker_l_lb)(int obj_ptr, int fn_id, int8_tArray a, jboolean b);
262 static invoker_l_lb js_invoke_function_l_lb;
263 int CS_LDK_register_l_lb_invoker(invoker_l_lb invoker) {
264         js_invoke_function_l_lb = invoker;
265         return 0;
266 }
267
268 typedef jboolean (*invoker_b_l)(int obj_ptr, int fn_id, int64_t a);
269 static invoker_b_l js_invoke_function_b_l;
270 int CS_LDK_register_b_l_invoker(invoker_b_l invoker) {
271         js_invoke_function_b_l = invoker;
272         return 0;
273 }
274
275 typedef int64_t (*invoker_l_llli)(int obj_ptr, int fn_id, int8_tArray a, int64_tArray b, int64_tArray c, int32_t d);
276 static invoker_l_llli js_invoke_function_l_llli;
277 int CS_LDK_register_l_llli_invoker(invoker_l_llli invoker) {
278         js_invoke_function_l_llli = invoker;
279         return 0;
280 }
281 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
282
283 static inline void* untag_ptr(uint64_t ptr) {
284         if (ptr < 4096) return (void*)ptr;
285         if (sizeof(void*) == 4) {
286                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
287                 return (void*)(uintptr_t)ptr;
288         } else {
289                 // For 64-bit systems, assume the top byte is used for tagging, then
290                 // use bit 9 ^ bit 10.
291                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
292                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
293 #ifdef LDK_DEBUG_BUILD
294                 // On debug builds we also use the 11th bit as a debug flag
295                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
296                 CHECK(tenth_bit != eleventh_bit);
297                 p ^= 1ULL << 53;
298 #endif
299                 return (void*)p;
300         }
301 }
302 static inline bool ptr_is_owned(uint64_t ptr) {
303         if(ptr < 4096) return true;
304         if (sizeof(void*) == 4) {
305                 return ptr & (1ULL << 32);
306         } else {
307                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
308                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
309 #ifdef LDK_DEBUG_BUILD
310                 // On debug builds we also use the 11th bit as a debug flag
311                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
312                 CHECK(tenth_bit != eleventh_bit);
313 #endif
314                 return (ninth_bit ^ tenth_bit) ? true : false;
315         }
316 }
317 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
318         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
319         if (sizeof(void*) == 4) {
320                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
321         } else {
322                 CHECK(sizeof(uintptr_t) == 8);
323                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
324                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
325 #ifdef LDK_DEBUG_BUILD
326                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
327                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
328                 CHECK(ninth_bit == tenth_bit);
329                 CHECK(ninth_bit == eleventh_bit);
330                 t ^= 1ULL << 53;
331 #endif
332                 CHECK(ptr_is_owned(t) == is_owned);
333                 CHECK(untag_ptr(t) == ptr);
334                 return t;
335         }
336 }
337
338 static inline LDKBolt11SemanticError LDKBolt11SemanticError_from_cs(int32_t ord) {
339         switch (ord) {
340                 case 0: return LDKBolt11SemanticError_NoPaymentHash;
341                 case 1: return LDKBolt11SemanticError_MultiplePaymentHashes;
342                 case 2: return LDKBolt11SemanticError_NoDescription;
343                 case 3: return LDKBolt11SemanticError_MultipleDescriptions;
344                 case 4: return LDKBolt11SemanticError_NoPaymentSecret;
345                 case 5: return LDKBolt11SemanticError_MultiplePaymentSecrets;
346                 case 6: return LDKBolt11SemanticError_InvalidFeatures;
347                 case 7: return LDKBolt11SemanticError_InvalidRecoveryId;
348                 case 8: return LDKBolt11SemanticError_InvalidSignature;
349                 case 9: return LDKBolt11SemanticError_ImpreciseAmount;
350                 default: abort();
351         }
352 }
353 static inline int32_t LDKBolt11SemanticError_to_cs(LDKBolt11SemanticError val) {
354         switch (val) {
355                 case LDKBolt11SemanticError_NoPaymentHash: return 0;
356                 case LDKBolt11SemanticError_MultiplePaymentHashes: return 1;
357                 case LDKBolt11SemanticError_NoDescription: return 2;
358                 case LDKBolt11SemanticError_MultipleDescriptions: return 3;
359                 case LDKBolt11SemanticError_NoPaymentSecret: return 4;
360                 case LDKBolt11SemanticError_MultiplePaymentSecrets: return 5;
361                 case LDKBolt11SemanticError_InvalidFeatures: return 6;
362                 case LDKBolt11SemanticError_InvalidRecoveryId: return 7;
363                 case LDKBolt11SemanticError_InvalidSignature: return 8;
364                 case LDKBolt11SemanticError_ImpreciseAmount: return 9;
365                 default: abort();
366         }
367 }
368 static inline LDKBolt12SemanticError LDKBolt12SemanticError_from_cs(int32_t ord) {
369         switch (ord) {
370                 case 0: return LDKBolt12SemanticError_AlreadyExpired;
371                 case 1: return LDKBolt12SemanticError_UnsupportedChain;
372                 case 2: return LDKBolt12SemanticError_UnexpectedChain;
373                 case 3: return LDKBolt12SemanticError_MissingAmount;
374                 case 4: return LDKBolt12SemanticError_InvalidAmount;
375                 case 5: return LDKBolt12SemanticError_InsufficientAmount;
376                 case 6: return LDKBolt12SemanticError_UnexpectedAmount;
377                 case 7: return LDKBolt12SemanticError_UnsupportedCurrency;
378                 case 8: return LDKBolt12SemanticError_UnknownRequiredFeatures;
379                 case 9: return LDKBolt12SemanticError_UnexpectedFeatures;
380                 case 10: return LDKBolt12SemanticError_MissingDescription;
381                 case 11: return LDKBolt12SemanticError_MissingSigningPubkey;
382                 case 12: return LDKBolt12SemanticError_InvalidSigningPubkey;
383                 case 13: return LDKBolt12SemanticError_UnexpectedSigningPubkey;
384                 case 14: return LDKBolt12SemanticError_MissingQuantity;
385                 case 15: return LDKBolt12SemanticError_InvalidQuantity;
386                 case 16: return LDKBolt12SemanticError_UnexpectedQuantity;
387                 case 17: return LDKBolt12SemanticError_InvalidMetadata;
388                 case 18: return LDKBolt12SemanticError_UnexpectedMetadata;
389                 case 19: return LDKBolt12SemanticError_MissingPayerMetadata;
390                 case 20: return LDKBolt12SemanticError_MissingPayerId;
391                 case 21: return LDKBolt12SemanticError_DuplicatePaymentId;
392                 case 22: return LDKBolt12SemanticError_MissingPaths;
393                 case 23: return LDKBolt12SemanticError_InvalidPayInfo;
394                 case 24: return LDKBolt12SemanticError_MissingCreationTime;
395                 case 25: return LDKBolt12SemanticError_MissingPaymentHash;
396                 case 26: return LDKBolt12SemanticError_MissingSignature;
397                 default: abort();
398         }
399 }
400 static inline int32_t LDKBolt12SemanticError_to_cs(LDKBolt12SemanticError val) {
401         switch (val) {
402                 case LDKBolt12SemanticError_AlreadyExpired: return 0;
403                 case LDKBolt12SemanticError_UnsupportedChain: return 1;
404                 case LDKBolt12SemanticError_UnexpectedChain: return 2;
405                 case LDKBolt12SemanticError_MissingAmount: return 3;
406                 case LDKBolt12SemanticError_InvalidAmount: return 4;
407                 case LDKBolt12SemanticError_InsufficientAmount: return 5;
408                 case LDKBolt12SemanticError_UnexpectedAmount: return 6;
409                 case LDKBolt12SemanticError_UnsupportedCurrency: return 7;
410                 case LDKBolt12SemanticError_UnknownRequiredFeatures: return 8;
411                 case LDKBolt12SemanticError_UnexpectedFeatures: return 9;
412                 case LDKBolt12SemanticError_MissingDescription: return 10;
413                 case LDKBolt12SemanticError_MissingSigningPubkey: return 11;
414                 case LDKBolt12SemanticError_InvalidSigningPubkey: return 12;
415                 case LDKBolt12SemanticError_UnexpectedSigningPubkey: return 13;
416                 case LDKBolt12SemanticError_MissingQuantity: return 14;
417                 case LDKBolt12SemanticError_InvalidQuantity: return 15;
418                 case LDKBolt12SemanticError_UnexpectedQuantity: return 16;
419                 case LDKBolt12SemanticError_InvalidMetadata: return 17;
420                 case LDKBolt12SemanticError_UnexpectedMetadata: return 18;
421                 case LDKBolt12SemanticError_MissingPayerMetadata: return 19;
422                 case LDKBolt12SemanticError_MissingPayerId: return 20;
423                 case LDKBolt12SemanticError_DuplicatePaymentId: return 21;
424                 case LDKBolt12SemanticError_MissingPaths: return 22;
425                 case LDKBolt12SemanticError_InvalidPayInfo: return 23;
426                 case LDKBolt12SemanticError_MissingCreationTime: return 24;
427                 case LDKBolt12SemanticError_MissingPaymentHash: return 25;
428                 case LDKBolt12SemanticError_MissingSignature: return 26;
429                 default: abort();
430         }
431 }
432 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_cs(int32_t ord) {
433         switch (ord) {
434                 case 0: return LDKCOption_NoneZ_Some;
435                 case 1: return LDKCOption_NoneZ_None;
436                 default: abort();
437         }
438 }
439 static inline int32_t LDKCOption_NoneZ_to_cs(LDKCOption_NoneZ val) {
440         switch (val) {
441                 case LDKCOption_NoneZ_Some: return 0;
442                 case LDKCOption_NoneZ_None: return 1;
443                 default: abort();
444         }
445 }
446 static inline LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_from_cs(int32_t ord) {
447         switch (ord) {
448                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
449                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
450                 case 2: return LDKChannelMonitorUpdateStatus_UnrecoverableError;
451                 default: abort();
452         }
453 }
454 static inline int32_t LDKChannelMonitorUpdateStatus_to_cs(LDKChannelMonitorUpdateStatus val) {
455         switch (val) {
456                 case LDKChannelMonitorUpdateStatus_Completed: return 0;
457                 case LDKChannelMonitorUpdateStatus_InProgress: return 1;
458                 case LDKChannelMonitorUpdateStatus_UnrecoverableError: return 2;
459                 default: abort();
460         }
461 }
462 static inline LDKChannelShutdownState LDKChannelShutdownState_from_cs(int32_t ord) {
463         switch (ord) {
464                 case 0: return LDKChannelShutdownState_NotShuttingDown;
465                 case 1: return LDKChannelShutdownState_ShutdownInitiated;
466                 case 2: return LDKChannelShutdownState_ResolvingHTLCs;
467                 case 3: return LDKChannelShutdownState_NegotiatingClosingFee;
468                 case 4: return LDKChannelShutdownState_ShutdownComplete;
469                 default: abort();
470         }
471 }
472 static inline int32_t LDKChannelShutdownState_to_cs(LDKChannelShutdownState val) {
473         switch (val) {
474                 case LDKChannelShutdownState_NotShuttingDown: return 0;
475                 case LDKChannelShutdownState_ShutdownInitiated: return 1;
476                 case LDKChannelShutdownState_ResolvingHTLCs: return 2;
477                 case LDKChannelShutdownState_NegotiatingClosingFee: return 3;
478                 case LDKChannelShutdownState_ShutdownComplete: return 4;
479                 default: abort();
480         }
481 }
482 static inline LDKConfirmationTarget LDKConfirmationTarget_from_cs(int32_t ord) {
483         switch (ord) {
484                 case 0: return LDKConfirmationTarget_OnChainSweep;
485                 case 1: return LDKConfirmationTarget_MaxAllowedNonAnchorChannelRemoteFee;
486                 case 2: return LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee;
487                 case 3: return LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee;
488                 case 4: return LDKConfirmationTarget_AnchorChannelFee;
489                 case 5: return LDKConfirmationTarget_NonAnchorChannelFee;
490                 case 6: return LDKConfirmationTarget_ChannelCloseMinimum;
491                 default: abort();
492         }
493 }
494 static inline int32_t LDKConfirmationTarget_to_cs(LDKConfirmationTarget val) {
495         switch (val) {
496                 case LDKConfirmationTarget_OnChainSweep: return 0;
497                 case LDKConfirmationTarget_MaxAllowedNonAnchorChannelRemoteFee: return 1;
498                 case LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee: return 2;
499                 case LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee: return 3;
500                 case LDKConfirmationTarget_AnchorChannelFee: return 4;
501                 case LDKConfirmationTarget_NonAnchorChannelFee: return 5;
502                 case LDKConfirmationTarget_ChannelCloseMinimum: return 6;
503                 default: abort();
504         }
505 }
506 static inline LDKCreationError LDKCreationError_from_cs(int32_t ord) {
507         switch (ord) {
508                 case 0: return LDKCreationError_DescriptionTooLong;
509                 case 1: return LDKCreationError_RouteTooLong;
510                 case 2: return LDKCreationError_TimestampOutOfBounds;
511                 case 3: return LDKCreationError_InvalidAmount;
512                 case 4: return LDKCreationError_MissingRouteHints;
513                 case 5: return LDKCreationError_MinFinalCltvExpiryDeltaTooShort;
514                 default: abort();
515         }
516 }
517 static inline int32_t LDKCreationError_to_cs(LDKCreationError val) {
518         switch (val) {
519                 case LDKCreationError_DescriptionTooLong: return 0;
520                 case LDKCreationError_RouteTooLong: return 1;
521                 case LDKCreationError_TimestampOutOfBounds: return 2;
522                 case LDKCreationError_InvalidAmount: return 3;
523                 case LDKCreationError_MissingRouteHints: return 4;
524                 case LDKCreationError_MinFinalCltvExpiryDeltaTooShort: return 5;
525                 default: abort();
526         }
527 }
528 static inline LDKCurrency LDKCurrency_from_cs(int32_t ord) {
529         switch (ord) {
530                 case 0: return LDKCurrency_Bitcoin;
531                 case 1: return LDKCurrency_BitcoinTestnet;
532                 case 2: return LDKCurrency_Regtest;
533                 case 3: return LDKCurrency_Simnet;
534                 case 4: return LDKCurrency_Signet;
535                 default: abort();
536         }
537 }
538 static inline int32_t LDKCurrency_to_cs(LDKCurrency val) {
539         switch (val) {
540                 case LDKCurrency_Bitcoin: return 0;
541                 case LDKCurrency_BitcoinTestnet: return 1;
542                 case LDKCurrency_Regtest: return 2;
543                 case LDKCurrency_Simnet: return 3;
544                 case LDKCurrency_Signet: return 4;
545                 default: abort();
546         }
547 }
548 static inline LDKHTLCClaim LDKHTLCClaim_from_cs(int32_t ord) {
549         switch (ord) {
550                 case 0: return LDKHTLCClaim_OfferedTimeout;
551                 case 1: return LDKHTLCClaim_OfferedPreimage;
552                 case 2: return LDKHTLCClaim_AcceptedTimeout;
553                 case 3: return LDKHTLCClaim_AcceptedPreimage;
554                 case 4: return LDKHTLCClaim_Revocation;
555                 default: abort();
556         }
557 }
558 static inline int32_t LDKHTLCClaim_to_cs(LDKHTLCClaim val) {
559         switch (val) {
560                 case LDKHTLCClaim_OfferedTimeout: return 0;
561                 case LDKHTLCClaim_OfferedPreimage: return 1;
562                 case LDKHTLCClaim_AcceptedTimeout: return 2;
563                 case LDKHTLCClaim_AcceptedPreimage: return 3;
564                 case LDKHTLCClaim_Revocation: return 4;
565                 default: abort();
566         }
567 }
568 static inline LDKIOError LDKIOError_from_cs(int32_t ord) {
569         switch (ord) {
570                 case 0: return LDKIOError_NotFound;
571                 case 1: return LDKIOError_PermissionDenied;
572                 case 2: return LDKIOError_ConnectionRefused;
573                 case 3: return LDKIOError_ConnectionReset;
574                 case 4: return LDKIOError_ConnectionAborted;
575                 case 5: return LDKIOError_NotConnected;
576                 case 6: return LDKIOError_AddrInUse;
577                 case 7: return LDKIOError_AddrNotAvailable;
578                 case 8: return LDKIOError_BrokenPipe;
579                 case 9: return LDKIOError_AlreadyExists;
580                 case 10: return LDKIOError_WouldBlock;
581                 case 11: return LDKIOError_InvalidInput;
582                 case 12: return LDKIOError_InvalidData;
583                 case 13: return LDKIOError_TimedOut;
584                 case 14: return LDKIOError_WriteZero;
585                 case 15: return LDKIOError_Interrupted;
586                 case 16: return LDKIOError_Other;
587                 case 17: return LDKIOError_UnexpectedEof;
588                 default: abort();
589         }
590 }
591 static inline int32_t LDKIOError_to_cs(LDKIOError val) {
592         switch (val) {
593                 case LDKIOError_NotFound: return 0;
594                 case LDKIOError_PermissionDenied: return 1;
595                 case LDKIOError_ConnectionRefused: return 2;
596                 case LDKIOError_ConnectionReset: return 3;
597                 case LDKIOError_ConnectionAborted: return 4;
598                 case LDKIOError_NotConnected: return 5;
599                 case LDKIOError_AddrInUse: return 6;
600                 case LDKIOError_AddrNotAvailable: return 7;
601                 case LDKIOError_BrokenPipe: return 8;
602                 case LDKIOError_AlreadyExists: return 9;
603                 case LDKIOError_WouldBlock: return 10;
604                 case LDKIOError_InvalidInput: return 11;
605                 case LDKIOError_InvalidData: return 12;
606                 case LDKIOError_TimedOut: return 13;
607                 case LDKIOError_WriteZero: return 14;
608                 case LDKIOError_Interrupted: return 15;
609                 case LDKIOError_Other: return 16;
610                 case LDKIOError_UnexpectedEof: return 17;
611                 default: abort();
612         }
613 }
614 static inline LDKLevel LDKLevel_from_cs(int32_t ord) {
615         switch (ord) {
616                 case 0: return LDKLevel_Gossip;
617                 case 1: return LDKLevel_Trace;
618                 case 2: return LDKLevel_Debug;
619                 case 3: return LDKLevel_Info;
620                 case 4: return LDKLevel_Warn;
621                 case 5: return LDKLevel_Error;
622                 default: abort();
623         }
624 }
625 static inline int32_t LDKLevel_to_cs(LDKLevel val) {
626         switch (val) {
627                 case LDKLevel_Gossip: return 0;
628                 case LDKLevel_Trace: return 1;
629                 case LDKLevel_Debug: return 2;
630                 case LDKLevel_Info: return 3;
631                 case LDKLevel_Warn: return 4;
632                 case LDKLevel_Error: return 5;
633                 default: abort();
634         }
635 }
636 static inline LDKNetwork LDKNetwork_from_cs(int32_t ord) {
637         switch (ord) {
638                 case 0: return LDKNetwork_Bitcoin;
639                 case 1: return LDKNetwork_Testnet;
640                 case 2: return LDKNetwork_Regtest;
641                 case 3: return LDKNetwork_Signet;
642                 default: abort();
643         }
644 }
645 static inline int32_t LDKNetwork_to_cs(LDKNetwork val) {
646         switch (val) {
647                 case LDKNetwork_Bitcoin: return 0;
648                 case LDKNetwork_Testnet: return 1;
649                 case LDKNetwork_Regtest: return 2;
650                 case LDKNetwork_Signet: return 3;
651                 default: abort();
652         }
653 }
654 static inline LDKPaymentFailureReason LDKPaymentFailureReason_from_cs(int32_t ord) {
655         switch (ord) {
656                 case 0: return LDKPaymentFailureReason_RecipientRejected;
657                 case 1: return LDKPaymentFailureReason_UserAbandoned;
658                 case 2: return LDKPaymentFailureReason_RetriesExhausted;
659                 case 3: return LDKPaymentFailureReason_PaymentExpired;
660                 case 4: return LDKPaymentFailureReason_RouteNotFound;
661                 case 5: return LDKPaymentFailureReason_UnexpectedError;
662                 default: abort();
663         }
664 }
665 static inline int32_t LDKPaymentFailureReason_to_cs(LDKPaymentFailureReason val) {
666         switch (val) {
667                 case LDKPaymentFailureReason_RecipientRejected: return 0;
668                 case LDKPaymentFailureReason_UserAbandoned: return 1;
669                 case LDKPaymentFailureReason_RetriesExhausted: return 2;
670                 case LDKPaymentFailureReason_PaymentExpired: return 3;
671                 case LDKPaymentFailureReason_RouteNotFound: return 4;
672                 case LDKPaymentFailureReason_UnexpectedError: return 5;
673                 default: abort();
674         }
675 }
676 static inline LDKRecipient LDKRecipient_from_cs(int32_t ord) {
677         switch (ord) {
678                 case 0: return LDKRecipient_Node;
679                 case 1: return LDKRecipient_PhantomNode;
680                 default: abort();
681         }
682 }
683 static inline int32_t LDKRecipient_to_cs(LDKRecipient val) {
684         switch (val) {
685                 case LDKRecipient_Node: return 0;
686                 case LDKRecipient_PhantomNode: return 1;
687                 default: abort();
688         }
689 }
690 static inline LDKRetryableSendFailure LDKRetryableSendFailure_from_cs(int32_t ord) {
691         switch (ord) {
692                 case 0: return LDKRetryableSendFailure_PaymentExpired;
693                 case 1: return LDKRetryableSendFailure_RouteNotFound;
694                 case 2: return LDKRetryableSendFailure_DuplicatePayment;
695                 default: abort();
696         }
697 }
698 static inline int32_t LDKRetryableSendFailure_to_cs(LDKRetryableSendFailure val) {
699         switch (val) {
700                 case LDKRetryableSendFailure_PaymentExpired: return 0;
701                 case LDKRetryableSendFailure_RouteNotFound: return 1;
702                 case LDKRetryableSendFailure_DuplicatePayment: return 2;
703                 default: abort();
704         }
705 }
706 static inline LDKSecp256k1Error LDKSecp256k1Error_from_cs(int32_t ord) {
707         switch (ord) {
708                 case 0: return LDKSecp256k1Error_IncorrectSignature;
709                 case 1: return LDKSecp256k1Error_InvalidMessage;
710                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
711                 case 3: return LDKSecp256k1Error_InvalidSignature;
712                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
713                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
714                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
715                 case 7: return LDKSecp256k1Error_InvalidTweak;
716                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
717                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
718                 case 10: return LDKSecp256k1Error_InvalidParityValue;
719                 default: abort();
720         }
721 }
722 static inline int32_t LDKSecp256k1Error_to_cs(LDKSecp256k1Error val) {
723         switch (val) {
724                 case LDKSecp256k1Error_IncorrectSignature: return 0;
725                 case LDKSecp256k1Error_InvalidMessage: return 1;
726                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
727                 case LDKSecp256k1Error_InvalidSignature: return 3;
728                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
729                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
730                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
731                 case LDKSecp256k1Error_InvalidTweak: return 7;
732                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
733                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
734                 case LDKSecp256k1Error_InvalidParityValue: return 10;
735                 default: abort();
736         }
737 }
738 static inline LDKSiPrefix LDKSiPrefix_from_cs(int32_t ord) {
739         switch (ord) {
740                 case 0: return LDKSiPrefix_Milli;
741                 case 1: return LDKSiPrefix_Micro;
742                 case 2: return LDKSiPrefix_Nano;
743                 case 3: return LDKSiPrefix_Pico;
744                 default: abort();
745         }
746 }
747 static inline int32_t LDKSiPrefix_to_cs(LDKSiPrefix val) {
748         switch (val) {
749                 case LDKSiPrefix_Milli: return 0;
750                 case LDKSiPrefix_Micro: return 1;
751                 case LDKSiPrefix_Nano: return 2;
752                 case LDKSiPrefix_Pico: return 3;
753                 default: abort();
754         }
755 }
756 static inline LDKSocketAddressParseError LDKSocketAddressParseError_from_cs(int32_t ord) {
757         switch (ord) {
758                 case 0: return LDKSocketAddressParseError_SocketAddrParse;
759                 case 1: return LDKSocketAddressParseError_InvalidInput;
760                 case 2: return LDKSocketAddressParseError_InvalidPort;
761                 case 3: return LDKSocketAddressParseError_InvalidOnionV3;
762                 default: abort();
763         }
764 }
765 static inline int32_t LDKSocketAddressParseError_to_cs(LDKSocketAddressParseError val) {
766         switch (val) {
767                 case LDKSocketAddressParseError_SocketAddrParse: return 0;
768                 case LDKSocketAddressParseError_InvalidInput: return 1;
769                 case LDKSocketAddressParseError_InvalidPort: return 2;
770                 case LDKSocketAddressParseError_InvalidOnionV3: return 3;
771                 default: abort();
772         }
773 }
774 static inline LDKUtxoLookupError LDKUtxoLookupError_from_cs(int32_t ord) {
775         switch (ord) {
776                 case 0: return LDKUtxoLookupError_UnknownChain;
777                 case 1: return LDKUtxoLookupError_UnknownTx;
778                 default: abort();
779         }
780 }
781 static inline int32_t LDKUtxoLookupError_to_cs(LDKUtxoLookupError val) {
782         switch (val) {
783                 case LDKUtxoLookupError_UnknownChain: return 0;
784                 case LDKUtxoLookupError_UnknownTx: return 1;
785                 default: abort();
786         }
787 }
788 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
789         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
790         return ret;
791 }
792 int8_tArray  CS_LDK_BigEndianScalar_get_bytes(int64_t thing) {
793         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
794         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
795         memcpy(ret_arr->elems, BigEndianScalar_get_bytes(thing_conv).data, 32);
796         return ret_arr;
797 }
798
799 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
800 void  CS_LDK_BigEndianScalar_free(int64_t thing) {
801         if (!ptr_is_owned(thing)) return;
802         void* thing_ptr = untag_ptr(thing);
803         CHECK_ACCESS(thing_ptr);
804         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
805         FREE(untag_ptr(thing));
806         BigEndianScalar_free(thing_conv);
807 }
808
809 uint32_t CS_LDK_LDKBech32Error_ty_from_ptr(int64_t ptr) {
810         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
811         switch(obj->tag) {
812                 case LDKBech32Error_MissingSeparator: return 0;
813                 case LDKBech32Error_InvalidChecksum: return 1;
814                 case LDKBech32Error_InvalidLength: return 2;
815                 case LDKBech32Error_InvalidChar: return 3;
816                 case LDKBech32Error_InvalidData: return 4;
817                 case LDKBech32Error_InvalidPadding: return 5;
818                 case LDKBech32Error_MixedCase: return 6;
819                 default: abort();
820         }
821 }
822 int32_t CS_LDK_LDKBech32Error_InvalidChar_get_invalid_char(int64_t ptr) {
823         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
824         CHECK(obj->tag == LDKBech32Error_InvalidChar);
825         int32_t invalid_char_conv = obj->invalid_char;
826         return invalid_char_conv;
827 }
828 int8_t CS_LDK_LDKBech32Error_InvalidData_get_invalid_data(int64_t ptr) {
829         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
830         CHECK(obj->tag == LDKBech32Error_InvalidData);
831         int8_t invalid_data_conv = obj->invalid_data;
832         return invalid_data_conv;
833 }
834 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
835         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
836         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
837         return ret;
838 }
839 struct LDKWitness TxIn_get_witness (struct LDKTxIn* thing) {    return Witness_clone(&thing->witness);}int8_tArray  CS_LDK_TxIn_get_witness(int64_t thing) {
840         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
841         LDKWitness ret_var = TxIn_get_witness(thing_conv);
842         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
843         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
844         Witness_free(ret_var);
845         return ret_arr;
846 }
847
848 struct LDKCVec_u8Z TxIn_get_script_sig (struct LDKTxIn* thing) {        return CVec_u8Z_clone(&thing->script_sig);}int8_tArray  CS_LDK_TxIn_get_script_sig(int64_t thing) {
849         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
850         LDKCVec_u8Z ret_var = TxIn_get_script_sig(thing_conv);
851         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
852         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
853         CVec_u8Z_free(ret_var);
854         return ret_arr;
855 }
856
857 LDKThirtyTwoBytes TxIn_get_previous_txid (struct LDKTxIn* thing) {      return thing->previous_txid;}int8_tArray  CS_LDK_TxIn_get_previous_txid(int64_t thing) {
858         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
859         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
860         memcpy(ret_arr->elems, TxIn_get_previous_txid(thing_conv).data, 32);
861         return ret_arr;
862 }
863
864 uint32_t TxIn_get_previous_vout (struct LDKTxIn* thing) {       return thing->previous_vout;}int32_t  CS_LDK_TxIn_get_previous_vout(int64_t thing) {
865         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
866         int32_t ret_conv = TxIn_get_previous_vout(thing_conv);
867         return ret_conv;
868 }
869
870 uint32_t TxIn_get_sequence (struct LDKTxIn* thing) {    return thing->sequence;}int32_t  CS_LDK_TxIn_get_sequence(int64_t thing) {
871         LDKTxIn* thing_conv = (LDKTxIn*)untag_ptr(thing);
872         int32_t ret_conv = TxIn_get_sequence(thing_conv);
873         return ret_conv;
874 }
875
876 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}int8_tArray  CS_LDK_TxOut_get_script_pubkey(int64_t thing) {
877         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
878         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
879         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
880         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
881         CVec_u8Z_free(ret_var);
882         return ret_arr;
883 }
884
885 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  CS_LDK_TxOut_get_value(int64_t thing) {
886         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
887         int64_t ret_conv = TxOut_get_value(thing_conv);
888         return ret_conv;
889 }
890
891 uint32_t CS_LDK_LDKCOption_u64Z_ty_from_ptr(int64_t ptr) {
892         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
893         switch(obj->tag) {
894                 case LDKCOption_u64Z_Some: return 0;
895                 case LDKCOption_u64Z_None: return 1;
896                 default: abort();
897         }
898 }
899 int64_t CS_LDK_LDKCOption_u64Z_Some_get_some(int64_t ptr) {
900         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
901         CHECK(obj->tag == LDKCOption_u64Z_Some);
902         int64_t some_conv = obj->some;
903         return some_conv;
904 }
905 static inline LDKCVec_BlindedPathZ CVec_BlindedPathZ_clone(const LDKCVec_BlindedPathZ *orig) {
906         LDKCVec_BlindedPathZ ret = { .data = MALLOC(sizeof(LDKBlindedPath) * orig->datalen, "LDKCVec_BlindedPathZ clone bytes"), .datalen = orig->datalen };
907         for (size_t i = 0; i < ret.datalen; i++) {
908                 ret.data[i] = BlindedPath_clone(&orig->data[i]);
909         }
910         return ret;
911 }
912 static inline struct LDKRefund CResult_RefundBolt12ParseErrorZ_get_ok(LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR owner){
913         LDKRefund ret = *owner->contents.result;
914         ret.is_owned = false;
915         return ret;
916 }
917 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_get_ok(int64_t owner) {
918         LDKCResult_RefundBolt12ParseErrorZ* owner_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(owner);
919         LDKRefund ret_var = CResult_RefundBolt12ParseErrorZ_get_ok(owner_conv);
920         int64_t ret_ref = 0;
921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
923         return ret_ref;
924 }
925
926 static inline struct LDKBolt12ParseError CResult_RefundBolt12ParseErrorZ_get_err(LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR owner){
927         LDKBolt12ParseError ret = *owner->contents.err;
928         ret.is_owned = false;
929         return ret;
930 }
931 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_get_err(int64_t owner) {
932         LDKCResult_RefundBolt12ParseErrorZ* owner_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(owner);
933         LDKBolt12ParseError ret_var = CResult_RefundBolt12ParseErrorZ_get_err(owner_conv);
934         int64_t ret_ref = 0;
935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
937         return ret_ref;
938 }
939
940 uint32_t CS_LDK_LDKRetry_ty_from_ptr(int64_t ptr) {
941         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
942         switch(obj->tag) {
943                 case LDKRetry_Attempts: return 0;
944                 case LDKRetry_Timeout: return 1;
945                 default: abort();
946         }
947 }
948 int32_t CS_LDK_LDKRetry_Attempts_get_attempts(int64_t ptr) {
949         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
950         CHECK(obj->tag == LDKRetry_Attempts);
951         int32_t attempts_conv = obj->attempts;
952         return attempts_conv;
953 }
954 int64_t CS_LDK_LDKRetry_Timeout_get_timeout(int64_t ptr) {
955         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
956         CHECK(obj->tag == LDKRetry_Timeout);
957         int64_t timeout_conv = obj->timeout;
958         return timeout_conv;
959 }
960 uint32_t CS_LDK_LDKDecodeError_ty_from_ptr(int64_t ptr) {
961         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
962         switch(obj->tag) {
963                 case LDKDecodeError_UnknownVersion: return 0;
964                 case LDKDecodeError_UnknownRequiredFeature: return 1;
965                 case LDKDecodeError_InvalidValue: return 2;
966                 case LDKDecodeError_ShortRead: return 3;
967                 case LDKDecodeError_BadLengthDescriptor: return 4;
968                 case LDKDecodeError_Io: return 5;
969                 case LDKDecodeError_UnsupportedCompression: return 6;
970                 default: abort();
971         }
972 }
973 int32_t CS_LDK_LDKDecodeError_Io_get_io(int64_t ptr) {
974         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
975         CHECK(obj->tag == LDKDecodeError_Io);
976         int32_t io_conv = LDKIOError_to_cs(obj->io);
977         return io_conv;
978 }
979 static inline struct LDKRetry CResult_RetryDecodeErrorZ_get_ok(LDKCResult_RetryDecodeErrorZ *NONNULL_PTR owner){
980 CHECK(owner->result_ok);
981         return Retry_clone(&*owner->contents.result);
982 }
983 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_get_ok(int64_t owner) {
984         LDKCResult_RetryDecodeErrorZ* owner_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(owner);
985         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
986         *ret_copy = CResult_RetryDecodeErrorZ_get_ok(owner_conv);
987         int64_t ret_ref = tag_ptr(ret_copy, true);
988         return ret_ref;
989 }
990
991 static inline struct LDKDecodeError CResult_RetryDecodeErrorZ_get_err(LDKCResult_RetryDecodeErrorZ *NONNULL_PTR owner){
992 CHECK(!owner->result_ok);
993         return DecodeError_clone(&*owner->contents.err);
994 }
995 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_get_err(int64_t owner) {
996         LDKCResult_RetryDecodeErrorZ* owner_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(owner);
997         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
998         *ret_copy = CResult_RetryDecodeErrorZ_get_err(owner_conv);
999         int64_t ret_ref = tag_ptr(ret_copy, true);
1000         return ret_ref;
1001 }
1002
1003 uint32_t CS_LDK_LDKAPIError_ty_from_ptr(int64_t ptr) {
1004         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1005         switch(obj->tag) {
1006                 case LDKAPIError_APIMisuseError: return 0;
1007                 case LDKAPIError_FeeRateTooHigh: return 1;
1008                 case LDKAPIError_InvalidRoute: return 2;
1009                 case LDKAPIError_ChannelUnavailable: return 3;
1010                 case LDKAPIError_MonitorUpdateInProgress: return 4;
1011                 case LDKAPIError_IncompatibleShutdownScript: return 5;
1012                 default: abort();
1013         }
1014 }
1015 jstring CS_LDK_LDKAPIError_APIMisuseError_get_err(int64_t ptr) {
1016         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1017         CHECK(obj->tag == LDKAPIError_APIMisuseError);
1018         LDKStr err_str = obj->api_misuse_error.err;
1019                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1020         return err_conv;
1021 }
1022 jstring CS_LDK_LDKAPIError_FeeRateTooHigh_get_err(int64_t ptr) {
1023         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1024         CHECK(obj->tag == LDKAPIError_FeeRateTooHigh);
1025         LDKStr err_str = obj->fee_rate_too_high.err;
1026                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1027         return err_conv;
1028 }
1029 int32_t CS_LDK_LDKAPIError_FeeRateTooHigh_get_feerate(int64_t ptr) {
1030         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1031         CHECK(obj->tag == LDKAPIError_FeeRateTooHigh);
1032         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
1033         return feerate_conv;
1034 }
1035 jstring CS_LDK_LDKAPIError_InvalidRoute_get_err(int64_t ptr) {
1036         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1037         CHECK(obj->tag == LDKAPIError_InvalidRoute);
1038         LDKStr err_str = obj->invalid_route.err;
1039                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1040         return err_conv;
1041 }
1042 jstring CS_LDK_LDKAPIError_ChannelUnavailable_get_err(int64_t ptr) {
1043         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1044         CHECK(obj->tag == LDKAPIError_ChannelUnavailable);
1045         LDKStr err_str = obj->channel_unavailable.err;
1046                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
1047         return err_conv;
1048 }
1049 int64_t CS_LDK_LDKAPIError_IncompatibleShutdownScript_get_script(int64_t ptr) {
1050         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
1051         CHECK(obj->tag == LDKAPIError_IncompatibleShutdownScript);
1052         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
1053                         int64_t script_ref = 0;
1054                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
1055                         script_ref = tag_ptr(script_var.inner, false);
1056         return script_ref;
1057 }
1058 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1059 CHECK(owner->result_ok);
1060         return *owner->contents.result;
1061 }
1062 void  CS_LDK_CResult_NoneAPIErrorZ_get_ok(int64_t owner) {
1063         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1064         CResult_NoneAPIErrorZ_get_ok(owner_conv);
1065 }
1066
1067 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
1068 CHECK(!owner->result_ok);
1069         return APIError_clone(&*owner->contents.err);
1070 }
1071 int64_t  CS_LDK_CResult_NoneAPIErrorZ_get_err(int64_t owner) {
1072         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
1073         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
1074         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
1075         int64_t ret_ref = tag_ptr(ret_copy, true);
1076         return ret_ref;
1077 }
1078
1079 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
1080         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
1081         for (size_t i = 0; i < ret.datalen; i++) {
1082                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
1083         }
1084         return ret;
1085 }
1086 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
1087         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
1088         for (size_t i = 0; i < ret.datalen; i++) {
1089                 ret.data[i] = APIError_clone(&orig->data[i]);
1090         }
1091         return ret;
1092 }
1093 uint32_t CS_LDK_LDKCOption_ThirtyTwoBytesZ_ty_from_ptr(int64_t ptr) {
1094         LDKCOption_ThirtyTwoBytesZ *obj = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(ptr);
1095         switch(obj->tag) {
1096                 case LDKCOption_ThirtyTwoBytesZ_Some: return 0;
1097                 case LDKCOption_ThirtyTwoBytesZ_None: return 1;
1098                 default: abort();
1099         }
1100 }
1101 int8_tArray CS_LDK_LDKCOption_ThirtyTwoBytesZ_Some_get_some(int64_t ptr) {
1102         LDKCOption_ThirtyTwoBytesZ *obj = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(ptr);
1103         CHECK(obj->tag == LDKCOption_ThirtyTwoBytesZ_Some);
1104         int8_tArray some_arr = init_int8_tArray(32, __LINE__);
1105         memcpy(some_arr->elems, obj->some.data, 32);
1106         return some_arr;
1107 }
1108 uint32_t CS_LDK_LDKCOption_CVec_u8ZZ_ty_from_ptr(int64_t ptr) {
1109         LDKCOption_CVec_u8ZZ *obj = (LDKCOption_CVec_u8ZZ*)untag_ptr(ptr);
1110         switch(obj->tag) {
1111                 case LDKCOption_CVec_u8ZZ_Some: return 0;
1112                 case LDKCOption_CVec_u8ZZ_None: return 1;
1113                 default: abort();
1114         }
1115 }
1116 int8_tArray CS_LDK_LDKCOption_CVec_u8ZZ_Some_get_some(int64_t ptr) {
1117         LDKCOption_CVec_u8ZZ *obj = (LDKCOption_CVec_u8ZZ*)untag_ptr(ptr);
1118         CHECK(obj->tag == LDKCOption_CVec_u8ZZ_Some);
1119         LDKCVec_u8Z some_var = obj->some;
1120                         int8_tArray some_arr = init_int8_tArray(some_var.datalen, __LINE__);
1121                         memcpy(some_arr->elems, some_var.data, some_var.datalen);
1122         return some_arr;
1123 }
1124 static inline struct LDKRecipientOnionFields CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1125         LDKRecipientOnionFields ret = *owner->contents.result;
1126         ret.is_owned = false;
1127         return ret;
1128 }
1129 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(int64_t owner) {
1130         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1131         LDKRecipientOnionFields ret_var = CResult_RecipientOnionFieldsDecodeErrorZ_get_ok(owner_conv);
1132         int64_t ret_ref = 0;
1133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1135         return ret_ref;
1136 }
1137
1138 static inline struct LDKDecodeError CResult_RecipientOnionFieldsDecodeErrorZ_get_err(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR owner){
1139 CHECK(!owner->result_ok);
1140         return DecodeError_clone(&*owner->contents.err);
1141 }
1142 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_get_err(int64_t owner) {
1143         LDKCResult_RecipientOnionFieldsDecodeErrorZ* owner_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(owner);
1144         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1145         *ret_copy = CResult_RecipientOnionFieldsDecodeErrorZ_get_err(owner_conv);
1146         int64_t ret_ref = tag_ptr(ret_copy, true);
1147         return ret_ref;
1148 }
1149
1150 static inline uint64_t C2Tuple_u64CVec_u8ZZ_get_a(LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR owner){
1151         return owner->a;
1152 }
1153 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_get_a(int64_t owner) {
1154         LDKC2Tuple_u64CVec_u8ZZ* owner_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(owner);
1155         int64_t ret_conv = C2Tuple_u64CVec_u8ZZ_get_a(owner_conv);
1156         return ret_conv;
1157 }
1158
1159 static inline struct LDKCVec_u8Z C2Tuple_u64CVec_u8ZZ_get_b(LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR owner){
1160         return CVec_u8Z_clone(&owner->b);
1161 }
1162 int8_tArray  CS_LDK_C2Tuple_u64CVec_u8ZZ_get_b(int64_t owner) {
1163         LDKC2Tuple_u64CVec_u8ZZ* owner_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(owner);
1164         LDKCVec_u8Z ret_var = C2Tuple_u64CVec_u8ZZ_get_b(owner_conv);
1165         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1166         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1167         CVec_u8Z_free(ret_var);
1168         return ret_arr;
1169 }
1170
1171 static inline LDKCVec_C2Tuple_u64CVec_u8ZZZ CVec_C2Tuple_u64CVec_u8ZZZ_clone(const LDKCVec_C2Tuple_u64CVec_u8ZZZ *orig) {
1172         LDKCVec_C2Tuple_u64CVec_u8ZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ) * orig->datalen, "LDKCVec_C2Tuple_u64CVec_u8ZZZ clone bytes"), .datalen = orig->datalen };
1173         for (size_t i = 0; i < ret.datalen; i++) {
1174                 ret.data[i] = C2Tuple_u64CVec_u8ZZ_clone(&orig->data[i]);
1175         }
1176         return ret;
1177 }
1178 static inline struct LDKRecipientOnionFields CResult_RecipientOnionFieldsNoneZ_get_ok(LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR owner){
1179         LDKRecipientOnionFields ret = *owner->contents.result;
1180         ret.is_owned = false;
1181         return ret;
1182 }
1183 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_get_ok(int64_t owner) {
1184         LDKCResult_RecipientOnionFieldsNoneZ* owner_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(owner);
1185         LDKRecipientOnionFields ret_var = CResult_RecipientOnionFieldsNoneZ_get_ok(owner_conv);
1186         int64_t ret_ref = 0;
1187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1189         return ret_ref;
1190 }
1191
1192 static inline void CResult_RecipientOnionFieldsNoneZ_get_err(LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR owner){
1193 CHECK(!owner->result_ok);
1194         return *owner->contents.err;
1195 }
1196 void  CS_LDK_CResult_RecipientOnionFieldsNoneZ_get_err(int64_t owner) {
1197         LDKCResult_RecipientOnionFieldsNoneZ* owner_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(owner);
1198         CResult_RecipientOnionFieldsNoneZ_get_err(owner_conv);
1199 }
1200
1201 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
1202         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
1203         for (size_t i = 0; i < ret.datalen; i++) {
1204                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1205         }
1206         return ret;
1207 }
1208 uint32_t CS_LDK_LDKCOption_CVec_ThirtyTwoBytesZZ_ty_from_ptr(int64_t ptr) {
1209         LDKCOption_CVec_ThirtyTwoBytesZZ *obj = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(ptr);
1210         switch(obj->tag) {
1211                 case LDKCOption_CVec_ThirtyTwoBytesZZ_Some: return 0;
1212                 case LDKCOption_CVec_ThirtyTwoBytesZZ_None: return 1;
1213                 default: abort();
1214         }
1215 }
1216 ptrArray CS_LDK_LDKCOption_CVec_ThirtyTwoBytesZZ_Some_get_some(int64_t ptr) {
1217         LDKCOption_CVec_ThirtyTwoBytesZZ *obj = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(ptr);
1218         CHECK(obj->tag == LDKCOption_CVec_ThirtyTwoBytesZZ_Some);
1219         LDKCVec_ThirtyTwoBytesZ some_var = obj->some;
1220                         ptrArray some_arr = NULL;
1221                         some_arr = init_ptrArray(some_var.datalen, __LINE__);
1222                         int8_tArray *some_arr_ptr = (int8_tArray*)(((uint8_t*)some_arr) + 8);
1223                         for (size_t i = 0; i < some_var.datalen; i++) {
1224                                 int8_tArray some_conv_8_arr = init_int8_tArray(32, __LINE__);
1225                                 memcpy(some_conv_8_arr->elems, some_var.data[i].data, 32);
1226                                 some_arr_ptr[i] = some_conv_8_arr;
1227                         }
1228                         
1229         return some_arr;
1230 }
1231 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesNoneZ_get_ok(LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR owner){
1232 CHECK(owner->result_ok);
1233         return ThirtyTwoBytes_clone(&*owner->contents.result);
1234 }
1235 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesNoneZ_get_ok(int64_t owner) {
1236         LDKCResult_ThirtyTwoBytesNoneZ* owner_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(owner);
1237         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1238         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesNoneZ_get_ok(owner_conv).data, 32);
1239         return ret_arr;
1240 }
1241
1242 static inline void CResult_ThirtyTwoBytesNoneZ_get_err(LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR owner){
1243 CHECK(!owner->result_ok);
1244         return *owner->contents.err;
1245 }
1246 void  CS_LDK_CResult_ThirtyTwoBytesNoneZ_get_err(int64_t owner) {
1247         LDKCResult_ThirtyTwoBytesNoneZ* owner_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(owner);
1248         CResult_ThirtyTwoBytesNoneZ_get_err(owner_conv);
1249 }
1250
1251 static inline struct LDKBlindedPayInfo CResult_BlindedPayInfoDecodeErrorZ_get_ok(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1252         LDKBlindedPayInfo ret = *owner->contents.result;
1253         ret.is_owned = false;
1254         return ret;
1255 }
1256 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_get_ok(int64_t owner) {
1257         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1258         LDKBlindedPayInfo ret_var = CResult_BlindedPayInfoDecodeErrorZ_get_ok(owner_conv);
1259         int64_t ret_ref = 0;
1260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1262         return ret_ref;
1263 }
1264
1265 static inline struct LDKDecodeError CResult_BlindedPayInfoDecodeErrorZ_get_err(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR owner){
1266 CHECK(!owner->result_ok);
1267         return DecodeError_clone(&*owner->contents.err);
1268 }
1269 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_get_err(int64_t owner) {
1270         LDKCResult_BlindedPayInfoDecodeErrorZ* owner_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(owner);
1271         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1272         *ret_copy = CResult_BlindedPayInfoDecodeErrorZ_get_err(owner_conv);
1273         int64_t ret_ref = tag_ptr(ret_copy, true);
1274         return ret_ref;
1275 }
1276
1277 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1278         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
1279         ret.is_owned = false;
1280         return ret;
1281 }
1282 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1283         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1284         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
1285         int64_t ret_ref = 0;
1286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1288         return ret_ref;
1289 }
1290
1291 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1292 CHECK(!owner->result_ok);
1293         return DecodeError_clone(&*owner->contents.err);
1294 }
1295 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(int64_t owner) {
1296         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1297         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1298         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
1299         int64_t ret_ref = tag_ptr(ret_copy, true);
1300         return ret_ref;
1301 }
1302
1303 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1304         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
1305         ret.is_owned = false;
1306         return ret;
1307 }
1308 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1309         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1310         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
1311         int64_t ret_ref = 0;
1312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1314         return ret_ref;
1315 }
1316
1317 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1318 CHECK(!owner->result_ok);
1319         return DecodeError_clone(&*owner->contents.err);
1320 }
1321 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(int64_t owner) {
1322         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1323         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1324         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
1325         int64_t ret_ref = tag_ptr(ret_copy, true);
1326         return ret_ref;
1327 }
1328
1329 uint32_t CS_LDK_LDKSpendableOutputDescriptor_ty_from_ptr(int64_t ptr) {
1330         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1331         switch(obj->tag) {
1332                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1333                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1334                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1335                 default: abort();
1336         }
1337 }
1338 int64_t CS_LDK_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(int64_t ptr) {
1339         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1340         CHECK(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1341         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1342                         int64_t outpoint_ref = 0;
1343                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1344                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
1345         return outpoint_ref;
1346 }
1347 int64_t CS_LDK_LDKSpendableOutputDescriptor_StaticOutput_get_output(int64_t ptr) {
1348         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1349         CHECK(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1350         LDKTxOut* output_ref = &obj->static_output.output;
1351         return tag_ptr(output_ref, false);
1352 }
1353 int64_t CS_LDK_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(int64_t ptr) {
1354         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1355         CHECK(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1356         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1357                         int64_t delayed_payment_output_ref = 0;
1358                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1359                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
1360         return delayed_payment_output_ref;
1361 }
1362 int64_t CS_LDK_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(int64_t ptr) {
1363         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
1364         CHECK(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1365         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1366                         int64_t static_payment_output_ref = 0;
1367                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1368                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
1369         return static_payment_output_ref;
1370 }
1371 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1372 CHECK(owner->result_ok);
1373         return SpendableOutputDescriptor_clone(&*owner->contents.result);
1374 }
1375 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1376         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1377         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
1378         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
1379         int64_t ret_ref = tag_ptr(ret_copy, true);
1380         return ret_ref;
1381 }
1382
1383 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
1384 CHECK(!owner->result_ok);
1385         return DecodeError_clone(&*owner->contents.err);
1386 }
1387 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(int64_t owner) {
1388         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
1389         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1390         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
1391         int64_t ret_ref = tag_ptr(ret_copy, true);
1392         return ret_ref;
1393 }
1394
1395 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1396         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1397         for (size_t i = 0; i < ret.datalen; i++) {
1398                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1399         }
1400         return ret;
1401 }
1402 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
1403         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
1404         for (size_t i = 0; i < ret.datalen; i++) {
1405                 ret.data[i] = TxOut_clone(&orig->data[i]);
1406         }
1407         return ret;
1408 }
1409 uint32_t CS_LDK_LDKCOption_u32Z_ty_from_ptr(int64_t ptr) {
1410         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1411         switch(obj->tag) {
1412                 case LDKCOption_u32Z_Some: return 0;
1413                 case LDKCOption_u32Z_None: return 1;
1414                 default: abort();
1415         }
1416 }
1417 int32_t CS_LDK_LDKCOption_u32Z_Some_get_some(int64_t ptr) {
1418         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1419         CHECK(obj->tag == LDKCOption_u32Z_Some);
1420         int32_t some_conv = obj->some;
1421         return some_conv;
1422 }
1423 static inline struct LDKCVec_u8Z C2Tuple_CVec_u8ZusizeZ_get_a(LDKC2Tuple_CVec_u8ZusizeZ *NONNULL_PTR owner){
1424         return CVec_u8Z_clone(&owner->a);
1425 }
1426 int8_tArray  CS_LDK_C2Tuple_CVec_u8ZusizeZ_get_a(int64_t owner) {
1427         LDKC2Tuple_CVec_u8ZusizeZ* owner_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(owner);
1428         LDKCVec_u8Z ret_var = C2Tuple_CVec_u8ZusizeZ_get_a(owner_conv);
1429         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1430         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1431         CVec_u8Z_free(ret_var);
1432         return ret_arr;
1433 }
1434
1435 static inline uintptr_t C2Tuple_CVec_u8ZusizeZ_get_b(LDKC2Tuple_CVec_u8ZusizeZ *NONNULL_PTR owner){
1436         return owner->b;
1437 }
1438 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_get_b(int64_t owner) {
1439         LDKC2Tuple_CVec_u8ZusizeZ* owner_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(owner);
1440         int64_t ret_conv = C2Tuple_CVec_u8ZusizeZ_get_b(owner_conv);
1441         return ret_conv;
1442 }
1443
1444 static inline struct LDKC2Tuple_CVec_u8ZusizeZ CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_ok(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ *NONNULL_PTR owner){
1445 CHECK(owner->result_ok);
1446         return C2Tuple_CVec_u8ZusizeZ_clone(&*owner->contents.result);
1447 }
1448 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_ok(int64_t owner) {
1449         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* owner_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(owner);
1450         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
1451         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_ok(owner_conv);
1452         return tag_ptr(ret_conv, true);
1453 }
1454
1455 static inline void CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_err(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ *NONNULL_PTR owner){
1456 CHECK(!owner->result_ok);
1457         return *owner->contents.err;
1458 }
1459 void  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_err(int64_t owner) {
1460         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* owner_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(owner);
1461         CResult_C2Tuple_CVec_u8ZusizeZNoneZ_get_err(owner_conv);
1462 }
1463
1464 static inline struct LDKChannelDerivationParameters CResult_ChannelDerivationParametersDecodeErrorZ_get_ok(LDKCResult_ChannelDerivationParametersDecodeErrorZ *NONNULL_PTR owner){
1465         LDKChannelDerivationParameters ret = *owner->contents.result;
1466         ret.is_owned = false;
1467         return ret;
1468 }
1469 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_get_ok(int64_t owner) {
1470         LDKCResult_ChannelDerivationParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(owner);
1471         LDKChannelDerivationParameters ret_var = CResult_ChannelDerivationParametersDecodeErrorZ_get_ok(owner_conv);
1472         int64_t ret_ref = 0;
1473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1474         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1475         return ret_ref;
1476 }
1477
1478 static inline struct LDKDecodeError CResult_ChannelDerivationParametersDecodeErrorZ_get_err(LDKCResult_ChannelDerivationParametersDecodeErrorZ *NONNULL_PTR owner){
1479 CHECK(!owner->result_ok);
1480         return DecodeError_clone(&*owner->contents.err);
1481 }
1482 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_get_err(int64_t owner) {
1483         LDKCResult_ChannelDerivationParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(owner);
1484         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1485         *ret_copy = CResult_ChannelDerivationParametersDecodeErrorZ_get_err(owner_conv);
1486         int64_t ret_ref = tag_ptr(ret_copy, true);
1487         return ret_ref;
1488 }
1489
1490 static inline struct LDKHTLCDescriptor CResult_HTLCDescriptorDecodeErrorZ_get_ok(LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR owner){
1491         LDKHTLCDescriptor ret = *owner->contents.result;
1492         ret.is_owned = false;
1493         return ret;
1494 }
1495 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_get_ok(int64_t owner) {
1496         LDKCResult_HTLCDescriptorDecodeErrorZ* owner_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(owner);
1497         LDKHTLCDescriptor ret_var = CResult_HTLCDescriptorDecodeErrorZ_get_ok(owner_conv);
1498         int64_t ret_ref = 0;
1499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1500         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1501         return ret_ref;
1502 }
1503
1504 static inline struct LDKDecodeError CResult_HTLCDescriptorDecodeErrorZ_get_err(LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR owner){
1505 CHECK(!owner->result_ok);
1506         return DecodeError_clone(&*owner->contents.err);
1507 }
1508 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_get_err(int64_t owner) {
1509         LDKCResult_HTLCDescriptorDecodeErrorZ* owner_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(owner);
1510         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1511         *ret_copy = CResult_HTLCDescriptorDecodeErrorZ_get_err(owner_conv);
1512         int64_t ret_ref = tag_ptr(ret_copy, true);
1513         return ret_ref;
1514 }
1515
1516 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1517 CHECK(owner->result_ok);
1518         return *owner->contents.result;
1519 }
1520 void  CS_LDK_CResult_NoneNoneZ_get_ok(int64_t owner) {
1521         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1522         CResult_NoneNoneZ_get_ok(owner_conv);
1523 }
1524
1525 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1526 CHECK(!owner->result_ok);
1527         return *owner->contents.err;
1528 }
1529 void  CS_LDK_CResult_NoneNoneZ_get_err(int64_t owner) {
1530         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1531         CResult_NoneNoneZ_get_err(owner_conv);
1532 }
1533
1534 static inline struct LDKECDSASignature C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_a(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ *NONNULL_PTR owner){
1535         return owner->a;
1536 }
1537 int8_tArray  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_a(int64_t owner) {
1538         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* owner_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(owner);
1539         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1540         memcpy(ret_arr->elems, C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_a(owner_conv).compact_form, 64);
1541         return ret_arr;
1542 }
1543
1544 static inline struct LDKCVec_ECDSASignatureZ C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_b(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ *NONNULL_PTR owner){
1545         return owner->b;
1546 }
1547 ptrArray  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_b(int64_t owner) {
1548         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* owner_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(owner);
1549         LDKCVec_ECDSASignatureZ ret_var = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_get_b(owner_conv);
1550         ptrArray ret_arr = NULL;
1551         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
1552         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
1553         for (size_t i = 0; i < ret_var.datalen; i++) {
1554                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
1555                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
1556                 ret_arr_ptr[i] = ret_conv_8_arr;
1557         }
1558         
1559         return ret_arr;
1560 }
1561
1562 static inline struct LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ *NONNULL_PTR owner){
1563 CHECK(owner->result_ok);
1564         return C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(&*owner->contents.result);
1565 }
1566 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_ok(int64_t owner) {
1567         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(owner);
1568         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
1569         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_ok(owner_conv);
1570         return tag_ptr(ret_conv, true);
1571 }
1572
1573 static inline void CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_err(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ *NONNULL_PTR owner){
1574 CHECK(!owner->result_ok);
1575         return *owner->contents.err;
1576 }
1577 void  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_err(int64_t owner) {
1578         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(owner);
1579         CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_get_err(owner_conv);
1580 }
1581
1582 static inline struct LDKECDSASignature CResult_ECDSASignatureNoneZ_get_ok(LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR owner){
1583 CHECK(owner->result_ok);
1584         return *owner->contents.result;
1585 }
1586 int8_tArray  CS_LDK_CResult_ECDSASignatureNoneZ_get_ok(int64_t owner) {
1587         LDKCResult_ECDSASignatureNoneZ* owner_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(owner);
1588         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1589         memcpy(ret_arr->elems, CResult_ECDSASignatureNoneZ_get_ok(owner_conv).compact_form, 64);
1590         return ret_arr;
1591 }
1592
1593 static inline void CResult_ECDSASignatureNoneZ_get_err(LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR owner){
1594 CHECK(!owner->result_ok);
1595         return *owner->contents.err;
1596 }
1597 void  CS_LDK_CResult_ECDSASignatureNoneZ_get_err(int64_t owner) {
1598         LDKCResult_ECDSASignatureNoneZ* owner_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(owner);
1599         CResult_ECDSASignatureNoneZ_get_err(owner_conv);
1600 }
1601
1602 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
1603 CHECK(owner->result_ok);
1604         return *owner->contents.result;
1605 }
1606 int8_tArray  CS_LDK_CResult_PublicKeyNoneZ_get_ok(int64_t owner) {
1607         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
1608         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
1609         memcpy(ret_arr->elems, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form, 33);
1610         return ret_arr;
1611 }
1612
1613 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
1614 CHECK(!owner->result_ok);
1615         return *owner->contents.err;
1616 }
1617 void  CS_LDK_CResult_PublicKeyNoneZ_get_err(int64_t owner) {
1618         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
1619         CResult_PublicKeyNoneZ_get_err(owner_conv);
1620 }
1621
1622 uint32_t CS_LDK_LDKCOption_BigEndianScalarZ_ty_from_ptr(int64_t ptr) {
1623         LDKCOption_BigEndianScalarZ *obj = (LDKCOption_BigEndianScalarZ*)untag_ptr(ptr);
1624         switch(obj->tag) {
1625                 case LDKCOption_BigEndianScalarZ_Some: return 0;
1626                 case LDKCOption_BigEndianScalarZ_None: return 1;
1627                 default: abort();
1628         }
1629 }
1630 int64_t CS_LDK_LDKCOption_BigEndianScalarZ_Some_get_some(int64_t ptr) {
1631         LDKCOption_BigEndianScalarZ *obj = (LDKCOption_BigEndianScalarZ*)untag_ptr(ptr);
1632         CHECK(obj->tag == LDKCOption_BigEndianScalarZ_Some);
1633         LDKBigEndianScalar* some_ref = &obj->some;
1634         return tag_ptr(some_ref, false);
1635 }
1636 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
1637 CHECK(owner->result_ok);
1638         return *owner->contents.result;
1639 }
1640 int8_tArray  CS_LDK_CResult_RecoverableSignatureNoneZ_get_ok(int64_t owner) {
1641         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
1642         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
1643         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
1644         return ret_arr;
1645 }
1646
1647 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
1648 CHECK(!owner->result_ok);
1649         return *owner->contents.err;
1650 }
1651 void  CS_LDK_CResult_RecoverableSignatureNoneZ_get_err(int64_t owner) {
1652         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
1653         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
1654 }
1655
1656 static inline struct LDKSchnorrSignature CResult_SchnorrSignatureNoneZ_get_ok(LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR owner){
1657 CHECK(owner->result_ok);
1658         return *owner->contents.result;
1659 }
1660 int8_tArray  CS_LDK_CResult_SchnorrSignatureNoneZ_get_ok(int64_t owner) {
1661         LDKCResult_SchnorrSignatureNoneZ* owner_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(owner);
1662         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1663         memcpy(ret_arr->elems, CResult_SchnorrSignatureNoneZ_get_ok(owner_conv).compact_form, 64);
1664         return ret_arr;
1665 }
1666
1667 static inline void CResult_SchnorrSignatureNoneZ_get_err(LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR owner){
1668 CHECK(!owner->result_ok);
1669         return *owner->contents.err;
1670 }
1671 void  CS_LDK_CResult_SchnorrSignatureNoneZ_get_err(int64_t owner) {
1672         LDKCResult_SchnorrSignatureNoneZ* owner_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(owner);
1673         CResult_SchnorrSignatureNoneZ_get_err(owner_conv);
1674 }
1675
1676 typedef struct LDKChannelSigner_JCalls {
1677         atomic_size_t refcnt;
1678         uint32_t instance_ptr;
1679 } LDKChannelSigner_JCalls;
1680 static void LDKChannelSigner_JCalls_free(void* this_arg) {
1681         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1682         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1683                 FREE(j_calls);
1684         }
1685 }
1686 LDKPublicKey get_per_commitment_point_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
1687         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1688         int64_t idx_conv = idx;
1689         int8_tArray ret = (int8_tArray)js_invoke_function_l_l(j_calls->instance_ptr, 0, idx_conv);
1690         LDKPublicKey ret_ref;
1691         CHECK(ret->arr_len == 33);
1692         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
1693         return ret_ref;
1694 }
1695 LDKThirtyTwoBytes release_commitment_secret_LDKChannelSigner_jcall(const void* this_arg, uint64_t idx) {
1696         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1697         int64_t idx_conv = idx;
1698         int8_tArray ret = (int8_tArray)js_invoke_function_l_l(j_calls->instance_ptr, 1, idx_conv);
1699         LDKThirtyTwoBytes ret_ref;
1700         CHECK(ret->arr_len == 32);
1701         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1702         return ret_ref;
1703 }
1704 LDKCResult_NoneNoneZ validate_holder_commitment_LDKChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_ThirtyTwoBytesZ preimages) {
1705         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1706         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1707         int64_t holder_tx_ref = 0;
1708         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
1709         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
1710         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
1711         LDKCVec_ThirtyTwoBytesZ preimages_var = preimages;
1712         ptrArray preimages_arr = NULL;
1713         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
1714         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
1715         for (size_t i = 0; i < preimages_var.datalen; i++) {
1716                 int8_tArray preimages_conv_8_arr = init_int8_tArray(32, __LINE__);
1717                 memcpy(preimages_conv_8_arr->elems, preimages_var.data[i].data, 32);
1718                 preimages_arr_ptr[i] = preimages_conv_8_arr;
1719         }
1720         
1721         FREE(preimages_var.data);
1722         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 2, holder_tx_ref, (int64_t)preimages_arr);
1723         void* ret_ptr = untag_ptr(ret);
1724         CHECK_ACCESS(ret_ptr);
1725         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1726         FREE(untag_ptr(ret));
1727         return ret_conv;
1728 }
1729 LDKThirtyTwoBytes channel_keys_id_LDKChannelSigner_jcall(const void* this_arg) {
1730         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1731         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 3);
1732         LDKThirtyTwoBytes ret_ref;
1733         CHECK(ret->arr_len == 32);
1734         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1735         return ret_ref;
1736 }
1737 void provide_channel_parameters_LDKChannelSigner_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1738         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) this_arg;
1739         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1740         int64_t channel_parameters_ref = 0;
1741         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
1742         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
1743         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
1744         js_invoke_function_void_l(j_calls->instance_ptr, 4, channel_parameters_ref);
1745 }
1746 static void LDKChannelSigner_JCalls_cloned(LDKChannelSigner* new_obj) {
1747         LDKChannelSigner_JCalls *j_calls = (LDKChannelSigner_JCalls*) new_obj->this_arg;
1748         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1749 }
1750 static inline LDKChannelSigner LDKChannelSigner_init (int64_t o, int64_t pubkeys) {
1751         LDKChannelSigner_JCalls *calls = MALLOC(sizeof(LDKChannelSigner_JCalls), "LDKChannelSigner_JCalls");
1752         atomic_init(&calls->refcnt, 1);
1753         calls->instance_ptr = o;
1754
1755         LDKChannelPublicKeys pubkeys_conv;
1756         pubkeys_conv.inner = untag_ptr(pubkeys);
1757         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
1758         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
1759
1760         LDKChannelSigner ret = {
1761                 .this_arg = (void*) calls,
1762                 .get_per_commitment_point = get_per_commitment_point_LDKChannelSigner_jcall,
1763                 .release_commitment_secret = release_commitment_secret_LDKChannelSigner_jcall,
1764                 .validate_holder_commitment = validate_holder_commitment_LDKChannelSigner_jcall,
1765                 .channel_keys_id = channel_keys_id_LDKChannelSigner_jcall,
1766                 .provide_channel_parameters = provide_channel_parameters_LDKChannelSigner_jcall,
1767                 .free = LDKChannelSigner_JCalls_free,
1768                 .pubkeys = pubkeys_conv,
1769                 .set_pubkeys = NULL,
1770         };
1771         return ret;
1772 }
1773 uint64_t  CS_LDK_LDKChannelSigner_new(int32_t o, int64_t pubkeys) {
1774         LDKChannelSigner *res_ptr = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
1775         *res_ptr = LDKChannelSigner_init(o, pubkeys);
1776         return tag_ptr(res_ptr, true);
1777 }
1778 int8_tArray  CS_LDK_ChannelSigner_get_per_commitment_point(int64_t this_arg, int64_t idx) {
1779         void* this_arg_ptr = untag_ptr(this_arg);
1780         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1781         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1782         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
1783         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1784         return ret_arr;
1785 }
1786
1787 int8_tArray  CS_LDK_ChannelSigner_release_commitment_secret(int64_t this_arg, int64_t idx) {
1788         void* this_arg_ptr = untag_ptr(this_arg);
1789         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1790         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1791         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1792         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1793         return ret_arr;
1794 }
1795
1796 int64_t  CS_LDK_ChannelSigner_validate_holder_commitment(int64_t this_arg, int64_t holder_tx, ptrArray preimages) {
1797         void* this_arg_ptr = untag_ptr(this_arg);
1798         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1799         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1800         LDKHolderCommitmentTransaction holder_tx_conv;
1801         holder_tx_conv.inner = untag_ptr(holder_tx);
1802         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
1803         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
1804         holder_tx_conv.is_owned = false;
1805         LDKCVec_ThirtyTwoBytesZ preimages_constr;
1806         preimages_constr.datalen = preimages->arr_len;
1807         if (preimages_constr.datalen > 0)
1808                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
1809         else
1810                 preimages_constr.data = NULL;
1811         int8_tArray* preimages_vals = (void*) preimages->elems;
1812         for (size_t i = 0; i < preimages_constr.datalen; i++) {
1813                 int8_tArray preimages_conv_8 = preimages_vals[i];
1814                 LDKThirtyTwoBytes preimages_conv_8_ref;
1815                 CHECK(preimages_conv_8->arr_len == 32);
1816                 memcpy(preimages_conv_8_ref.data, preimages_conv_8->elems, 32); FREE(preimages_conv_8);
1817                 preimages_constr.data[i] = preimages_conv_8_ref;
1818         }
1819         FREE(preimages);
1820         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
1821         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
1822         return tag_ptr(ret_conv, true);
1823 }
1824
1825 int8_tArray  CS_LDK_ChannelSigner_channel_keys_id(int64_t this_arg) {
1826         void* this_arg_ptr = untag_ptr(this_arg);
1827         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1828         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1829         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1830         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
1831         return ret_arr;
1832 }
1833
1834 void  CS_LDK_ChannelSigner_provide_channel_parameters(int64_t this_arg, int64_t channel_parameters) {
1835         void* this_arg_ptr = untag_ptr(this_arg);
1836         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1837         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1838         LDKChannelTransactionParameters channel_parameters_conv;
1839         channel_parameters_conv.inner = untag_ptr(channel_parameters);
1840         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
1841         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
1842         channel_parameters_conv.is_owned = false;
1843         (this_arg_conv->provide_channel_parameters)(this_arg_conv->this_arg, &channel_parameters_conv);
1844 }
1845
1846 LDKChannelPublicKeys LDKChannelSigner_set_get_pubkeys(LDKChannelSigner* this_arg) {
1847         if (this_arg->set_pubkeys != NULL)
1848                 this_arg->set_pubkeys(this_arg);
1849         return this_arg->pubkeys;
1850 }
1851 int64_t  CS_LDK_ChannelSigner_get_pubkeys(int64_t this_arg) {
1852         void* this_arg_ptr = untag_ptr(this_arg);
1853         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1854         LDKChannelSigner* this_arg_conv = (LDKChannelSigner*)this_arg_ptr;
1855         LDKChannelPublicKeys ret_var = LDKChannelSigner_set_get_pubkeys(this_arg_conv);
1856         int64_t ret_ref = 0;
1857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1859         return ret_ref;
1860 }
1861
1862 typedef struct LDKEcdsaChannelSigner_JCalls {
1863         atomic_size_t refcnt;
1864         uint32_t instance_ptr;
1865         LDKChannelSigner_JCalls* ChannelSigner;
1866 } LDKEcdsaChannelSigner_JCalls;
1867 static void LDKEcdsaChannelSigner_JCalls_free(void* this_arg) {
1868         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1869         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1870                 FREE(j_calls);
1871         }
1872 }
1873 LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_ThirtyTwoBytesZ preimages) {
1874         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1875         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1876         int64_t commitment_tx_ref = 0;
1877         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
1878         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1879         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
1880         LDKCVec_ThirtyTwoBytesZ preimages_var = preimages;
1881         ptrArray preimages_arr = NULL;
1882         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
1883         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 8);
1884         for (size_t i = 0; i < preimages_var.datalen; i++) {
1885                 int8_tArray preimages_conv_8_arr = init_int8_tArray(32, __LINE__);
1886                 memcpy(preimages_conv_8_arr->elems, preimages_var.data[i].data, 32);
1887                 preimages_arr_ptr[i] = preimages_conv_8_arr;
1888         }
1889         
1890         FREE(preimages_var.data);
1891         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 5, commitment_tx_ref, (int64_t)preimages_arr);
1892         void* ret_ptr = untag_ptr(ret);
1893         CHECK_ACCESS(ret_ptr);
1894         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)(ret_ptr);
1895         FREE(untag_ptr(ret));
1896         return ret_conv;
1897 }
1898 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1899         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1900         int64_t idx_conv = idx;
1901         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
1902         memcpy(secret_arr->elems, *secret, 32);
1903         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 6, idx_conv, (int64_t)secret_arr);
1904         void* ret_ptr = untag_ptr(ret);
1905         CHECK_ACCESS(ret_ptr);
1906         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1907         FREE(untag_ptr(ret));
1908         return ret_conv;
1909 }
1910 LDKCResult_ECDSASignatureNoneZ sign_holder_commitment_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1911         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1912         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1913         int64_t commitment_tx_ref = 0;
1914         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
1915         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1916         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
1917         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 7, commitment_tx_ref);
1918         void* ret_ptr = untag_ptr(ret);
1919         CHECK_ACCESS(ret_ptr);
1920         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1921         FREE(untag_ptr(ret));
1922         return ret_conv;
1923 }
1924 LDKCResult_ECDSASignatureNoneZ sign_justice_revoked_output_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
1925         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1926         LDKTransaction justice_tx_var = justice_tx;
1927         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
1928         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
1929         Transaction_free(justice_tx_var);
1930         int64_t input_conv = input;
1931         int64_t amount_conv = amount;
1932         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
1933         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
1934         uint64_t ret = js_invoke_function_l_llll(j_calls->instance_ptr, 8, (int64_t)justice_tx_arr, input_conv, amount_conv, (int64_t)per_commitment_key_arr);
1935         void* ret_ptr = untag_ptr(ret);
1936         CHECK_ACCESS(ret_ptr);
1937         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1938         FREE(untag_ptr(ret));
1939         return ret_conv;
1940 }
1941 LDKCResult_ECDSASignatureNoneZ sign_justice_revoked_htlc_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
1942         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1943         LDKTransaction justice_tx_var = justice_tx;
1944         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
1945         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
1946         Transaction_free(justice_tx_var);
1947         int64_t input_conv = input;
1948         int64_t amount_conv = amount;
1949         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
1950         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
1951         LDKHTLCOutputInCommitment htlc_var = *htlc;
1952         int64_t htlc_ref = 0;
1953         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
1954         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
1955         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
1956         uint64_t ret = js_invoke_function_l_lllll(j_calls->instance_ptr, 9, (int64_t)justice_tx_arr, input_conv, amount_conv, (int64_t)per_commitment_key_arr, htlc_ref);
1957         void* ret_ptr = untag_ptr(ret);
1958         CHECK_ACCESS(ret_ptr);
1959         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1960         FREE(untag_ptr(ret));
1961         return ret_conv;
1962 }
1963 LDKCResult_ECDSASignatureNoneZ sign_holder_htlc_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, const LDKHTLCDescriptor * htlc_descriptor) {
1964         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1965         LDKTransaction htlc_tx_var = htlc_tx;
1966         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
1967         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
1968         Transaction_free(htlc_tx_var);
1969         int64_t input_conv = input;
1970         LDKHTLCDescriptor htlc_descriptor_var = *htlc_descriptor;
1971         int64_t htlc_descriptor_ref = 0;
1972         htlc_descriptor_var = HTLCDescriptor_clone(&htlc_descriptor_var);
1973         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptor_var);
1974         htlc_descriptor_ref = tag_ptr(htlc_descriptor_var.inner, htlc_descriptor_var.is_owned);
1975         uint64_t ret = js_invoke_function_l_lll(j_calls->instance_ptr, 10, (int64_t)htlc_tx_arr, input_conv, htlc_descriptor_ref);
1976         void* ret_ptr = untag_ptr(ret);
1977         CHECK_ACCESS(ret_ptr);
1978         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
1979         FREE(untag_ptr(ret));
1980         return ret_conv;
1981 }
1982 LDKCResult_ECDSASignatureNoneZ sign_counterparty_htlc_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
1983         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
1984         LDKTransaction htlc_tx_var = htlc_tx;
1985         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
1986         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
1987         Transaction_free(htlc_tx_var);
1988         int64_t input_conv = input;
1989         int64_t amount_conv = amount;
1990         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
1991         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
1992         LDKHTLCOutputInCommitment htlc_var = *htlc;
1993         int64_t htlc_ref = 0;
1994         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
1995         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
1996         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
1997         uint64_t ret = js_invoke_function_l_lllll(j_calls->instance_ptr, 11, (int64_t)htlc_tx_arr, input_conv, amount_conv, (int64_t)per_commitment_point_arr, htlc_ref);
1998         void* ret_ptr = untag_ptr(ret);
1999         CHECK_ACCESS(ret_ptr);
2000         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2001         FREE(untag_ptr(ret));
2002         return ret_conv;
2003 }
2004 LDKCResult_ECDSASignatureNoneZ sign_closing_transaction_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2005         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
2006         LDKClosingTransaction closing_tx_var = *closing_tx;
2007         int64_t closing_tx_ref = 0;
2008         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
2009         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
2010         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
2011         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 12, closing_tx_ref);
2012         void* ret_ptr = untag_ptr(ret);
2013         CHECK_ACCESS(ret_ptr);
2014         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2015         FREE(untag_ptr(ret));
2016         return ret_conv;
2017 }
2018 LDKCResult_ECDSASignatureNoneZ sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
2019         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
2020         LDKTransaction anchor_tx_var = anchor_tx;
2021         int8_tArray anchor_tx_arr = init_int8_tArray(anchor_tx_var.datalen, __LINE__);
2022         memcpy(anchor_tx_arr->elems, anchor_tx_var.data, anchor_tx_var.datalen);
2023         Transaction_free(anchor_tx_var);
2024         int64_t input_conv = input;
2025         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 13, (int64_t)anchor_tx_arr, input_conv);
2026         void* ret_ptr = untag_ptr(ret);
2027         CHECK_ACCESS(ret_ptr);
2028         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2029         FREE(untag_ptr(ret));
2030         return ret_conv;
2031 }
2032 LDKCResult_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2033         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) this_arg;
2034         LDKUnsignedChannelAnnouncement msg_var = *msg;
2035         int64_t msg_ref = 0;
2036         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
2037         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2038         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
2039         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 14, msg_ref);
2040         void* ret_ptr = untag_ptr(ret);
2041         CHECK_ACCESS(ret_ptr);
2042         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
2043         FREE(untag_ptr(ret));
2044         return ret_conv;
2045 }
2046 static void LDKEcdsaChannelSigner_JCalls_cloned(LDKEcdsaChannelSigner* new_obj) {
2047         LDKEcdsaChannelSigner_JCalls *j_calls = (LDKEcdsaChannelSigner_JCalls*) new_obj->this_arg;
2048         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2049         atomic_fetch_add_explicit(&j_calls->ChannelSigner->refcnt, 1, memory_order_release);
2050 }
2051 static inline LDKEcdsaChannelSigner LDKEcdsaChannelSigner_init (int64_t o, int64_t ChannelSigner, int64_t pubkeys) {
2052         LDKEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKEcdsaChannelSigner_JCalls), "LDKEcdsaChannelSigner_JCalls");
2053         atomic_init(&calls->refcnt, 1);
2054         calls->instance_ptr = o;
2055
2056         LDKChannelPublicKeys pubkeys_conv;
2057         pubkeys_conv.inner = untag_ptr(pubkeys);
2058         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
2059         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2060
2061         LDKEcdsaChannelSigner ret = {
2062                 .this_arg = (void*) calls,
2063                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKEcdsaChannelSigner_jcall,
2064                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKEcdsaChannelSigner_jcall,
2065                 .sign_holder_commitment = sign_holder_commitment_LDKEcdsaChannelSigner_jcall,
2066                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKEcdsaChannelSigner_jcall,
2067                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKEcdsaChannelSigner_jcall,
2068                 .sign_holder_htlc_transaction = sign_holder_htlc_transaction_LDKEcdsaChannelSigner_jcall,
2069                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKEcdsaChannelSigner_jcall,
2070                 .sign_closing_transaction = sign_closing_transaction_LDKEcdsaChannelSigner_jcall,
2071                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKEcdsaChannelSigner_jcall,
2072                 .sign_channel_announcement_with_funding_key = sign_channel_announcement_with_funding_key_LDKEcdsaChannelSigner_jcall,
2073                 .free = LDKEcdsaChannelSigner_JCalls_free,
2074                 .ChannelSigner = LDKChannelSigner_init(ChannelSigner, pubkeys),
2075         };
2076         calls->ChannelSigner = ret.ChannelSigner.this_arg;
2077         return ret;
2078 }
2079 uint64_t  CS_LDK_LDKEcdsaChannelSigner_new(int32_t o, int32_t ChannelSigner, int64_t pubkeys) {
2080         LDKEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
2081         *res_ptr = LDKEcdsaChannelSigner_init(o, ChannelSigner, pubkeys);
2082         return tag_ptr(res_ptr, true);
2083 }
2084 int64_t  CS_LDK_EcdsaChannelSigner_sign_counterparty_commitment(int64_t this_arg, int64_t commitment_tx, ptrArray preimages) {
2085         void* this_arg_ptr = untag_ptr(this_arg);
2086         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2087         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2088         LDKCommitmentTransaction commitment_tx_conv;
2089         commitment_tx_conv.inner = untag_ptr(commitment_tx);
2090         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
2091         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2092         commitment_tx_conv.is_owned = false;
2093         LDKCVec_ThirtyTwoBytesZ preimages_constr;
2094         preimages_constr.datalen = preimages->arr_len;
2095         if (preimages_constr.datalen > 0)
2096                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
2097         else
2098                 preimages_constr.data = NULL;
2099         int8_tArray* preimages_vals = (void*) preimages->elems;
2100         for (size_t i = 0; i < preimages_constr.datalen; i++) {
2101                 int8_tArray preimages_conv_8 = preimages_vals[i];
2102                 LDKThirtyTwoBytes preimages_conv_8_ref;
2103                 CHECK(preimages_conv_8->arr_len == 32);
2104                 memcpy(preimages_conv_8_ref.data, preimages_conv_8->elems, 32); FREE(preimages_conv_8);
2105                 preimages_constr.data[i] = preimages_conv_8_ref;
2106         }
2107         FREE(preimages);
2108         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
2109         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
2110         return tag_ptr(ret_conv, true);
2111 }
2112
2113 int64_t  CS_LDK_EcdsaChannelSigner_validate_counterparty_revocation(int64_t this_arg, int64_t idx, int8_tArray secret) {
2114         void* this_arg_ptr = untag_ptr(this_arg);
2115         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2116         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2117         uint8_t secret_arr[32];
2118         CHECK(secret->arr_len == 32);
2119         memcpy(secret_arr, secret->elems, 32); FREE(secret);
2120         uint8_t (*secret_ref)[32] = &secret_arr;
2121         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2122         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2123         return tag_ptr(ret_conv, true);
2124 }
2125
2126 int64_t  CS_LDK_EcdsaChannelSigner_sign_holder_commitment(int64_t this_arg, int64_t commitment_tx) {
2127         void* this_arg_ptr = untag_ptr(this_arg);
2128         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2129         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2130         LDKHolderCommitmentTransaction commitment_tx_conv;
2131         commitment_tx_conv.inner = untag_ptr(commitment_tx);
2132         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
2133         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2134         commitment_tx_conv.is_owned = false;
2135         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2136         *ret_conv = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2137         return tag_ptr(ret_conv, true);
2138 }
2139
2140 int64_t  CS_LDK_EcdsaChannelSigner_sign_justice_revoked_output(int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
2141         void* this_arg_ptr = untag_ptr(this_arg);
2142         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2143         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2144         LDKTransaction justice_tx_ref;
2145         justice_tx_ref.datalen = justice_tx->arr_len;
2146         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2147         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2148         justice_tx_ref.data_is_owned = true;
2149         uint8_t per_commitment_key_arr[32];
2150         CHECK(per_commitment_key->arr_len == 32);
2151         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2152         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2153         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2154         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2155         return tag_ptr(ret_conv, true);
2156 }
2157
2158 int64_t  CS_LDK_EcdsaChannelSigner_sign_justice_revoked_htlc(int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
2159         void* this_arg_ptr = untag_ptr(this_arg);
2160         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2161         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2162         LDKTransaction justice_tx_ref;
2163         justice_tx_ref.datalen = justice_tx->arr_len;
2164         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2165         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2166         justice_tx_ref.data_is_owned = true;
2167         uint8_t per_commitment_key_arr[32];
2168         CHECK(per_commitment_key->arr_len == 32);
2169         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2170         uint8_t (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2171         LDKHTLCOutputInCommitment htlc_conv;
2172         htlc_conv.inner = untag_ptr(htlc);
2173         htlc_conv.is_owned = ptr_is_owned(htlc);
2174         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2175         htlc_conv.is_owned = false;
2176         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2177         *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);
2178         return tag_ptr(ret_conv, true);
2179 }
2180
2181 int64_t  CS_LDK_EcdsaChannelSigner_sign_holder_htlc_transaction(int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t htlc_descriptor) {
2182         void* this_arg_ptr = untag_ptr(this_arg);
2183         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2184         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2185         LDKTransaction htlc_tx_ref;
2186         htlc_tx_ref.datalen = htlc_tx->arr_len;
2187         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2188         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
2189         htlc_tx_ref.data_is_owned = true;
2190         LDKHTLCDescriptor htlc_descriptor_conv;
2191         htlc_descriptor_conv.inner = untag_ptr(htlc_descriptor);
2192         htlc_descriptor_conv.is_owned = ptr_is_owned(htlc_descriptor);
2193         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptor_conv);
2194         htlc_descriptor_conv.is_owned = false;
2195         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2196         *ret_conv = (this_arg_conv->sign_holder_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_ref, input, &htlc_descriptor_conv);
2197         return tag_ptr(ret_conv, true);
2198 }
2199
2200 int64_t  CS_LDK_EcdsaChannelSigner_sign_counterparty_htlc_transaction(int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
2201         void* this_arg_ptr = untag_ptr(this_arg);
2202         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2203         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2204         LDKTransaction htlc_tx_ref;
2205         htlc_tx_ref.datalen = htlc_tx->arr_len;
2206         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2207         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
2208         htlc_tx_ref.data_is_owned = true;
2209         LDKPublicKey per_commitment_point_ref;
2210         CHECK(per_commitment_point->arr_len == 33);
2211         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
2212         LDKHTLCOutputInCommitment htlc_conv;
2213         htlc_conv.inner = untag_ptr(htlc);
2214         htlc_conv.is_owned = ptr_is_owned(htlc);
2215         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2216         htlc_conv.is_owned = false;
2217         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2218         *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);
2219         return tag_ptr(ret_conv, true);
2220 }
2221
2222 int64_t  CS_LDK_EcdsaChannelSigner_sign_closing_transaction(int64_t this_arg, int64_t closing_tx) {
2223         void* this_arg_ptr = untag_ptr(this_arg);
2224         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2225         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2226         LDKClosingTransaction closing_tx_conv;
2227         closing_tx_conv.inner = untag_ptr(closing_tx);
2228         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
2229         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
2230         closing_tx_conv.is_owned = false;
2231         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2232         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2233         return tag_ptr(ret_conv, true);
2234 }
2235
2236 int64_t  CS_LDK_EcdsaChannelSigner_sign_holder_anchor_input(int64_t this_arg, int8_tArray anchor_tx, int64_t input) {
2237         void* this_arg_ptr = untag_ptr(this_arg);
2238         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2239         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2240         LDKTransaction anchor_tx_ref;
2241         anchor_tx_ref.datalen = anchor_tx->arr_len;
2242         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
2243         memcpy(anchor_tx_ref.data, anchor_tx->elems, anchor_tx_ref.datalen); FREE(anchor_tx);
2244         anchor_tx_ref.data_is_owned = true;
2245         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2246         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
2247         return tag_ptr(ret_conv, true);
2248 }
2249
2250 int64_t  CS_LDK_EcdsaChannelSigner_sign_channel_announcement_with_funding_key(int64_t this_arg, int64_t msg) {
2251         void* this_arg_ptr = untag_ptr(this_arg);
2252         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2253         LDKEcdsaChannelSigner* this_arg_conv = (LDKEcdsaChannelSigner*)this_arg_ptr;
2254         LDKUnsignedChannelAnnouncement msg_conv;
2255         msg_conv.inner = untag_ptr(msg);
2256         msg_conv.is_owned = ptr_is_owned(msg);
2257         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
2258         msg_conv.is_owned = false;
2259         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
2260         *ret_conv = (this_arg_conv->sign_channel_announcement_with_funding_key)(this_arg_conv->this_arg, &msg_conv);
2261         return tag_ptr(ret_conv, true);
2262 }
2263
2264 typedef struct LDKWriteableEcdsaChannelSigner_JCalls {
2265         atomic_size_t refcnt;
2266         uint32_t instance_ptr;
2267         LDKEcdsaChannelSigner_JCalls* EcdsaChannelSigner;
2268         LDKChannelSigner_JCalls* ChannelSigner;
2269 } LDKWriteableEcdsaChannelSigner_JCalls;
2270 static void LDKWriteableEcdsaChannelSigner_JCalls_free(void* this_arg) {
2271         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
2272         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2273                 FREE(j_calls);
2274         }
2275 }
2276 LDKCVec_u8Z write_LDKWriteableEcdsaChannelSigner_jcall(const void* this_arg) {
2277         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) this_arg;
2278         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 15);
2279         LDKCVec_u8Z ret_ref;
2280         ret_ref.datalen = ret->arr_len;
2281         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2282         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
2283         return ret_ref;
2284 }
2285 static void LDKWriteableEcdsaChannelSigner_JCalls_cloned(LDKWriteableEcdsaChannelSigner* new_obj) {
2286         LDKWriteableEcdsaChannelSigner_JCalls *j_calls = (LDKWriteableEcdsaChannelSigner_JCalls*) new_obj->this_arg;
2287         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2288         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->refcnt, 1, memory_order_release);
2289         atomic_fetch_add_explicit(&j_calls->EcdsaChannelSigner->ChannelSigner->refcnt, 1, memory_order_release);
2290 }
2291 static inline LDKWriteableEcdsaChannelSigner LDKWriteableEcdsaChannelSigner_init (int64_t o, int64_t EcdsaChannelSigner, int64_t ChannelSigner, int64_t pubkeys) {
2292         LDKWriteableEcdsaChannelSigner_JCalls *calls = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner_JCalls), "LDKWriteableEcdsaChannelSigner_JCalls");
2293         atomic_init(&calls->refcnt, 1);
2294         calls->instance_ptr = o;
2295
2296         LDKChannelPublicKeys pubkeys_conv;
2297         pubkeys_conv.inner = untag_ptr(pubkeys);
2298         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
2299         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2300
2301         LDKWriteableEcdsaChannelSigner ret = {
2302                 .this_arg = (void*) calls,
2303                 .write = write_LDKWriteableEcdsaChannelSigner_jcall,
2304                 .cloned = LDKWriteableEcdsaChannelSigner_JCalls_cloned,
2305                 .free = LDKWriteableEcdsaChannelSigner_JCalls_free,
2306                 .EcdsaChannelSigner = LDKEcdsaChannelSigner_init(EcdsaChannelSigner, ChannelSigner, pubkeys),
2307         };
2308         calls->EcdsaChannelSigner = ret.EcdsaChannelSigner.this_arg;
2309         calls->ChannelSigner = ret.EcdsaChannelSigner.ChannelSigner.this_arg;
2310         return ret;
2311 }
2312 uint64_t  CS_LDK_LDKWriteableEcdsaChannelSigner_new(int32_t o, int32_t EcdsaChannelSigner, int32_t ChannelSigner, int64_t pubkeys) {
2313         LDKWriteableEcdsaChannelSigner *res_ptr = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
2314         *res_ptr = LDKWriteableEcdsaChannelSigner_init(o, EcdsaChannelSigner, ChannelSigner, pubkeys);
2315         return tag_ptr(res_ptr, true);
2316 }
2317 int8_tArray  CS_LDK_WriteableEcdsaChannelSigner_write(int64_t this_arg) {
2318         void* this_arg_ptr = untag_ptr(this_arg);
2319         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2320         LDKWriteableEcdsaChannelSigner* this_arg_conv = (LDKWriteableEcdsaChannelSigner*)this_arg_ptr;
2321         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2322         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2323         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2324         CVec_u8Z_free(ret_var);
2325         return ret_arr;
2326 }
2327
2328 static inline struct LDKWriteableEcdsaChannelSigner CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
2329 CHECK(owner->result_ok);
2330         return WriteableEcdsaChannelSigner_clone(&*owner->contents.result);
2331 }
2332 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(int64_t owner) {
2333         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
2334         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
2335         *ret_ret = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_ok(owner_conv);
2336         return tag_ptr(ret_ret, true);
2337 }
2338
2339 static inline struct LDKDecodeError CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR owner){
2340 CHECK(!owner->result_ok);
2341         return DecodeError_clone(&*owner->contents.err);
2342 }
2343 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(int64_t owner) {
2344         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* owner_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(owner);
2345         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2346         *ret_copy = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_get_err(owner_conv);
2347         int64_t ret_ref = tag_ptr(ret_copy, true);
2348         return ret_ref;
2349 }
2350
2351 static inline struct LDKCVec_u8Z CResult_CVec_u8ZNoneZ_get_ok(LDKCResult_CVec_u8ZNoneZ *NONNULL_PTR owner){
2352 CHECK(owner->result_ok);
2353         return CVec_u8Z_clone(&*owner->contents.result);
2354 }
2355 int8_tArray  CS_LDK_CResult_CVec_u8ZNoneZ_get_ok(int64_t owner) {
2356         LDKCResult_CVec_u8ZNoneZ* owner_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(owner);
2357         LDKCVec_u8Z ret_var = CResult_CVec_u8ZNoneZ_get_ok(owner_conv);
2358         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2359         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2360         CVec_u8Z_free(ret_var);
2361         return ret_arr;
2362 }
2363
2364 static inline void CResult_CVec_u8ZNoneZ_get_err(LDKCResult_CVec_u8ZNoneZ *NONNULL_PTR owner){
2365 CHECK(!owner->result_ok);
2366         return *owner->contents.err;
2367 }
2368 void  CS_LDK_CResult_CVec_u8ZNoneZ_get_err(int64_t owner) {
2369         LDKCResult_CVec_u8ZNoneZ* owner_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(owner);
2370         CResult_CVec_u8ZNoneZ_get_err(owner_conv);
2371 }
2372
2373 static inline struct LDKShutdownScript CResult_ShutdownScriptNoneZ_get_ok(LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR owner){
2374         LDKShutdownScript ret = *owner->contents.result;
2375         ret.is_owned = false;
2376         return ret;
2377 }
2378 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_get_ok(int64_t owner) {
2379         LDKCResult_ShutdownScriptNoneZ* owner_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(owner);
2380         LDKShutdownScript ret_var = CResult_ShutdownScriptNoneZ_get_ok(owner_conv);
2381         int64_t ret_ref = 0;
2382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2383         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2384         return ret_ref;
2385 }
2386
2387 static inline void CResult_ShutdownScriptNoneZ_get_err(LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR owner){
2388 CHECK(!owner->result_ok);
2389         return *owner->contents.err;
2390 }
2391 void  CS_LDK_CResult_ShutdownScriptNoneZ_get_err(int64_t owner) {
2392         LDKCResult_ShutdownScriptNoneZ* owner_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(owner);
2393         CResult_ShutdownScriptNoneZ_get_err(owner_conv);
2394 }
2395
2396 uint32_t CS_LDK_LDKCOption_u16Z_ty_from_ptr(int64_t ptr) {
2397         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
2398         switch(obj->tag) {
2399                 case LDKCOption_u16Z_Some: return 0;
2400                 case LDKCOption_u16Z_None: return 1;
2401                 default: abort();
2402         }
2403 }
2404 int16_t CS_LDK_LDKCOption_u16Z_Some_get_some(int64_t ptr) {
2405         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
2406         CHECK(obj->tag == LDKCOption_u16Z_Some);
2407         int16_t some_conv = obj->some;
2408         return some_conv;
2409 }
2410 uint32_t CS_LDK_LDKCOption_boolZ_ty_from_ptr(int64_t ptr) {
2411         LDKCOption_boolZ *obj = (LDKCOption_boolZ*)untag_ptr(ptr);
2412         switch(obj->tag) {
2413                 case LDKCOption_boolZ_Some: return 0;
2414                 case LDKCOption_boolZ_None: return 1;
2415                 default: abort();
2416         }
2417 }
2418 jboolean CS_LDK_LDKCOption_boolZ_Some_get_some(int64_t ptr) {
2419         LDKCOption_boolZ *obj = (LDKCOption_boolZ*)untag_ptr(ptr);
2420         CHECK(obj->tag == LDKCOption_boolZ_Some);
2421         jboolean some_conv = obj->some;
2422         return some_conv;
2423 }
2424 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2425         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2426         for (size_t i = 0; i < ret.datalen; i++) {
2427                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2428         }
2429         return ret;
2430 }
2431 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
2432 CHECK(owner->result_ok);
2433         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
2434 }
2435 ptrArray  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_get_ok(int64_t owner) {
2436         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
2437         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
2438         ptrArray ret_arr = NULL;
2439         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2440         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
2441         for (size_t i = 0; i < ret_var.datalen; i++) {
2442                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
2443                 int8_tArray ret_conv_8_arr = init_int8_tArray(ret_conv_8_var.datalen, __LINE__);
2444                 memcpy(ret_conv_8_arr->elems, ret_conv_8_var.data, ret_conv_8_var.datalen);
2445                 CVec_u8Z_free(ret_conv_8_var);
2446                 ret_arr_ptr[i] = ret_conv_8_arr;
2447         }
2448         
2449         FREE(ret_var.data);
2450         return ret_arr;
2451 }
2452
2453 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
2454 CHECK(!owner->result_ok);
2455         return *owner->contents.err;
2456 }
2457 void  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_get_err(int64_t owner) {
2458         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
2459         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
2460 }
2461
2462 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
2463         LDKInMemorySigner ret = *owner->contents.result;
2464         ret.is_owned = false;
2465         return ret;
2466 }
2467 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_get_ok(int64_t owner) {
2468         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
2469         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
2470         int64_t ret_ref = 0;
2471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2473         return ret_ref;
2474 }
2475
2476 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
2477 CHECK(!owner->result_ok);
2478         return DecodeError_clone(&*owner->contents.err);
2479 }
2480 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_get_err(int64_t owner) {
2481         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
2482         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2483         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
2484         int64_t ret_ref = tag_ptr(ret_copy, true);
2485         return ret_ref;
2486 }
2487
2488 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
2489 CHECK(owner->result_ok);
2490         return *owner->contents.result;
2491 }
2492 int8_tArray  CS_LDK_CResult_TransactionNoneZ_get_ok(int64_t owner) {
2493         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
2494         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
2495         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2496         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2497         return ret_arr;
2498 }
2499
2500 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
2501 CHECK(!owner->result_ok);
2502         return *owner->contents.err;
2503 }
2504 void  CS_LDK_CResult_TransactionNoneZ_get_err(int64_t owner) {
2505         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
2506         CResult_TransactionNoneZ_get_err(owner_conv);
2507 }
2508
2509 typedef struct LDKScoreLookUp_JCalls {
2510         atomic_size_t refcnt;
2511         uint32_t instance_ptr;
2512 } LDKScoreLookUp_JCalls;
2513 static void LDKScoreLookUp_JCalls_free(void* this_arg) {
2514         LDKScoreLookUp_JCalls *j_calls = (LDKScoreLookUp_JCalls*) this_arg;
2515         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2516                 FREE(j_calls);
2517         }
2518 }
2519 uint64_t channel_penalty_msat_LDKScoreLookUp_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage, const LDKProbabilisticScoringFeeParameters * score_params) {
2520         LDKScoreLookUp_JCalls *j_calls = (LDKScoreLookUp_JCalls*) this_arg;
2521         int64_t short_channel_id_conv = short_channel_id;
2522         LDKNodeId source_var = *source;
2523         int64_t source_ref = 0;
2524         source_var = NodeId_clone(&source_var);
2525         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
2526         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
2527         LDKNodeId target_var = *target;
2528         int64_t target_ref = 0;
2529         target_var = NodeId_clone(&target_var);
2530         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
2531         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
2532         LDKChannelUsage usage_var = usage;
2533         int64_t usage_ref = 0;
2534         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
2535         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
2536         LDKProbabilisticScoringFeeParameters score_params_var = *score_params;
2537         int64_t score_params_ref = 0;
2538         score_params_var = ProbabilisticScoringFeeParameters_clone(&score_params_var);
2539         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_var);
2540         score_params_ref = tag_ptr(score_params_var.inner, score_params_var.is_owned);
2541         return js_invoke_function_l_lllll(j_calls->instance_ptr, 16, short_channel_id_conv, source_ref, target_ref, usage_ref, score_params_ref);
2542 }
2543 static void LDKScoreLookUp_JCalls_cloned(LDKScoreLookUp* new_obj) {
2544         LDKScoreLookUp_JCalls *j_calls = (LDKScoreLookUp_JCalls*) new_obj->this_arg;
2545         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2546 }
2547 static inline LDKScoreLookUp LDKScoreLookUp_init (int64_t o) {
2548         LDKScoreLookUp_JCalls *calls = MALLOC(sizeof(LDKScoreLookUp_JCalls), "LDKScoreLookUp_JCalls");
2549         atomic_init(&calls->refcnt, 1);
2550         calls->instance_ptr = o;
2551
2552         LDKScoreLookUp ret = {
2553                 .this_arg = (void*) calls,
2554                 .channel_penalty_msat = channel_penalty_msat_LDKScoreLookUp_jcall,
2555                 .free = LDKScoreLookUp_JCalls_free,
2556         };
2557         return ret;
2558 }
2559 uint64_t  CS_LDK_LDKScoreLookUp_new(int32_t o) {
2560         LDKScoreLookUp *res_ptr = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
2561         *res_ptr = LDKScoreLookUp_init(o);
2562         return tag_ptr(res_ptr, true);
2563 }
2564 int64_t  CS_LDK_ScoreLookUp_channel_penalty_msat(int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target, int64_t usage, int64_t score_params) {
2565         void* this_arg_ptr = untag_ptr(this_arg);
2566         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2567         LDKScoreLookUp* this_arg_conv = (LDKScoreLookUp*)this_arg_ptr;
2568         LDKNodeId source_conv;
2569         source_conv.inner = untag_ptr(source);
2570         source_conv.is_owned = ptr_is_owned(source);
2571         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
2572         source_conv.is_owned = false;
2573         LDKNodeId target_conv;
2574         target_conv.inner = untag_ptr(target);
2575         target_conv.is_owned = ptr_is_owned(target);
2576         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
2577         target_conv.is_owned = false;
2578         LDKChannelUsage usage_conv;
2579         usage_conv.inner = untag_ptr(usage);
2580         usage_conv.is_owned = ptr_is_owned(usage);
2581         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
2582         usage_conv = ChannelUsage_clone(&usage_conv);
2583         LDKProbabilisticScoringFeeParameters score_params_conv;
2584         score_params_conv.inner = untag_ptr(score_params);
2585         score_params_conv.is_owned = ptr_is_owned(score_params);
2586         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_conv);
2587         score_params_conv.is_owned = false;
2588         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv, &score_params_conv);
2589         return ret_conv;
2590 }
2591
2592 typedef struct LDKScoreUpdate_JCalls {
2593         atomic_size_t refcnt;
2594         uint32_t instance_ptr;
2595 } LDKScoreUpdate_JCalls;
2596 static void LDKScoreUpdate_JCalls_free(void* this_arg) {
2597         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2598         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2599                 FREE(j_calls);
2600         }
2601 }
2602 void payment_path_failed_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2603         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2604         LDKPath path_var = *path;
2605         int64_t path_ref = 0;
2606         path_var = Path_clone(&path_var);
2607         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2608         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2609         int64_t short_channel_id_conv = short_channel_id;
2610         js_invoke_function_void_ll(j_calls->instance_ptr, 17, path_ref, short_channel_id_conv);
2611 }
2612 void payment_path_successful_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path) {
2613         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2614         LDKPath path_var = *path;
2615         int64_t path_ref = 0;
2616         path_var = Path_clone(&path_var);
2617         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2618         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2619         js_invoke_function_void_l(j_calls->instance_ptr, 18, path_ref);
2620 }
2621 void probe_failed_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path, uint64_t short_channel_id) {
2622         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2623         LDKPath path_var = *path;
2624         int64_t path_ref = 0;
2625         path_var = Path_clone(&path_var);
2626         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2627         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2628         int64_t short_channel_id_conv = short_channel_id;
2629         js_invoke_function_void_ll(j_calls->instance_ptr, 19, path_ref, short_channel_id_conv);
2630 }
2631 void probe_successful_LDKScoreUpdate_jcall(void* this_arg, const LDKPath * path) {
2632         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) this_arg;
2633         LDKPath path_var = *path;
2634         int64_t path_ref = 0;
2635         path_var = Path_clone(&path_var);
2636         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
2637         path_ref = tag_ptr(path_var.inner, path_var.is_owned);
2638         js_invoke_function_void_l(j_calls->instance_ptr, 20, path_ref);
2639 }
2640 static void LDKScoreUpdate_JCalls_cloned(LDKScoreUpdate* new_obj) {
2641         LDKScoreUpdate_JCalls *j_calls = (LDKScoreUpdate_JCalls*) new_obj->this_arg;
2642         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2643 }
2644 static inline LDKScoreUpdate LDKScoreUpdate_init (int64_t o) {
2645         LDKScoreUpdate_JCalls *calls = MALLOC(sizeof(LDKScoreUpdate_JCalls), "LDKScoreUpdate_JCalls");
2646         atomic_init(&calls->refcnt, 1);
2647         calls->instance_ptr = o;
2648
2649         LDKScoreUpdate ret = {
2650                 .this_arg = (void*) calls,
2651                 .payment_path_failed = payment_path_failed_LDKScoreUpdate_jcall,
2652                 .payment_path_successful = payment_path_successful_LDKScoreUpdate_jcall,
2653                 .probe_failed = probe_failed_LDKScoreUpdate_jcall,
2654                 .probe_successful = probe_successful_LDKScoreUpdate_jcall,
2655                 .free = LDKScoreUpdate_JCalls_free,
2656         };
2657         return ret;
2658 }
2659 uint64_t  CS_LDK_LDKScoreUpdate_new(int32_t o) {
2660         LDKScoreUpdate *res_ptr = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
2661         *res_ptr = LDKScoreUpdate_init(o);
2662         return tag_ptr(res_ptr, true);
2663 }
2664 void  CS_LDK_ScoreUpdate_payment_path_failed(int64_t this_arg, int64_t path, int64_t short_channel_id) {
2665         void* this_arg_ptr = untag_ptr(this_arg);
2666         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2667         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2668         LDKPath path_conv;
2669         path_conv.inner = untag_ptr(path);
2670         path_conv.is_owned = ptr_is_owned(path);
2671         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2672         path_conv.is_owned = false;
2673         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2674 }
2675
2676 void  CS_LDK_ScoreUpdate_payment_path_successful(int64_t this_arg, int64_t path) {
2677         void* this_arg_ptr = untag_ptr(this_arg);
2678         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2679         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2680         LDKPath path_conv;
2681         path_conv.inner = untag_ptr(path);
2682         path_conv.is_owned = ptr_is_owned(path);
2683         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2684         path_conv.is_owned = false;
2685         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, &path_conv);
2686 }
2687
2688 void  CS_LDK_ScoreUpdate_probe_failed(int64_t this_arg, int64_t path, int64_t short_channel_id) {
2689         void* this_arg_ptr = untag_ptr(this_arg);
2690         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2691         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2692         LDKPath path_conv;
2693         path_conv.inner = untag_ptr(path);
2694         path_conv.is_owned = ptr_is_owned(path);
2695         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2696         path_conv.is_owned = false;
2697         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, &path_conv, short_channel_id);
2698 }
2699
2700 void  CS_LDK_ScoreUpdate_probe_successful(int64_t this_arg, int64_t path) {
2701         void* this_arg_ptr = untag_ptr(this_arg);
2702         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2703         LDKScoreUpdate* this_arg_conv = (LDKScoreUpdate*)this_arg_ptr;
2704         LDKPath path_conv;
2705         path_conv.inner = untag_ptr(path);
2706         path_conv.is_owned = ptr_is_owned(path);
2707         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
2708         path_conv.is_owned = false;
2709         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, &path_conv);
2710 }
2711
2712 typedef struct LDKLockableScore_JCalls {
2713         atomic_size_t refcnt;
2714         uint32_t instance_ptr;
2715 } LDKLockableScore_JCalls;
2716 static void LDKLockableScore_JCalls_free(void* this_arg) {
2717         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2718         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2719                 FREE(j_calls);
2720         }
2721 }
2722 LDKScoreLookUp read_lock_LDKLockableScore_jcall(const void* this_arg) {
2723         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2724         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 21);
2725         void* ret_ptr = untag_ptr(ret);
2726         CHECK_ACCESS(ret_ptr);
2727         LDKScoreLookUp ret_conv = *(LDKScoreLookUp*)(ret_ptr);
2728         if (ret_conv.free == LDKScoreLookUp_JCalls_free) {
2729                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2730                 LDKScoreLookUp_JCalls_cloned(&ret_conv);
2731         }// WARNING: we may need a move here but no clone is available for LDKScoreLookUp
2732         
2733         return ret_conv;
2734 }
2735 LDKScoreUpdate write_lock_LDKLockableScore_jcall(const void* this_arg) {
2736         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2737         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 22);
2738         void* ret_ptr = untag_ptr(ret);
2739         CHECK_ACCESS(ret_ptr);
2740         LDKScoreUpdate ret_conv = *(LDKScoreUpdate*)(ret_ptr);
2741         if (ret_conv.free == LDKScoreUpdate_JCalls_free) {
2742                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2743                 LDKScoreUpdate_JCalls_cloned(&ret_conv);
2744         }// WARNING: we may need a move here but no clone is available for LDKScoreUpdate
2745         
2746         return ret_conv;
2747 }
2748 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2749         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2750         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2751 }
2752 static inline LDKLockableScore LDKLockableScore_init (int64_t o) {
2753         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2754         atomic_init(&calls->refcnt, 1);
2755         calls->instance_ptr = o;
2756
2757         LDKLockableScore ret = {
2758                 .this_arg = (void*) calls,
2759                 .read_lock = read_lock_LDKLockableScore_jcall,
2760                 .write_lock = write_lock_LDKLockableScore_jcall,
2761                 .free = LDKLockableScore_JCalls_free,
2762         };
2763         return ret;
2764 }
2765 uint64_t  CS_LDK_LDKLockableScore_new(int32_t o) {
2766         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2767         *res_ptr = LDKLockableScore_init(o);
2768         return tag_ptr(res_ptr, true);
2769 }
2770 int64_t  CS_LDK_LockableScore_read_lock(int64_t this_arg) {
2771         void* this_arg_ptr = untag_ptr(this_arg);
2772         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2773         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2774         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
2775         *ret_ret = (this_arg_conv->read_lock)(this_arg_conv->this_arg);
2776         return tag_ptr(ret_ret, true);
2777 }
2778
2779 int64_t  CS_LDK_LockableScore_write_lock(int64_t this_arg) {
2780         void* this_arg_ptr = untag_ptr(this_arg);
2781         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2782         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2783         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
2784         *ret_ret = (this_arg_conv->write_lock)(this_arg_conv->this_arg);
2785         return tag_ptr(ret_ret, true);
2786 }
2787
2788 typedef struct LDKWriteableScore_JCalls {
2789         atomic_size_t refcnt;
2790         uint32_t instance_ptr;
2791         LDKLockableScore_JCalls* LockableScore;
2792 } LDKWriteableScore_JCalls;
2793 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2794         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2795         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2796                 FREE(j_calls);
2797         }
2798 }
2799 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2800         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2801         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 23);
2802         LDKCVec_u8Z ret_ref;
2803         ret_ref.datalen = ret->arr_len;
2804         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2805         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
2806         return ret_ref;
2807 }
2808 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2809         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2810         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2811         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2812 }
2813 static inline LDKWriteableScore LDKWriteableScore_init (int64_t o, int64_t LockableScore) {
2814         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2815         atomic_init(&calls->refcnt, 1);
2816         calls->instance_ptr = o;
2817
2818         LDKWriteableScore ret = {
2819                 .this_arg = (void*) calls,
2820                 .write = write_LDKWriteableScore_jcall,
2821                 .free = LDKWriteableScore_JCalls_free,
2822                 .LockableScore = LDKLockableScore_init(LockableScore),
2823         };
2824         calls->LockableScore = ret.LockableScore.this_arg;
2825         return ret;
2826 }
2827 uint64_t  CS_LDK_LDKWriteableScore_new(int32_t o, int32_t LockableScore) {
2828         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2829         *res_ptr = LDKWriteableScore_init(o, LockableScore);
2830         return tag_ptr(res_ptr, true);
2831 }
2832 int8_tArray  CS_LDK_WriteableScore_write(int64_t this_arg) {
2833         void* this_arg_ptr = untag_ptr(this_arg);
2834         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2835         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2836         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2837         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2838         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2839         CVec_u8Z_free(ret_var);
2840         return ret_arr;
2841 }
2842
2843 uint32_t CS_LDK_LDKCOption_WriteableScoreZ_ty_from_ptr(int64_t ptr) {
2844         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2845         switch(obj->tag) {
2846                 case LDKCOption_WriteableScoreZ_Some: return 0;
2847                 case LDKCOption_WriteableScoreZ_None: return 1;
2848                 default: abort();
2849         }
2850 }
2851 int64_t CS_LDK_LDKCOption_WriteableScoreZ_Some_get_some(int64_t ptr) {
2852         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2853         CHECK(obj->tag == LDKCOption_WriteableScoreZ_Some);
2854         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2855         *some_ret = obj->some;
2856                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2857                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2858                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2859                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2860                         }
2861         return tag_ptr(some_ret, true);
2862 }
2863 static inline void CResult_NoneIOErrorZ_get_ok(LDKCResult_NoneIOErrorZ *NONNULL_PTR owner){
2864 CHECK(owner->result_ok);
2865         return *owner->contents.result;
2866 }
2867 void  CS_LDK_CResult_NoneIOErrorZ_get_ok(int64_t owner) {
2868         LDKCResult_NoneIOErrorZ* owner_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(owner);
2869         CResult_NoneIOErrorZ_get_ok(owner_conv);
2870 }
2871
2872 static inline enum LDKIOError CResult_NoneIOErrorZ_get_err(LDKCResult_NoneIOErrorZ *NONNULL_PTR owner){
2873 CHECK(!owner->result_ok);
2874         return *owner->contents.err;
2875 }
2876 int32_t  CS_LDK_CResult_NoneIOErrorZ_get_err(int64_t owner) {
2877         LDKCResult_NoneIOErrorZ* owner_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(owner);
2878         int32_t ret_conv = LDKIOError_to_cs(CResult_NoneIOErrorZ_get_err(owner_conv));
2879         return ret_conv;
2880 }
2881
2882 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2883         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2884         for (size_t i = 0; i < ret.datalen; i++) {
2885                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2886         }
2887         return ret;
2888 }
2889 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2890         LDKRoute ret = *owner->contents.result;
2891         ret.is_owned = false;
2892         return ret;
2893 }
2894 int64_t  CS_LDK_CResult_RouteLightningErrorZ_get_ok(int64_t owner) {
2895         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2896         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2897         int64_t ret_ref = 0;
2898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2899         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2900         return ret_ref;
2901 }
2902
2903 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2904         LDKLightningError ret = *owner->contents.err;
2905         ret.is_owned = false;
2906         return ret;
2907 }
2908 int64_t  CS_LDK_CResult_RouteLightningErrorZ_get_err(int64_t owner) {
2909         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2910         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2911         int64_t ret_ref = 0;
2912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2914         return ret_ref;
2915 }
2916
2917 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2918         LDKInFlightHtlcs ret = *owner->contents.result;
2919         ret.is_owned = false;
2920         return ret;
2921 }
2922 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_get_ok(int64_t owner) {
2923         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2924         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
2925         int64_t ret_ref = 0;
2926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2927         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2928         return ret_ref;
2929 }
2930
2931 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2932 CHECK(!owner->result_ok);
2933         return DecodeError_clone(&*owner->contents.err);
2934 }
2935 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_get_err(int64_t owner) {
2936         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2937         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2938         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
2939         int64_t ret_ref = tag_ptr(ret_copy, true);
2940         return ret_ref;
2941 }
2942
2943 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2944         LDKRouteHop ret = *owner->contents.result;
2945         ret.is_owned = false;
2946         return ret;
2947 }
2948 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_get_ok(int64_t owner) {
2949         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2950         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2951         int64_t ret_ref = 0;
2952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2953         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2954         return ret_ref;
2955 }
2956
2957 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2958 CHECK(!owner->result_ok);
2959         return DecodeError_clone(&*owner->contents.err);
2960 }
2961 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_get_err(int64_t owner) {
2962         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2963         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2964         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2965         int64_t ret_ref = tag_ptr(ret_copy, true);
2966         return ret_ref;
2967 }
2968
2969 static inline LDKCVec_BlindedHopZ CVec_BlindedHopZ_clone(const LDKCVec_BlindedHopZ *orig) {
2970         LDKCVec_BlindedHopZ ret = { .data = MALLOC(sizeof(LDKBlindedHop) * orig->datalen, "LDKCVec_BlindedHopZ clone bytes"), .datalen = orig->datalen };
2971         for (size_t i = 0; i < ret.datalen; i++) {
2972                 ret.data[i] = BlindedHop_clone(&orig->data[i]);
2973         }
2974         return ret;
2975 }
2976 static inline struct LDKBlindedTail CResult_BlindedTailDecodeErrorZ_get_ok(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2977         LDKBlindedTail ret = *owner->contents.result;
2978         ret.is_owned = false;
2979         return ret;
2980 }
2981 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_get_ok(int64_t owner) {
2982         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
2983         LDKBlindedTail ret_var = CResult_BlindedTailDecodeErrorZ_get_ok(owner_conv);
2984         int64_t ret_ref = 0;
2985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2987         return ret_ref;
2988 }
2989
2990 static inline struct LDKDecodeError CResult_BlindedTailDecodeErrorZ_get_err(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR owner){
2991 CHECK(!owner->result_ok);
2992         return DecodeError_clone(&*owner->contents.err);
2993 }
2994 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_get_err(int64_t owner) {
2995         LDKCResult_BlindedTailDecodeErrorZ* owner_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(owner);
2996         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2997         *ret_copy = CResult_BlindedTailDecodeErrorZ_get_err(owner_conv);
2998         int64_t ret_ref = tag_ptr(ret_copy, true);
2999         return ret_ref;
3000 }
3001
3002 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
3003         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
3004         for (size_t i = 0; i < ret.datalen; i++) {
3005                 ret.data[i] = RouteHop_clone(&orig->data[i]);
3006         }
3007         return ret;
3008 }
3009 static inline LDKCVec_PathZ CVec_PathZ_clone(const LDKCVec_PathZ *orig) {
3010         LDKCVec_PathZ ret = { .data = MALLOC(sizeof(LDKPath) * orig->datalen, "LDKCVec_PathZ clone bytes"), .datalen = orig->datalen };
3011         for (size_t i = 0; i < ret.datalen; i++) {
3012                 ret.data[i] = Path_clone(&orig->data[i]);
3013         }
3014         return ret;
3015 }
3016 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
3017         LDKRoute ret = *owner->contents.result;
3018         ret.is_owned = false;
3019         return ret;
3020 }
3021 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_get_ok(int64_t owner) {
3022         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
3023         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
3024         int64_t ret_ref = 0;
3025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3027         return ret_ref;
3028 }
3029
3030 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
3031 CHECK(!owner->result_ok);
3032         return DecodeError_clone(&*owner->contents.err);
3033 }
3034 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_get_err(int64_t owner) {
3035         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
3036         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3037         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
3038         int64_t ret_ref = tag_ptr(ret_copy, true);
3039         return ret_ref;
3040 }
3041
3042 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
3043         LDKRouteParameters ret = *owner->contents.result;
3044         ret.is_owned = false;
3045         return ret;
3046 }
3047 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_get_ok(int64_t owner) {
3048         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
3049         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
3050         int64_t ret_ref = 0;
3051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3053         return ret_ref;
3054 }
3055
3056 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
3057 CHECK(!owner->result_ok);
3058         return DecodeError_clone(&*owner->contents.err);
3059 }
3060 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_get_err(int64_t owner) {
3061         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
3062         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3063         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
3064         int64_t ret_ref = tag_ptr(ret_copy, true);
3065         return ret_ref;
3066 }
3067
3068 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3069         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3070         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3071         return ret;
3072 }
3073 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
3074         LDKPaymentParameters ret = *owner->contents.result;
3075         ret.is_owned = false;
3076         return ret;
3077 }
3078 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_get_ok(int64_t owner) {
3079         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
3080         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
3081         int64_t ret_ref = 0;
3082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3084         return ret_ref;
3085 }
3086
3087 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
3088 CHECK(!owner->result_ok);
3089         return DecodeError_clone(&*owner->contents.err);
3090 }
3091 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_get_err(int64_t owner) {
3092         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
3093         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3094         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
3095         int64_t ret_ref = tag_ptr(ret_copy, true);
3096         return ret_ref;
3097 }
3098
3099 static inline struct LDKBlindedPayInfo C2Tuple_BlindedPayInfoBlindedPathZ_get_a(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
3100         LDKBlindedPayInfo ret = owner->a;
3101         ret.is_owned = false;
3102         return ret;
3103 }
3104 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_get_a(int64_t owner) {
3105         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
3106         LDKBlindedPayInfo ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_a(owner_conv);
3107         int64_t ret_ref = 0;
3108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3110         return ret_ref;
3111 }
3112
3113 static inline struct LDKBlindedPath C2Tuple_BlindedPayInfoBlindedPathZ_get_b(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR owner){
3114         LDKBlindedPath ret = owner->b;
3115         ret.is_owned = false;
3116         return ret;
3117 }
3118 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_get_b(int64_t owner) {
3119         LDKC2Tuple_BlindedPayInfoBlindedPathZ* owner_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(owner);
3120         LDKBlindedPath ret_var = C2Tuple_BlindedPayInfoBlindedPathZ_get_b(owner_conv);
3121         int64_t ret_ref = 0;
3122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3124         return ret_ref;
3125 }
3126
3127 static inline LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_clone(const LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ *orig) {
3128         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ) * orig->datalen, "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ clone bytes"), .datalen = orig->datalen };
3129         for (size_t i = 0; i < ret.datalen; i++) {
3130                 ret.data[i] = C2Tuple_BlindedPayInfoBlindedPathZ_clone(&orig->data[i]);
3131         }
3132         return ret;
3133 }
3134 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
3135         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
3136         for (size_t i = 0; i < ret.datalen; i++) {
3137                 ret.data[i] = RouteHint_clone(&orig->data[i]);
3138         }
3139         return ret;
3140 }
3141 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
3142         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
3143         for (size_t i = 0; i < ret.datalen; i++) {
3144                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
3145         }
3146         return ret;
3147 }
3148 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
3149         LDKRouteHint ret = *owner->contents.result;
3150         ret.is_owned = false;
3151         return ret;
3152 }
3153 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_get_ok(int64_t owner) {
3154         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
3155         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
3156         int64_t ret_ref = 0;
3157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3158         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3159         return ret_ref;
3160 }
3161
3162 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
3163 CHECK(!owner->result_ok);
3164         return DecodeError_clone(&*owner->contents.err);
3165 }
3166 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_get_err(int64_t owner) {
3167         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
3168         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3169         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
3170         int64_t ret_ref = tag_ptr(ret_copy, true);
3171         return ret_ref;
3172 }
3173
3174 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
3175         LDKRouteHintHop ret = *owner->contents.result;
3176         ret.is_owned = false;
3177         return ret;
3178 }
3179 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_get_ok(int64_t owner) {
3180         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
3181         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
3182         int64_t ret_ref = 0;
3183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3185         return ret_ref;
3186 }
3187
3188 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
3189 CHECK(!owner->result_ok);
3190         return DecodeError_clone(&*owner->contents.err);
3191 }
3192 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_get_err(int64_t owner) {
3193         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
3194         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3195         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
3196         int64_t ret_ref = tag_ptr(ret_copy, true);
3197         return ret_ref;
3198 }
3199
3200 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3201         LDKFixedPenaltyScorer ret = *owner->contents.result;
3202         ret.is_owned = false;
3203         return ret;
3204 }
3205 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(int64_t owner) {
3206         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3207         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3208         int64_t ret_ref = 0;
3209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3211         return ret_ref;
3212 }
3213
3214 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3215 CHECK(!owner->result_ok);
3216         return DecodeError_clone(&*owner->contents.err);
3217 }
3218 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(int64_t owner) {
3219         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3220         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3221         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3222         int64_t ret_ref = tag_ptr(ret_copy, true);
3223         return ret_ref;
3224 }
3225
3226 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
3227         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
3228         for (size_t i = 0; i < ret.datalen; i++) {
3229                 ret.data[i] = NodeId_clone(&orig->data[i]);
3230         }
3231         return ret;
3232 }
3233 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3234         return owner->a;
3235 }
3236 int64_t  CS_LDK_C2Tuple_u64u64Z_get_a(int64_t owner) {
3237         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3238         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3239         return ret_conv;
3240 }
3241
3242 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3243         return owner->b;
3244 }
3245 int64_t  CS_LDK_C2Tuple_u64u64Z_get_b(int64_t owner) {
3246         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3247         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3248         return ret_conv;
3249 }
3250
3251 uint32_t CS_LDK_LDKCOption_C2Tuple_u64u64ZZ_ty_from_ptr(int64_t ptr) {
3252         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
3253         switch(obj->tag) {
3254                 case LDKCOption_C2Tuple_u64u64ZZ_Some: return 0;
3255                 case LDKCOption_C2Tuple_u64u64ZZ_None: return 1;
3256                 default: abort();
3257         }
3258 }
3259 int64_t CS_LDK_LDKCOption_C2Tuple_u64u64ZZ_Some_get_some(int64_t ptr) {
3260         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
3261         CHECK(obj->tag == LDKCOption_C2Tuple_u64u64ZZ_Some);
3262         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3263         *some_conv = obj->some;
3264                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
3265         return tag_ptr(some_conv, true);
3266 }
3267 static inline struct LDKThirtyTwoU16s C2Tuple_Z_get_a(LDKC2Tuple_Z *NONNULL_PTR owner){
3268         return owner->a;
3269 }
3270 int16_tArray  CS_LDK_C2Tuple_Z_get_a(int64_t owner) {
3271         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3272         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3273         memcpy(ret_arr->elems, C2Tuple_Z_get_a(owner_conv).data, 32 * 2);
3274         return ret_arr;
3275 }
3276
3277 static inline struct LDKThirtyTwoU16s C2Tuple_Z_get_b(LDKC2Tuple_Z *NONNULL_PTR owner){
3278         return owner->b;
3279 }
3280 int16_tArray  CS_LDK_C2Tuple_Z_get_b(int64_t owner) {
3281         LDKC2Tuple_Z* owner_conv = (LDKC2Tuple_Z*)untag_ptr(owner);
3282         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3283         memcpy(ret_arr->elems, C2Tuple_Z_get_b(owner_conv).data, 32 * 2);
3284         return ret_arr;
3285 }
3286
3287 static inline struct LDKThirtyTwoU16s C2Tuple__u1632_u1632Z_get_a(LDKC2Tuple__u1632_u1632Z *NONNULL_PTR owner){
3288         return owner->a;
3289 }
3290 int16_tArray  CS_LDK_C2Tuple__u1632_u1632Z_get_a(int64_t owner) {
3291         LDKC2Tuple__u1632_u1632Z* owner_conv = (LDKC2Tuple__u1632_u1632Z*)untag_ptr(owner);
3292         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3293         memcpy(ret_arr->elems, C2Tuple__u1632_u1632Z_get_a(owner_conv).data, 32 * 2);
3294         return ret_arr;
3295 }
3296
3297 static inline struct LDKThirtyTwoU16s C2Tuple__u1632_u1632Z_get_b(LDKC2Tuple__u1632_u1632Z *NONNULL_PTR owner){
3298         return owner->b;
3299 }
3300 int16_tArray  CS_LDK_C2Tuple__u1632_u1632Z_get_b(int64_t owner) {
3301         LDKC2Tuple__u1632_u1632Z* owner_conv = (LDKC2Tuple__u1632_u1632Z*)untag_ptr(owner);
3302         int16_tArray ret_arr = init_int16_tArray(32, __LINE__);
3303         memcpy(ret_arr->elems, C2Tuple__u1632_u1632Z_get_b(owner_conv).data, 32 * 2);
3304         return ret_arr;
3305 }
3306
3307 uint32_t CS_LDK_LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_ty_from_ptr(int64_t ptr) {
3308         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *obj = (LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ*)untag_ptr(ptr);
3309         switch(obj->tag) {
3310                 case LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_Some: return 0;
3311                 case LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_None: return 1;
3312                 default: abort();
3313         }
3314 }
3315 int64_t CS_LDK_LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_Some_get_some(int64_t ptr) {
3316         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *obj = (LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ*)untag_ptr(ptr);
3317         CHECK(obj->tag == LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_Some);
3318         LDKC2Tuple__u1632_u1632Z* some_conv = &obj->some;
3319                         // WARNING: we really need to clone here, but no clone is available for LDKC2Tuple__u1632_u1632Z
3320         return tag_ptr(some_conv, false);
3321 }
3322 uint32_t CS_LDK_LDKCOption_f64Z_ty_from_ptr(int64_t ptr) {
3323         LDKCOption_f64Z *obj = (LDKCOption_f64Z*)untag_ptr(ptr);
3324         switch(obj->tag) {
3325                 case LDKCOption_f64Z_Some: return 0;
3326                 case LDKCOption_f64Z_None: return 1;
3327                 default: abort();
3328         }
3329 }
3330 double CS_LDK_LDKCOption_f64Z_Some_get_some(int64_t ptr) {
3331         LDKCOption_f64Z *obj = (LDKCOption_f64Z*)untag_ptr(ptr);
3332         CHECK(obj->tag == LDKCOption_f64Z_Some);
3333         double some_conv = obj->some;
3334         return some_conv;
3335 }
3336 typedef struct LDKLogger_JCalls {
3337         atomic_size_t refcnt;
3338         uint32_t instance_ptr;
3339 } LDKLogger_JCalls;
3340 static void LDKLogger_JCalls_free(void* this_arg) {
3341         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3342         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3343                 FREE(j_calls);
3344         }
3345 }
3346 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3347         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3348         LDKRecord record_var = *record;
3349         int64_t record_ref = 0;
3350         record_var = Record_clone(&record_var);
3351         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3352         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
3353         js_invoke_function_void_l(j_calls->instance_ptr, 24, record_ref);
3354 }
3355 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3356         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3357         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3358 }
3359 static inline LDKLogger LDKLogger_init (int64_t o) {
3360         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3361         atomic_init(&calls->refcnt, 1);
3362         calls->instance_ptr = o;
3363
3364         LDKLogger ret = {
3365                 .this_arg = (void*) calls,
3366                 .log = log_LDKLogger_jcall,
3367                 .free = LDKLogger_JCalls_free,
3368         };
3369         return ret;
3370 }
3371 uint64_t  CS_LDK_LDKLogger_new(int32_t o) {
3372         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3373         *res_ptr = LDKLogger_init(o);
3374         return tag_ptr(res_ptr, true);
3375 }
3376 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3377         LDKProbabilisticScorer ret = *owner->contents.result;
3378         ret.is_owned = false;
3379         return ret;
3380 }
3381 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(int64_t owner) {
3382         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3383         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
3384         int64_t ret_ref = 0;
3385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3387         return ret_ref;
3388 }
3389
3390 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
3391 CHECK(!owner->result_ok);
3392         return DecodeError_clone(&*owner->contents.err);
3393 }
3394 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_get_err(int64_t owner) {
3395         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
3396         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3397         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
3398         int64_t ret_ref = tag_ptr(ret_copy, true);
3399         return ret_ref;
3400 }
3401
3402 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3403         return owner->a;
3404 }
3405 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_get_a(int64_t owner) {
3406         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3407         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3408         return ret_conv;
3409 }
3410
3411 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3412         return owner->b;
3413 }
3414 int8_tArray  CS_LDK_C2Tuple_usizeTransactionZ_get_b(int64_t owner) {
3415         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3416         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3417         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3418         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3419         return ret_arr;
3420 }
3421
3422 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3423         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3424         for (size_t i = 0; i < ret.datalen; i++) {
3425                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3426         }
3427         return ret;
3428 }
3429 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_a(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ *NONNULL_PTR owner){
3430         return ThirtyTwoBytes_clone(&owner->a);
3431 }
3432 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_a(int64_t owner) {
3433         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(owner);
3434         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3435         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_a(owner_conv).data, 32);
3436         return ret_arr;
3437 }
3438
3439 static inline struct LDKCOption_ThirtyTwoBytesZ C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_b(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ *NONNULL_PTR owner){
3440         return COption_ThirtyTwoBytesZ_clone(&owner->b);
3441 }
3442 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_b(int64_t owner) {
3443         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(owner);
3444         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
3445         *ret_copy = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_get_b(owner_conv);
3446         int64_t ret_ref = tag_ptr(ret_copy, true);
3447         return ret_ref;
3448 }
3449
3450 static inline LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ *orig) {
3451         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ clone bytes"), .datalen = orig->datalen };
3452         for (size_t i = 0; i < ret.datalen; i++) {
3453                 ret.data[i] = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(&orig->data[i]);
3454         }
3455         return ret;
3456 }
3457 static inline enum LDKChannelMonitorUpdateStatus CResult_ChannelMonitorUpdateStatusNoneZ_get_ok(LDKCResult_ChannelMonitorUpdateStatusNoneZ *NONNULL_PTR owner){
3458 CHECK(owner->result_ok);
3459         return ChannelMonitorUpdateStatus_clone(&*owner->contents.result);
3460 }
3461 int32_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_get_ok(int64_t owner) {
3462         LDKCResult_ChannelMonitorUpdateStatusNoneZ* owner_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(owner);
3463         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(CResult_ChannelMonitorUpdateStatusNoneZ_get_ok(owner_conv));
3464         return ret_conv;
3465 }
3466
3467 static inline void CResult_ChannelMonitorUpdateStatusNoneZ_get_err(LDKCResult_ChannelMonitorUpdateStatusNoneZ *NONNULL_PTR owner){
3468 CHECK(!owner->result_ok);
3469         return *owner->contents.err;
3470 }
3471 void  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_get_err(int64_t owner) {
3472         LDKCResult_ChannelMonitorUpdateStatusNoneZ* owner_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(owner);
3473         CResult_ChannelMonitorUpdateStatusNoneZ_get_err(owner_conv);
3474 }
3475
3476 uint32_t CS_LDK_LDKMonitorEvent_ty_from_ptr(int64_t ptr) {
3477         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3478         switch(obj->tag) {
3479                 case LDKMonitorEvent_HTLCEvent: return 0;
3480                 case LDKMonitorEvent_HolderForceClosed: return 1;
3481                 case LDKMonitorEvent_Completed: return 2;
3482                 default: abort();
3483         }
3484 }
3485 int64_t CS_LDK_LDKMonitorEvent_HTLCEvent_get_htlc_event(int64_t ptr) {
3486         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3487         CHECK(obj->tag == LDKMonitorEvent_HTLCEvent);
3488         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3489                         int64_t htlc_event_ref = 0;
3490                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3491                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3492         return htlc_event_ref;
3493 }
3494 int64_t CS_LDK_LDKMonitorEvent_HolderForceClosed_get_holder_force_closed(int64_t ptr) {
3495         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3496         CHECK(obj->tag == LDKMonitorEvent_HolderForceClosed);
3497         LDKOutPoint holder_force_closed_var = obj->holder_force_closed;
3498                         int64_t holder_force_closed_ref = 0;
3499                         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_force_closed_var);
3500                         holder_force_closed_ref = tag_ptr(holder_force_closed_var.inner, false);
3501         return holder_force_closed_ref;
3502 }
3503 int64_t CS_LDK_LDKMonitorEvent_Completed_get_funding_txo(int64_t ptr) {
3504         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3505         CHECK(obj->tag == LDKMonitorEvent_Completed);
3506         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
3507                         int64_t funding_txo_ref = 0;
3508                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3509                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3510         return funding_txo_ref;
3511 }
3512 int64_t CS_LDK_LDKMonitorEvent_Completed_get_monitor_update_id(int64_t ptr) {
3513         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3514         CHECK(obj->tag == LDKMonitorEvent_Completed);
3515         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
3516         return monitor_update_id_conv;
3517 }
3518 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3519         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3520         for (size_t i = 0; i < ret.datalen; i++) {
3521                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3522         }
3523         return ret;
3524 }
3525 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3526         LDKOutPoint ret = owner->a;
3527         ret.is_owned = false;
3528         return ret;
3529 }
3530 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(int64_t owner) {
3531         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3532         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3533         int64_t ret_ref = 0;
3534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3536         return ret_ref;
3537 }
3538
3539 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3540         return CVec_MonitorEventZ_clone(&owner->b);
3541 }
3542 int64_tArray  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(int64_t owner) {
3543         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3544         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3545         int64_tArray ret_arr = NULL;
3546         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
3547         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
3548         for (size_t o = 0; o < ret_var.datalen; o++) {
3549                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3550                 *ret_conv_14_copy = ret_var.data[o];
3551                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
3552                 ret_arr_ptr[o] = ret_conv_14_ref;
3553         }
3554         
3555         FREE(ret_var.data);
3556         return ret_arr;
3557 }
3558
3559 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3560         return owner->c;
3561 }
3562 int8_tArray  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(int64_t owner) {
3563         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3564         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3565         memcpy(ret_arr->elems, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form, 33);
3566         return ret_arr;
3567 }
3568
3569 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3570         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3571         for (size_t i = 0; i < ret.datalen; i++) {
3572                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3573         }
3574         return ret;
3575 }
3576 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3577         LDKInitFeatures ret = *owner->contents.result;
3578         ret.is_owned = false;
3579         return ret;
3580 }
3581 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3582         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3583         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
3584         int64_t ret_ref = 0;
3585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3587         return ret_ref;
3588 }
3589
3590 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
3591 CHECK(!owner->result_ok);
3592         return DecodeError_clone(&*owner->contents.err);
3593 }
3594 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_get_err(int64_t owner) {
3595         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
3596         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3597         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
3598         int64_t ret_ref = tag_ptr(ret_copy, true);
3599         return ret_ref;
3600 }
3601
3602 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3603         LDKChannelFeatures ret = *owner->contents.result;
3604         ret.is_owned = false;
3605         return ret;
3606 }
3607 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3608         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3609         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
3610         int64_t ret_ref = 0;
3611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3612         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3613         return ret_ref;
3614 }
3615
3616 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
3617 CHECK(!owner->result_ok);
3618         return DecodeError_clone(&*owner->contents.err);
3619 }
3620 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_get_err(int64_t owner) {
3621         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
3622         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3623         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
3624         int64_t ret_ref = tag_ptr(ret_copy, true);
3625         return ret_ref;
3626 }
3627
3628 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3629         LDKNodeFeatures ret = *owner->contents.result;
3630         ret.is_owned = false;
3631         return ret;
3632 }
3633 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3634         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3635         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
3636         int64_t ret_ref = 0;
3637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3638         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3639         return ret_ref;
3640 }
3641
3642 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3643 CHECK(!owner->result_ok);
3644         return DecodeError_clone(&*owner->contents.err);
3645 }
3646 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_get_err(int64_t owner) {
3647         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
3648         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3649         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
3650         int64_t ret_ref = tag_ptr(ret_copy, true);
3651         return ret_ref;
3652 }
3653
3654 static inline struct LDKBolt11InvoiceFeatures CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3655         LDKBolt11InvoiceFeatures ret = *owner->contents.result;
3656         ret.is_owned = false;
3657         return ret;
3658 }
3659 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3660         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3661         LDKBolt11InvoiceFeatures ret_var = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3662         int64_t ret_ref = 0;
3663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3665         return ret_ref;
3666 }
3667
3668 static inline struct LDKDecodeError CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3669 CHECK(!owner->result_ok);
3670         return DecodeError_clone(&*owner->contents.err);
3671 }
3672 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_err(int64_t owner) {
3673         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3674         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3675         *ret_copy = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3676         int64_t ret_ref = tag_ptr(ret_copy, true);
3677         return ret_ref;
3678 }
3679
3680 static inline struct LDKBolt12InvoiceFeatures CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3681         LDKBolt12InvoiceFeatures ret = *owner->contents.result;
3682         ret.is_owned = false;
3683         return ret;
3684 }
3685 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3686         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3687         LDKBolt12InvoiceFeatures ret_var = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
3688         int64_t ret_ref = 0;
3689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3691         return ret_ref;
3692 }
3693
3694 static inline struct LDKDecodeError CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
3695 CHECK(!owner->result_ok);
3696         return DecodeError_clone(&*owner->contents.err);
3697 }
3698 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_err(int64_t owner) {
3699         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
3700         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3701         *ret_copy = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
3702         int64_t ret_ref = tag_ptr(ret_copy, true);
3703         return ret_ref;
3704 }
3705
3706 static inline struct LDKBlindedHopFeatures CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3707         LDKBlindedHopFeatures ret = *owner->contents.result;
3708         ret.is_owned = false;
3709         return ret;
3710 }
3711 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3712         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3713         LDKBlindedHopFeatures ret_var = CResult_BlindedHopFeaturesDecodeErrorZ_get_ok(owner_conv);
3714         int64_t ret_ref = 0;
3715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3717         return ret_ref;
3718 }
3719
3720 static inline struct LDKDecodeError CResult_BlindedHopFeaturesDecodeErrorZ_get_err(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR owner){
3721 CHECK(!owner->result_ok);
3722         return DecodeError_clone(&*owner->contents.err);
3723 }
3724 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_get_err(int64_t owner) {
3725         LDKCResult_BlindedHopFeaturesDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(owner);
3726         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3727         *ret_copy = CResult_BlindedHopFeaturesDecodeErrorZ_get_err(owner_conv);
3728         int64_t ret_ref = tag_ptr(ret_copy, true);
3729         return ret_ref;
3730 }
3731
3732 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3733         LDKChannelTypeFeatures ret = *owner->contents.result;
3734         ret.is_owned = false;
3735         return ret;
3736 }
3737 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(int64_t owner) {
3738         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3739         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
3740         int64_t ret_ref = 0;
3741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3742         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3743         return ret_ref;
3744 }
3745
3746 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
3747 CHECK(!owner->result_ok);
3748         return DecodeError_clone(&*owner->contents.err);
3749 }
3750 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(int64_t owner) {
3751         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
3752         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3753         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
3754         int64_t ret_ref = tag_ptr(ret_copy, true);
3755         return ret_ref;
3756 }
3757
3758 static inline struct LDKOffer CResult_OfferBolt12ParseErrorZ_get_ok(LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR owner){
3759         LDKOffer ret = *owner->contents.result;
3760         ret.is_owned = false;
3761         return ret;
3762 }
3763 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_get_ok(int64_t owner) {
3764         LDKCResult_OfferBolt12ParseErrorZ* owner_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(owner);
3765         LDKOffer ret_var = CResult_OfferBolt12ParseErrorZ_get_ok(owner_conv);
3766         int64_t ret_ref = 0;
3767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3768         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3769         return ret_ref;
3770 }
3771
3772 static inline struct LDKBolt12ParseError CResult_OfferBolt12ParseErrorZ_get_err(LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR owner){
3773         LDKBolt12ParseError ret = *owner->contents.err;
3774         ret.is_owned = false;
3775         return ret;
3776 }
3777 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_get_err(int64_t owner) {
3778         LDKCResult_OfferBolt12ParseErrorZ* owner_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(owner);
3779         LDKBolt12ParseError ret_var = CResult_OfferBolt12ParseErrorZ_get_err(owner_conv);
3780         int64_t ret_ref = 0;
3781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3783         return ret_ref;
3784 }
3785
3786 static inline struct LDKPublicKey CResult_PublicKeySecp256k1ErrorZ_get_ok(LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR owner){
3787 CHECK(owner->result_ok);
3788         return *owner->contents.result;
3789 }
3790 int8_tArray  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_get_ok(int64_t owner) {
3791         LDKCResult_PublicKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(owner);
3792         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3793         memcpy(ret_arr->elems, CResult_PublicKeySecp256k1ErrorZ_get_ok(owner_conv).compressed_form, 33);
3794         return ret_arr;
3795 }
3796
3797 static inline enum LDKSecp256k1Error CResult_PublicKeySecp256k1ErrorZ_get_err(LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR owner){
3798 CHECK(!owner->result_ok);
3799         return *owner->contents.err;
3800 }
3801 int32_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_get_err(int64_t owner) {
3802         LDKCResult_PublicKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(owner);
3803         int32_t ret_conv = LDKSecp256k1Error_to_cs(CResult_PublicKeySecp256k1ErrorZ_get_err(owner_conv));
3804         return ret_conv;
3805 }
3806
3807 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3808         LDKNodeId ret = *owner->contents.result;
3809         ret.is_owned = false;
3810         return ret;
3811 }
3812 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_get_ok(int64_t owner) {
3813         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
3814         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3815         int64_t ret_ref = 0;
3816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3817         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3818         return ret_ref;
3819 }
3820
3821 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3822 CHECK(!owner->result_ok);
3823         return DecodeError_clone(&*owner->contents.err);
3824 }
3825 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_get_err(int64_t owner) {
3826         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
3827         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3828         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3829         int64_t ret_ref = tag_ptr(ret_copy, true);
3830         return ret_ref;
3831 }
3832
3833 uint32_t CS_LDK_LDKNetworkUpdate_ty_from_ptr(int64_t ptr) {
3834         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3835         switch(obj->tag) {
3836                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
3837                 case LDKNetworkUpdate_ChannelFailure: return 1;
3838                 case LDKNetworkUpdate_NodeFailure: return 2;
3839                 default: abort();
3840         }
3841 }
3842 int64_t CS_LDK_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(int64_t ptr) {
3843         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3844         CHECK(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
3845         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
3846                         int64_t msg_ref = 0;
3847                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3848                         msg_ref = tag_ptr(msg_var.inner, false);
3849         return msg_ref;
3850 }
3851 int64_t CS_LDK_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(int64_t ptr) {
3852         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3853         CHECK(obj->tag == LDKNetworkUpdate_ChannelFailure);
3854         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
3855         return short_channel_id_conv;
3856 }
3857 jboolean CS_LDK_LDKNetworkUpdate_ChannelFailure_get_is_permanent(int64_t ptr) {
3858         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3859         CHECK(obj->tag == LDKNetworkUpdate_ChannelFailure);
3860         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
3861         return is_permanent_conv;
3862 }
3863 int8_tArray CS_LDK_LDKNetworkUpdate_NodeFailure_get_node_id(int64_t ptr) {
3864         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3865         CHECK(obj->tag == LDKNetworkUpdate_NodeFailure);
3866         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3867         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
3868         return node_id_arr;
3869 }
3870 jboolean CS_LDK_LDKNetworkUpdate_NodeFailure_get_is_permanent(int64_t ptr) {
3871         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
3872         CHECK(obj->tag == LDKNetworkUpdate_NodeFailure);
3873         jboolean is_permanent_conv = obj->node_failure.is_permanent;
3874         return is_permanent_conv;
3875 }
3876 uint32_t CS_LDK_LDKCOption_NetworkUpdateZ_ty_from_ptr(int64_t ptr) {
3877         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
3878         switch(obj->tag) {
3879                 case LDKCOption_NetworkUpdateZ_Some: return 0;
3880                 case LDKCOption_NetworkUpdateZ_None: return 1;
3881                 default: abort();
3882         }
3883 }
3884 int64_t CS_LDK_LDKCOption_NetworkUpdateZ_Some_get_some(int64_t ptr) {
3885         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
3886         CHECK(obj->tag == LDKCOption_NetworkUpdateZ_Some);
3887         int64_t some_ref = tag_ptr(&obj->some, false);
3888         return some_ref;
3889 }
3890 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3891 CHECK(owner->result_ok);
3892         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3893 }
3894 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(int64_t owner) {
3895         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
3896         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3897         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3898         int64_t ret_ref = tag_ptr(ret_copy, true);
3899         return ret_ref;
3900 }
3901
3902 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3903 CHECK(!owner->result_ok);
3904         return DecodeError_clone(&*owner->contents.err);
3905 }
3906 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(int64_t owner) {
3907         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
3908         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3909         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3910         int64_t ret_ref = tag_ptr(ret_copy, true);
3911         return ret_ref;
3912 }
3913
3914 static inline struct LDKTxOut CResult_TxOutUtxoLookupErrorZ_get_ok(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
3915 CHECK(owner->result_ok);
3916         return TxOut_clone(&*owner->contents.result);
3917 }
3918 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_get_ok(int64_t owner) {
3919         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
3920         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3921         *ret_ref = CResult_TxOutUtxoLookupErrorZ_get_ok(owner_conv);
3922         return tag_ptr(ret_ref, true);
3923 }
3924
3925 static inline enum LDKUtxoLookupError CResult_TxOutUtxoLookupErrorZ_get_err(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR owner){
3926 CHECK(!owner->result_ok);
3927         return UtxoLookupError_clone(&*owner->contents.err);
3928 }
3929 int32_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_get_err(int64_t owner) {
3930         LDKCResult_TxOutUtxoLookupErrorZ* owner_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(owner);
3931         int32_t ret_conv = LDKUtxoLookupError_to_cs(CResult_TxOutUtxoLookupErrorZ_get_err(owner_conv));
3932         return ret_conv;
3933 }
3934
3935 uint32_t CS_LDK_LDKUtxoResult_ty_from_ptr(int64_t ptr) {
3936         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
3937         switch(obj->tag) {
3938                 case LDKUtxoResult_Sync: return 0;
3939                 case LDKUtxoResult_Async: return 1;
3940                 default: abort();
3941         }
3942 }
3943 int64_t CS_LDK_LDKUtxoResult_Sync_get_sync(int64_t ptr) {
3944         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
3945         CHECK(obj->tag == LDKUtxoResult_Sync);
3946         LDKCResult_TxOutUtxoLookupErrorZ* sync_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
3947         *sync_conv = obj->sync;
3948                         *sync_conv = CResult_TxOutUtxoLookupErrorZ_clone(sync_conv);
3949         return tag_ptr(sync_conv, true);
3950 }
3951 int64_t CS_LDK_LDKUtxoResult_Async_get_async(int64_t ptr) {
3952         LDKUtxoResult *obj = (LDKUtxoResult*)untag_ptr(ptr);
3953         CHECK(obj->tag == LDKUtxoResult_Async);
3954         LDKUtxoFuture async_var = obj->async;
3955                         int64_t async_ref = 0;
3956                         CHECK_INNER_FIELD_ACCESS_OR_NULL(async_var);
3957                         async_ref = tag_ptr(async_var.inner, false);
3958         return async_ref;
3959 }
3960 typedef struct LDKUtxoLookup_JCalls {
3961         atomic_size_t refcnt;
3962         uint32_t instance_ptr;
3963 } LDKUtxoLookup_JCalls;
3964 static void LDKUtxoLookup_JCalls_free(void* this_arg) {
3965         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
3966         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3967                 FREE(j_calls);
3968         }
3969 }
3970 LDKUtxoResult get_utxo_LDKUtxoLookup_jcall(const void* this_arg, const uint8_t (* chain_hash)[32], uint64_t short_channel_id) {
3971         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) this_arg;
3972         int8_tArray chain_hash_arr = init_int8_tArray(32, __LINE__);
3973         memcpy(chain_hash_arr->elems, *chain_hash, 32);
3974         int64_t short_channel_id_conv = short_channel_id;
3975         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 25, (int64_t)chain_hash_arr, short_channel_id_conv);
3976         void* ret_ptr = untag_ptr(ret);
3977         CHECK_ACCESS(ret_ptr);
3978         LDKUtxoResult ret_conv = *(LDKUtxoResult*)(ret_ptr);
3979         FREE(untag_ptr(ret));
3980         return ret_conv;
3981 }
3982 static void LDKUtxoLookup_JCalls_cloned(LDKUtxoLookup* new_obj) {
3983         LDKUtxoLookup_JCalls *j_calls = (LDKUtxoLookup_JCalls*) new_obj->this_arg;
3984         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3985 }
3986 static inline LDKUtxoLookup LDKUtxoLookup_init (int64_t o) {
3987         LDKUtxoLookup_JCalls *calls = MALLOC(sizeof(LDKUtxoLookup_JCalls), "LDKUtxoLookup_JCalls");
3988         atomic_init(&calls->refcnt, 1);
3989         calls->instance_ptr = o;
3990
3991         LDKUtxoLookup ret = {
3992                 .this_arg = (void*) calls,
3993                 .get_utxo = get_utxo_LDKUtxoLookup_jcall,
3994                 .free = LDKUtxoLookup_JCalls_free,
3995         };
3996         return ret;
3997 }
3998 uint64_t  CS_LDK_LDKUtxoLookup_new(int32_t o) {
3999         LDKUtxoLookup *res_ptr = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
4000         *res_ptr = LDKUtxoLookup_init(o);
4001         return tag_ptr(res_ptr, true);
4002 }
4003 int64_t  CS_LDK_UtxoLookup_get_utxo(int64_t this_arg, int8_tArray chain_hash, int64_t short_channel_id) {
4004         void* this_arg_ptr = untag_ptr(this_arg);
4005         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4006         LDKUtxoLookup* this_arg_conv = (LDKUtxoLookup*)this_arg_ptr;
4007         uint8_t chain_hash_arr[32];
4008         CHECK(chain_hash->arr_len == 32);
4009         memcpy(chain_hash_arr, chain_hash->elems, 32); FREE(chain_hash);
4010         uint8_t (*chain_hash_ref)[32] = &chain_hash_arr;
4011         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
4012         *ret_copy = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, chain_hash_ref, short_channel_id);
4013         int64_t ret_ref = tag_ptr(ret_copy, true);
4014         return ret_ref;
4015 }
4016
4017 uint32_t CS_LDK_LDKCOption_UtxoLookupZ_ty_from_ptr(int64_t ptr) {
4018         LDKCOption_UtxoLookupZ *obj = (LDKCOption_UtxoLookupZ*)untag_ptr(ptr);
4019         switch(obj->tag) {
4020                 case LDKCOption_UtxoLookupZ_Some: return 0;
4021                 case LDKCOption_UtxoLookupZ_None: return 1;
4022                 default: abort();
4023         }
4024 }
4025 int64_t CS_LDK_LDKCOption_UtxoLookupZ_Some_get_some(int64_t ptr) {
4026         LDKCOption_UtxoLookupZ *obj = (LDKCOption_UtxoLookupZ*)untag_ptr(ptr);
4027         CHECK(obj->tag == LDKCOption_UtxoLookupZ_Some);
4028         LDKUtxoLookup* some_ret = MALLOC(sizeof(LDKUtxoLookup), "LDKUtxoLookup");
4029         *some_ret = obj->some;
4030                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4031                         if ((*some_ret).free == LDKUtxoLookup_JCalls_free) {
4032                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4033                                 LDKUtxoLookup_JCalls_cloned(&(*some_ret));
4034                         }
4035         return tag_ptr(some_ret, true);
4036 }
4037 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4038 CHECK(owner->result_ok);
4039         return *owner->contents.result;
4040 }
4041 void  CS_LDK_CResult_NoneLightningErrorZ_get_ok(int64_t owner) {
4042         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4043         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4044 }
4045
4046 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4047         LDKLightningError ret = *owner->contents.err;
4048         ret.is_owned = false;
4049         return ret;
4050 }
4051 int64_t  CS_LDK_CResult_NoneLightningErrorZ_get_err(int64_t owner) {
4052         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4053         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4054         int64_t ret_ref = 0;
4055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4057         return ret_ref;
4058 }
4059
4060 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4061 CHECK(owner->result_ok);
4062         return *owner->contents.result;
4063 }
4064 jboolean  CS_LDK_CResult_boolLightningErrorZ_get_ok(int64_t owner) {
4065         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4066         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4067         return ret_conv;
4068 }
4069
4070 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4071         LDKLightningError ret = *owner->contents.err;
4072         ret.is_owned = false;
4073         return ret;
4074 }
4075 int64_t  CS_LDK_CResult_boolLightningErrorZ_get_err(int64_t owner) {
4076         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4077         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4078         int64_t ret_ref = 0;
4079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4080         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4081         return ret_ref;
4082 }
4083
4084 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4085         LDKChannelAnnouncement ret = owner->a;
4086         ret.is_owned = false;
4087         return ret;
4088 }
4089 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(int64_t owner) {
4090         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4091         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4092         int64_t ret_ref = 0;
4093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4095         return ret_ref;
4096 }
4097
4098 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4099         LDKChannelUpdate ret = owner->b;
4100         ret.is_owned = false;
4101         return ret;
4102 }
4103 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(int64_t owner) {
4104         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4105         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4106         int64_t ret_ref = 0;
4107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4108         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4109         return ret_ref;
4110 }
4111
4112 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4113         LDKChannelUpdate ret = owner->c;
4114         ret.is_owned = false;
4115         return ret;
4116 }
4117 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(int64_t owner) {
4118         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4119         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4120         int64_t ret_ref = 0;
4121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4123         return ret_ref;
4124 }
4125
4126 uint32_t CS_LDK_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_ty_from_ptr(int64_t ptr) {
4127         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4128         switch(obj->tag) {
4129                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: return 0;
4130                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: return 1;
4131                 default: abort();
4132         }
4133 }
4134 int64_t CS_LDK_LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_get_some(int64_t ptr) {
4135         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4136         CHECK(obj->tag == LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some);
4137         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4138         *some_conv = obj->some;
4139                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
4140         return tag_ptr(some_conv, true);
4141 }
4142 uint32_t CS_LDK_LDKErrorAction_ty_from_ptr(int64_t ptr) {
4143         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4144         switch(obj->tag) {
4145                 case LDKErrorAction_DisconnectPeer: return 0;
4146                 case LDKErrorAction_DisconnectPeerWithWarning: return 1;
4147                 case LDKErrorAction_IgnoreError: return 2;
4148                 case LDKErrorAction_IgnoreAndLog: return 3;
4149                 case LDKErrorAction_IgnoreDuplicateGossip: return 4;
4150                 case LDKErrorAction_SendErrorMessage: return 5;
4151                 case LDKErrorAction_SendWarningMessage: return 6;
4152                 default: abort();
4153         }
4154 }
4155 int64_t CS_LDK_LDKErrorAction_DisconnectPeer_get_msg(int64_t ptr) {
4156         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4157         CHECK(obj->tag == LDKErrorAction_DisconnectPeer);
4158         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
4159                         int64_t msg_ref = 0;
4160                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4161                         msg_ref = tag_ptr(msg_var.inner, false);
4162         return msg_ref;
4163 }
4164 int64_t CS_LDK_LDKErrorAction_DisconnectPeerWithWarning_get_msg(int64_t ptr) {
4165         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4166         CHECK(obj->tag == LDKErrorAction_DisconnectPeerWithWarning);
4167         LDKWarningMessage msg_var = obj->disconnect_peer_with_warning.msg;
4168                         int64_t msg_ref = 0;
4169                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4170                         msg_ref = tag_ptr(msg_var.inner, false);
4171         return msg_ref;
4172 }
4173 int32_t CS_LDK_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(int64_t ptr) {
4174         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4175         CHECK(obj->tag == LDKErrorAction_IgnoreAndLog);
4176         int32_t ignore_and_log_conv = LDKLevel_to_cs(obj->ignore_and_log);
4177         return ignore_and_log_conv;
4178 }
4179 int64_t CS_LDK_LDKErrorAction_SendErrorMessage_get_msg(int64_t ptr) {
4180         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4181         CHECK(obj->tag == LDKErrorAction_SendErrorMessage);
4182         LDKErrorMessage msg_var = obj->send_error_message.msg;
4183                         int64_t msg_ref = 0;
4184                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4185                         msg_ref = tag_ptr(msg_var.inner, false);
4186         return msg_ref;
4187 }
4188 int64_t CS_LDK_LDKErrorAction_SendWarningMessage_get_msg(int64_t ptr) {
4189         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4190         CHECK(obj->tag == LDKErrorAction_SendWarningMessage);
4191         LDKWarningMessage msg_var = obj->send_warning_message.msg;
4192                         int64_t msg_ref = 0;
4193                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4194                         msg_ref = tag_ptr(msg_var.inner, false);
4195         return msg_ref;
4196 }
4197 int32_t CS_LDK_LDKErrorAction_SendWarningMessage_get_log_level(int64_t ptr) {
4198         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
4199         CHECK(obj->tag == LDKErrorAction_SendWarningMessage);
4200         int32_t log_level_conv = LDKLevel_to_cs(obj->send_warning_message.log_level);
4201         return log_level_conv;
4202 }
4203 uint32_t CS_LDK_LDKMessageSendEvent_ty_from_ptr(int64_t ptr) {
4204         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4205         switch(obj->tag) {
4206                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
4207                 case LDKMessageSendEvent_SendAcceptChannelV2: return 1;
4208                 case LDKMessageSendEvent_SendOpenChannel: return 2;
4209                 case LDKMessageSendEvent_SendOpenChannelV2: return 3;
4210                 case LDKMessageSendEvent_SendFundingCreated: return 4;
4211                 case LDKMessageSendEvent_SendFundingSigned: return 5;
4212                 case LDKMessageSendEvent_SendTxAddInput: return 6;
4213                 case LDKMessageSendEvent_SendTxAddOutput: return 7;
4214                 case LDKMessageSendEvent_SendTxRemoveInput: return 8;
4215                 case LDKMessageSendEvent_SendTxRemoveOutput: return 9;
4216                 case LDKMessageSendEvent_SendTxComplete: return 10;
4217                 case LDKMessageSendEvent_SendTxSignatures: return 11;
4218                 case LDKMessageSendEvent_SendTxInitRbf: return 12;
4219                 case LDKMessageSendEvent_SendTxAckRbf: return 13;
4220                 case LDKMessageSendEvent_SendTxAbort: return 14;
4221                 case LDKMessageSendEvent_SendChannelReady: return 15;
4222                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 16;
4223                 case LDKMessageSendEvent_UpdateHTLCs: return 17;
4224                 case LDKMessageSendEvent_SendRevokeAndACK: return 18;
4225                 case LDKMessageSendEvent_SendClosingSigned: return 19;
4226                 case LDKMessageSendEvent_SendShutdown: return 20;
4227                 case LDKMessageSendEvent_SendChannelReestablish: return 21;
4228                 case LDKMessageSendEvent_SendChannelAnnouncement: return 22;
4229                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 23;
4230                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 24;
4231                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 25;
4232                 case LDKMessageSendEvent_SendChannelUpdate: return 26;
4233                 case LDKMessageSendEvent_HandleError: return 27;
4234                 case LDKMessageSendEvent_SendChannelRangeQuery: return 28;
4235                 case LDKMessageSendEvent_SendShortIdsQuery: return 29;
4236                 case LDKMessageSendEvent_SendReplyChannelRange: return 30;
4237                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 31;
4238                 default: abort();
4239         }
4240 }
4241 int8_tArray CS_LDK_LDKMessageSendEvent_SendAcceptChannel_get_node_id(int64_t ptr) {
4242         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4243         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
4244         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4245         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
4246         return node_id_arr;
4247 }
4248 int64_t CS_LDK_LDKMessageSendEvent_SendAcceptChannel_get_msg(int64_t ptr) {
4249         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4250         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
4251         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
4252                         int64_t msg_ref = 0;
4253                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4254                         msg_ref = tag_ptr(msg_var.inner, false);
4255         return msg_ref;
4256 }
4257 int8_tArray CS_LDK_LDKMessageSendEvent_SendAcceptChannelV2_get_node_id(int64_t ptr) {
4258         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4259         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannelV2);
4260         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4261         memcpy(node_id_arr->elems, obj->send_accept_channel_v2.node_id.compressed_form, 33);
4262         return node_id_arr;
4263 }
4264 int64_t CS_LDK_LDKMessageSendEvent_SendAcceptChannelV2_get_msg(int64_t ptr) {
4265         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4266         CHECK(obj->tag == LDKMessageSendEvent_SendAcceptChannelV2);
4267         LDKAcceptChannelV2 msg_var = obj->send_accept_channel_v2.msg;
4268                         int64_t msg_ref = 0;
4269                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4270                         msg_ref = tag_ptr(msg_var.inner, false);
4271         return msg_ref;
4272 }
4273 int8_tArray CS_LDK_LDKMessageSendEvent_SendOpenChannel_get_node_id(int64_t ptr) {
4274         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4275         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannel);
4276         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4277         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
4278         return node_id_arr;
4279 }
4280 int64_t CS_LDK_LDKMessageSendEvent_SendOpenChannel_get_msg(int64_t ptr) {
4281         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4282         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannel);
4283         LDKOpenChannel msg_var = obj->send_open_channel.msg;
4284                         int64_t msg_ref = 0;
4285                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4286                         msg_ref = tag_ptr(msg_var.inner, false);
4287         return msg_ref;
4288 }
4289 int8_tArray CS_LDK_LDKMessageSendEvent_SendOpenChannelV2_get_node_id(int64_t ptr) {
4290         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4291         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannelV2);
4292         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4293         memcpy(node_id_arr->elems, obj->send_open_channel_v2.node_id.compressed_form, 33);
4294         return node_id_arr;
4295 }
4296 int64_t CS_LDK_LDKMessageSendEvent_SendOpenChannelV2_get_msg(int64_t ptr) {
4297         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4298         CHECK(obj->tag == LDKMessageSendEvent_SendOpenChannelV2);
4299         LDKOpenChannelV2 msg_var = obj->send_open_channel_v2.msg;
4300                         int64_t msg_ref = 0;
4301                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4302                         msg_ref = tag_ptr(msg_var.inner, false);
4303         return msg_ref;
4304 }
4305 int8_tArray CS_LDK_LDKMessageSendEvent_SendFundingCreated_get_node_id(int64_t ptr) {
4306         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4307         CHECK(obj->tag == LDKMessageSendEvent_SendFundingCreated);
4308         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4309         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
4310         return node_id_arr;
4311 }
4312 int64_t CS_LDK_LDKMessageSendEvent_SendFundingCreated_get_msg(int64_t ptr) {
4313         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4314         CHECK(obj->tag == LDKMessageSendEvent_SendFundingCreated);
4315         LDKFundingCreated msg_var = obj->send_funding_created.msg;
4316                         int64_t msg_ref = 0;
4317                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4318                         msg_ref = tag_ptr(msg_var.inner, false);
4319         return msg_ref;
4320 }
4321 int8_tArray CS_LDK_LDKMessageSendEvent_SendFundingSigned_get_node_id(int64_t ptr) {
4322         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4323         CHECK(obj->tag == LDKMessageSendEvent_SendFundingSigned);
4324         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4325         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
4326         return node_id_arr;
4327 }
4328 int64_t CS_LDK_LDKMessageSendEvent_SendFundingSigned_get_msg(int64_t ptr) {
4329         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4330         CHECK(obj->tag == LDKMessageSendEvent_SendFundingSigned);
4331         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
4332                         int64_t msg_ref = 0;
4333                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4334                         msg_ref = tag_ptr(msg_var.inner, false);
4335         return msg_ref;
4336 }
4337 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAddInput_get_node_id(int64_t ptr) {
4338         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4339         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddInput);
4340         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4341         memcpy(node_id_arr->elems, obj->send_tx_add_input.node_id.compressed_form, 33);
4342         return node_id_arr;
4343 }
4344 int64_t CS_LDK_LDKMessageSendEvent_SendTxAddInput_get_msg(int64_t ptr) {
4345         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4346         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddInput);
4347         LDKTxAddInput msg_var = obj->send_tx_add_input.msg;
4348                         int64_t msg_ref = 0;
4349                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4350                         msg_ref = tag_ptr(msg_var.inner, false);
4351         return msg_ref;
4352 }
4353 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAddOutput_get_node_id(int64_t ptr) {
4354         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4355         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddOutput);
4356         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4357         memcpy(node_id_arr->elems, obj->send_tx_add_output.node_id.compressed_form, 33);
4358         return node_id_arr;
4359 }
4360 int64_t CS_LDK_LDKMessageSendEvent_SendTxAddOutput_get_msg(int64_t ptr) {
4361         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4362         CHECK(obj->tag == LDKMessageSendEvent_SendTxAddOutput);
4363         LDKTxAddOutput msg_var = obj->send_tx_add_output.msg;
4364                         int64_t msg_ref = 0;
4365                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4366                         msg_ref = tag_ptr(msg_var.inner, false);
4367         return msg_ref;
4368 }
4369 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxRemoveInput_get_node_id(int64_t ptr) {
4370         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4371         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveInput);
4372         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4373         memcpy(node_id_arr->elems, obj->send_tx_remove_input.node_id.compressed_form, 33);
4374         return node_id_arr;
4375 }
4376 int64_t CS_LDK_LDKMessageSendEvent_SendTxRemoveInput_get_msg(int64_t ptr) {
4377         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4378         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveInput);
4379         LDKTxRemoveInput msg_var = obj->send_tx_remove_input.msg;
4380                         int64_t msg_ref = 0;
4381                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4382                         msg_ref = tag_ptr(msg_var.inner, false);
4383         return msg_ref;
4384 }
4385 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxRemoveOutput_get_node_id(int64_t ptr) {
4386         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4387         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveOutput);
4388         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4389         memcpy(node_id_arr->elems, obj->send_tx_remove_output.node_id.compressed_form, 33);
4390         return node_id_arr;
4391 }
4392 int64_t CS_LDK_LDKMessageSendEvent_SendTxRemoveOutput_get_msg(int64_t ptr) {
4393         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4394         CHECK(obj->tag == LDKMessageSendEvent_SendTxRemoveOutput);
4395         LDKTxRemoveOutput msg_var = obj->send_tx_remove_output.msg;
4396                         int64_t msg_ref = 0;
4397                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4398                         msg_ref = tag_ptr(msg_var.inner, false);
4399         return msg_ref;
4400 }
4401 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxComplete_get_node_id(int64_t ptr) {
4402         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4403         CHECK(obj->tag == LDKMessageSendEvent_SendTxComplete);
4404         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4405         memcpy(node_id_arr->elems, obj->send_tx_complete.node_id.compressed_form, 33);
4406         return node_id_arr;
4407 }
4408 int64_t CS_LDK_LDKMessageSendEvent_SendTxComplete_get_msg(int64_t ptr) {
4409         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4410         CHECK(obj->tag == LDKMessageSendEvent_SendTxComplete);
4411         LDKTxComplete msg_var = obj->send_tx_complete.msg;
4412                         int64_t msg_ref = 0;
4413                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4414                         msg_ref = tag_ptr(msg_var.inner, false);
4415         return msg_ref;
4416 }
4417 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxSignatures_get_node_id(int64_t ptr) {
4418         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4419         CHECK(obj->tag == LDKMessageSendEvent_SendTxSignatures);
4420         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4421         memcpy(node_id_arr->elems, obj->send_tx_signatures.node_id.compressed_form, 33);
4422         return node_id_arr;
4423 }
4424 int64_t CS_LDK_LDKMessageSendEvent_SendTxSignatures_get_msg(int64_t ptr) {
4425         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4426         CHECK(obj->tag == LDKMessageSendEvent_SendTxSignatures);
4427         LDKTxSignatures msg_var = obj->send_tx_signatures.msg;
4428                         int64_t msg_ref = 0;
4429                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4430                         msg_ref = tag_ptr(msg_var.inner, false);
4431         return msg_ref;
4432 }
4433 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxInitRbf_get_node_id(int64_t ptr) {
4434         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4435         CHECK(obj->tag == LDKMessageSendEvent_SendTxInitRbf);
4436         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4437         memcpy(node_id_arr->elems, obj->send_tx_init_rbf.node_id.compressed_form, 33);
4438         return node_id_arr;
4439 }
4440 int64_t CS_LDK_LDKMessageSendEvent_SendTxInitRbf_get_msg(int64_t ptr) {
4441         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4442         CHECK(obj->tag == LDKMessageSendEvent_SendTxInitRbf);
4443         LDKTxInitRbf msg_var = obj->send_tx_init_rbf.msg;
4444                         int64_t msg_ref = 0;
4445                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4446                         msg_ref = tag_ptr(msg_var.inner, false);
4447         return msg_ref;
4448 }
4449 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAckRbf_get_node_id(int64_t ptr) {
4450         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4451         CHECK(obj->tag == LDKMessageSendEvent_SendTxAckRbf);
4452         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4453         memcpy(node_id_arr->elems, obj->send_tx_ack_rbf.node_id.compressed_form, 33);
4454         return node_id_arr;
4455 }
4456 int64_t CS_LDK_LDKMessageSendEvent_SendTxAckRbf_get_msg(int64_t ptr) {
4457         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4458         CHECK(obj->tag == LDKMessageSendEvent_SendTxAckRbf);
4459         LDKTxAckRbf msg_var = obj->send_tx_ack_rbf.msg;
4460                         int64_t msg_ref = 0;
4461                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4462                         msg_ref = tag_ptr(msg_var.inner, false);
4463         return msg_ref;
4464 }
4465 int8_tArray CS_LDK_LDKMessageSendEvent_SendTxAbort_get_node_id(int64_t ptr) {
4466         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4467         CHECK(obj->tag == LDKMessageSendEvent_SendTxAbort);
4468         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4469         memcpy(node_id_arr->elems, obj->send_tx_abort.node_id.compressed_form, 33);
4470         return node_id_arr;
4471 }
4472 int64_t CS_LDK_LDKMessageSendEvent_SendTxAbort_get_msg(int64_t ptr) {
4473         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4474         CHECK(obj->tag == LDKMessageSendEvent_SendTxAbort);
4475         LDKTxAbort msg_var = obj->send_tx_abort.msg;
4476                         int64_t msg_ref = 0;
4477                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4478                         msg_ref = tag_ptr(msg_var.inner, false);
4479         return msg_ref;
4480 }
4481 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelReady_get_node_id(int64_t ptr) {
4482         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4483         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReady);
4484         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4485         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
4486         return node_id_arr;
4487 }
4488 int64_t CS_LDK_LDKMessageSendEvent_SendChannelReady_get_msg(int64_t ptr) {
4489         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4490         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReady);
4491         LDKChannelReady msg_var = obj->send_channel_ready.msg;
4492                         int64_t msg_ref = 0;
4493                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4494                         msg_ref = tag_ptr(msg_var.inner, false);
4495         return msg_ref;
4496 }
4497 int8_tArray CS_LDK_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(int64_t ptr) {
4498         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4499         CHECK(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
4500         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4501         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
4502         return node_id_arr;
4503 }
4504 int64_t CS_LDK_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(int64_t ptr) {
4505         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4506         CHECK(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
4507         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
4508                         int64_t msg_ref = 0;
4509                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4510                         msg_ref = tag_ptr(msg_var.inner, false);
4511         return msg_ref;
4512 }
4513 int8_tArray CS_LDK_LDKMessageSendEvent_UpdateHTLCs_get_node_id(int64_t ptr) {
4514         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4515         CHECK(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
4516         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4517         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
4518         return node_id_arr;
4519 }
4520 int64_t CS_LDK_LDKMessageSendEvent_UpdateHTLCs_get_updates(int64_t ptr) {
4521         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4522         CHECK(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
4523         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
4524                         int64_t updates_ref = 0;
4525                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
4526                         updates_ref = tag_ptr(updates_var.inner, false);
4527         return updates_ref;
4528 }
4529 int8_tArray CS_LDK_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(int64_t ptr) {
4530         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4531         CHECK(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
4532         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4533         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
4534         return node_id_arr;
4535 }
4536 int64_t CS_LDK_LDKMessageSendEvent_SendRevokeAndACK_get_msg(int64_t ptr) {
4537         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4538         CHECK(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
4539         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
4540                         int64_t msg_ref = 0;
4541                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4542                         msg_ref = tag_ptr(msg_var.inner, false);
4543         return msg_ref;
4544 }
4545 int8_tArray CS_LDK_LDKMessageSendEvent_SendClosingSigned_get_node_id(int64_t ptr) {
4546         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4547         CHECK(obj->tag == LDKMessageSendEvent_SendClosingSigned);
4548         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4549         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
4550         return node_id_arr;
4551 }
4552 int64_t CS_LDK_LDKMessageSendEvent_SendClosingSigned_get_msg(int64_t ptr) {
4553         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4554         CHECK(obj->tag == LDKMessageSendEvent_SendClosingSigned);
4555         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
4556                         int64_t msg_ref = 0;
4557                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4558                         msg_ref = tag_ptr(msg_var.inner, false);
4559         return msg_ref;
4560 }
4561 int8_tArray CS_LDK_LDKMessageSendEvent_SendShutdown_get_node_id(int64_t ptr) {
4562         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4563         CHECK(obj->tag == LDKMessageSendEvent_SendShutdown);
4564         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4565         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
4566         return node_id_arr;
4567 }
4568 int64_t CS_LDK_LDKMessageSendEvent_SendShutdown_get_msg(int64_t ptr) {
4569         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4570         CHECK(obj->tag == LDKMessageSendEvent_SendShutdown);
4571         LDKShutdown msg_var = obj->send_shutdown.msg;
4572                         int64_t msg_ref = 0;
4573                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4574                         msg_ref = tag_ptr(msg_var.inner, false);
4575         return msg_ref;
4576 }
4577 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelReestablish_get_node_id(int64_t ptr) {
4578         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4579         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
4580         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4581         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
4582         return node_id_arr;
4583 }
4584 int64_t CS_LDK_LDKMessageSendEvent_SendChannelReestablish_get_msg(int64_t ptr) {
4585         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4586         CHECK(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
4587         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
4588                         int64_t msg_ref = 0;
4589                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4590                         msg_ref = tag_ptr(msg_var.inner, false);
4591         return msg_ref;
4592 }
4593 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelAnnouncement_get_node_id(int64_t ptr) {
4594         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4595         CHECK(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
4596         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4597         memcpy(node_id_arr->elems, obj->send_channel_announcement.node_id.compressed_form, 33);
4598         return node_id_arr;
4599 }
4600 int64_t CS_LDK_LDKMessageSendEvent_SendChannelAnnouncement_get_msg(int64_t ptr) {
4601         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4602         CHECK(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
4603         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
4604                         int64_t msg_ref = 0;
4605                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4606                         msg_ref = tag_ptr(msg_var.inner, false);
4607         return msg_ref;
4608 }
4609 int64_t CS_LDK_LDKMessageSendEvent_SendChannelAnnouncement_get_update_msg(int64_t ptr) {
4610         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4611         CHECK(obj->tag == LDKMessageSendEvent_SendChannelAnnouncement);
4612         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
4613                         int64_t update_msg_ref = 0;
4614                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4615                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4616         return update_msg_ref;
4617 }
4618 int64_t CS_LDK_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(int64_t ptr) {
4619         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4620         CHECK(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
4621         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
4622                         int64_t msg_ref = 0;
4623                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4624                         msg_ref = tag_ptr(msg_var.inner, false);
4625         return msg_ref;
4626 }
4627 int64_t CS_LDK_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(int64_t ptr) {
4628         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4629         CHECK(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
4630         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
4631                         int64_t update_msg_ref = 0;
4632                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
4633                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
4634         return update_msg_ref;
4635 }
4636 int64_t CS_LDK_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(int64_t ptr) {
4637         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4638         CHECK(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
4639         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
4640                         int64_t msg_ref = 0;
4641                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4642                         msg_ref = tag_ptr(msg_var.inner, false);
4643         return msg_ref;
4644 }
4645 int64_t CS_LDK_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(int64_t ptr) {
4646         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4647         CHECK(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
4648         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
4649                         int64_t msg_ref = 0;
4650                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4651                         msg_ref = tag_ptr(msg_var.inner, false);
4652         return msg_ref;
4653 }
4654 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelUpdate_get_node_id(int64_t ptr) {
4655         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4656         CHECK(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
4657         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4658         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
4659         return node_id_arr;
4660 }
4661 int64_t CS_LDK_LDKMessageSendEvent_SendChannelUpdate_get_msg(int64_t ptr) {
4662         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4663         CHECK(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
4664         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
4665                         int64_t msg_ref = 0;
4666                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4667                         msg_ref = tag_ptr(msg_var.inner, false);
4668         return msg_ref;
4669 }
4670 int8_tArray CS_LDK_LDKMessageSendEvent_HandleError_get_node_id(int64_t ptr) {
4671         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4672         CHECK(obj->tag == LDKMessageSendEvent_HandleError);
4673         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4674         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
4675         return node_id_arr;
4676 }
4677 int64_t CS_LDK_LDKMessageSendEvent_HandleError_get_action(int64_t ptr) {
4678         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4679         CHECK(obj->tag == LDKMessageSendEvent_HandleError);
4680         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
4681         return action_ref;
4682 }
4683 int8_tArray CS_LDK_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(int64_t ptr) {
4684         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4685         CHECK(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
4686         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4687         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
4688         return node_id_arr;
4689 }
4690 int64_t CS_LDK_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(int64_t ptr) {
4691         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4692         CHECK(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
4693         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
4694                         int64_t msg_ref = 0;
4695                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4696                         msg_ref = tag_ptr(msg_var.inner, false);
4697         return msg_ref;
4698 }
4699 int8_tArray CS_LDK_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(int64_t ptr) {
4700         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4701         CHECK(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
4702         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4703         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
4704         return node_id_arr;
4705 }
4706 int64_t CS_LDK_LDKMessageSendEvent_SendShortIdsQuery_get_msg(int64_t ptr) {
4707         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4708         CHECK(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
4709         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
4710                         int64_t msg_ref = 0;
4711                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4712                         msg_ref = tag_ptr(msg_var.inner, false);
4713         return msg_ref;
4714 }
4715 int8_tArray CS_LDK_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(int64_t ptr) {
4716         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4717         CHECK(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
4718         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4719         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
4720         return node_id_arr;
4721 }
4722 int64_t CS_LDK_LDKMessageSendEvent_SendReplyChannelRange_get_msg(int64_t ptr) {
4723         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4724         CHECK(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
4725         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
4726                         int64_t msg_ref = 0;
4727                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4728                         msg_ref = tag_ptr(msg_var.inner, false);
4729         return msg_ref;
4730 }
4731 int8_tArray CS_LDK_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(int64_t ptr) {
4732         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4733         CHECK(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
4734         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
4735         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
4736         return node_id_arr;
4737 }
4738 int64_t CS_LDK_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(int64_t ptr) {
4739         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
4740         CHECK(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
4741         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
4742                         int64_t msg_ref = 0;
4743                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
4744                         msg_ref = tag_ptr(msg_var.inner, false);
4745         return msg_ref;
4746 }
4747 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
4748         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
4749         for (size_t i = 0; i < ret.datalen; i++) {
4750                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
4751         }
4752         return ret;
4753 }
4754 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4755         LDKChannelUpdateInfo ret = *owner->contents.result;
4756         ret.is_owned = false;
4757         return ret;
4758 }
4759 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(int64_t owner) {
4760         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4761         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4762         int64_t ret_ref = 0;
4763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4765         return ret_ref;
4766 }
4767
4768 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4769 CHECK(!owner->result_ok);
4770         return DecodeError_clone(&*owner->contents.err);
4771 }
4772 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(int64_t owner) {
4773         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4774         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4775         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4776         int64_t ret_ref = tag_ptr(ret_copy, true);
4777         return ret_ref;
4778 }
4779
4780 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4781         LDKChannelInfo ret = *owner->contents.result;
4782         ret.is_owned = false;
4783         return ret;
4784 }
4785 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_get_ok(int64_t owner) {
4786         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4787         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4788         int64_t ret_ref = 0;
4789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4790         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4791         return ret_ref;
4792 }
4793
4794 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4795 CHECK(!owner->result_ok);
4796         return DecodeError_clone(&*owner->contents.err);
4797 }
4798 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_get_err(int64_t owner) {
4799         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4800         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4801         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4802         int64_t ret_ref = tag_ptr(ret_copy, true);
4803         return ret_ref;
4804 }
4805
4806 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4807         LDKRoutingFees ret = *owner->contents.result;
4808         ret.is_owned = false;
4809         return ret;
4810 }
4811 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_get_ok(int64_t owner) {
4812         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4813         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4814         int64_t ret_ref = 0;
4815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4816         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4817         return ret_ref;
4818 }
4819
4820 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4821 CHECK(!owner->result_ok);
4822         return DecodeError_clone(&*owner->contents.err);
4823 }
4824 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_get_err(int64_t owner) {
4825         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4826         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4827         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4828         int64_t ret_ref = tag_ptr(ret_copy, true);
4829         return ret_ref;
4830 }
4831
4832 uint32_t CS_LDK_LDKSocketAddress_ty_from_ptr(int64_t ptr) {
4833         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4834         switch(obj->tag) {
4835                 case LDKSocketAddress_TcpIpV4: return 0;
4836                 case LDKSocketAddress_TcpIpV6: return 1;
4837                 case LDKSocketAddress_OnionV2: return 2;
4838                 case LDKSocketAddress_OnionV3: return 3;
4839                 case LDKSocketAddress_Hostname: return 4;
4840                 default: abort();
4841         }
4842 }
4843 int8_tArray CS_LDK_LDKSocketAddress_TcpIpV4_get_addr(int64_t ptr) {
4844         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4845         CHECK(obj->tag == LDKSocketAddress_TcpIpV4);
4846         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
4847         memcpy(addr_arr->elems, obj->tcp_ip_v4.addr.data, 4);
4848         return addr_arr;
4849 }
4850 int16_t CS_LDK_LDKSocketAddress_TcpIpV4_get_port(int64_t ptr) {
4851         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4852         CHECK(obj->tag == LDKSocketAddress_TcpIpV4);
4853         int16_t port_conv = obj->tcp_ip_v4.port;
4854         return port_conv;
4855 }
4856 int8_tArray CS_LDK_LDKSocketAddress_TcpIpV6_get_addr(int64_t ptr) {
4857         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4858         CHECK(obj->tag == LDKSocketAddress_TcpIpV6);
4859         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
4860         memcpy(addr_arr->elems, obj->tcp_ip_v6.addr.data, 16);
4861         return addr_arr;
4862 }
4863 int16_t CS_LDK_LDKSocketAddress_TcpIpV6_get_port(int64_t ptr) {
4864         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4865         CHECK(obj->tag == LDKSocketAddress_TcpIpV6);
4866         int16_t port_conv = obj->tcp_ip_v6.port;
4867         return port_conv;
4868 }
4869 int8_tArray CS_LDK_LDKSocketAddress_OnionV2_get_onion_v2(int64_t ptr) {
4870         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4871         CHECK(obj->tag == LDKSocketAddress_OnionV2);
4872         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
4873         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
4874         return onion_v2_arr;
4875 }
4876 int8_tArray CS_LDK_LDKSocketAddress_OnionV3_get_ed25519_pubkey(int64_t ptr) {
4877         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4878         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4879         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
4880         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
4881         return ed25519_pubkey_arr;
4882 }
4883 int16_t CS_LDK_LDKSocketAddress_OnionV3_get_checksum(int64_t ptr) {
4884         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4885         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4886         int16_t checksum_conv = obj->onion_v3.checksum;
4887         return checksum_conv;
4888 }
4889 int8_t CS_LDK_LDKSocketAddress_OnionV3_get_version(int64_t ptr) {
4890         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4891         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4892         int8_t version_conv = obj->onion_v3.version;
4893         return version_conv;
4894 }
4895 int16_t CS_LDK_LDKSocketAddress_OnionV3_get_port(int64_t ptr) {
4896         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4897         CHECK(obj->tag == LDKSocketAddress_OnionV3);
4898         int16_t port_conv = obj->onion_v3.port;
4899         return port_conv;
4900 }
4901 int64_t CS_LDK_LDKSocketAddress_Hostname_get_hostname(int64_t ptr) {
4902         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4903         CHECK(obj->tag == LDKSocketAddress_Hostname);
4904         LDKHostname hostname_var = obj->hostname.hostname;
4905                         int64_t hostname_ref = 0;
4906                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4907                         hostname_ref = tag_ptr(hostname_var.inner, false);
4908         return hostname_ref;
4909 }
4910 int16_t CS_LDK_LDKSocketAddress_Hostname_get_port(int64_t ptr) {
4911         LDKSocketAddress *obj = (LDKSocketAddress*)untag_ptr(ptr);
4912         CHECK(obj->tag == LDKSocketAddress_Hostname);
4913         int16_t port_conv = obj->hostname.port;
4914         return port_conv;
4915 }
4916 static inline LDKCVec_SocketAddressZ CVec_SocketAddressZ_clone(const LDKCVec_SocketAddressZ *orig) {
4917         LDKCVec_SocketAddressZ ret = { .data = MALLOC(sizeof(LDKSocketAddress) * orig->datalen, "LDKCVec_SocketAddressZ clone bytes"), .datalen = orig->datalen };
4918         for (size_t i = 0; i < ret.datalen; i++) {
4919                 ret.data[i] = SocketAddress_clone(&orig->data[i]);
4920         }
4921         return ret;
4922 }
4923 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4924         LDKNodeAnnouncementInfo ret = *owner->contents.result;
4925         ret.is_owned = false;
4926         return ret;
4927 }
4928 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(int64_t owner) {
4929         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4930         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4931         int64_t ret_ref = 0;
4932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4934         return ret_ref;
4935 }
4936
4937 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4938 CHECK(!owner->result_ok);
4939         return DecodeError_clone(&*owner->contents.err);
4940 }
4941 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(int64_t owner) {
4942         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4943         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4944         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4945         int64_t ret_ref = tag_ptr(ret_copy, true);
4946         return ret_ref;
4947 }
4948
4949 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4950         LDKNodeAlias ret = *owner->contents.result;
4951         ret.is_owned = false;
4952         return ret;
4953 }
4954 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_get_ok(int64_t owner) {
4955         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4956         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4957         int64_t ret_ref = 0;
4958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4959         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4960         return ret_ref;
4961 }
4962
4963 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4964 CHECK(!owner->result_ok);
4965         return DecodeError_clone(&*owner->contents.err);
4966 }
4967 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_get_err(int64_t owner) {
4968         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4969         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4970         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4971         int64_t ret_ref = tag_ptr(ret_copy, true);
4972         return ret_ref;
4973 }
4974
4975 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4976         LDKNodeInfo ret = *owner->contents.result;
4977         ret.is_owned = false;
4978         return ret;
4979 }
4980 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_get_ok(int64_t owner) {
4981         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4982         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4983         int64_t ret_ref = 0;
4984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4986         return ret_ref;
4987 }
4988
4989 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4990 CHECK(!owner->result_ok);
4991         return DecodeError_clone(&*owner->contents.err);
4992 }
4993 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_get_err(int64_t owner) {
4994         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4995         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4996         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4997         int64_t ret_ref = tag_ptr(ret_copy, true);
4998         return ret_ref;
4999 }
5000
5001 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5002         LDKNetworkGraph ret = *owner->contents.result;
5003         ret.is_owned = false;
5004         return ret;
5005 }
5006 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_get_ok(int64_t owner) {
5007         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5008         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
5009         int64_t ret_ref = 0;
5010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5011         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5012         return ret_ref;
5013 }
5014
5015 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
5016 CHECK(!owner->result_ok);
5017         return DecodeError_clone(&*owner->contents.err);
5018 }
5019 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_get_err(int64_t owner) {
5020         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
5021         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5022         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
5023         int64_t ret_ref = tag_ptr(ret_copy, true);
5024         return ret_ref;
5025 }
5026
5027 uint32_t CS_LDK_LDKCOption_CVec_SocketAddressZZ_ty_from_ptr(int64_t ptr) {
5028         LDKCOption_CVec_SocketAddressZZ *obj = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(ptr);
5029         switch(obj->tag) {
5030                 case LDKCOption_CVec_SocketAddressZZ_Some: return 0;
5031                 case LDKCOption_CVec_SocketAddressZZ_None: return 1;
5032                 default: abort();
5033         }
5034 }
5035 int64_tArray CS_LDK_LDKCOption_CVec_SocketAddressZZ_Some_get_some(int64_t ptr) {
5036         LDKCOption_CVec_SocketAddressZZ *obj = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(ptr);
5037         CHECK(obj->tag == LDKCOption_CVec_SocketAddressZZ_Some);
5038         LDKCVec_SocketAddressZ some_var = obj->some;
5039                         int64_tArray some_arr = NULL;
5040                         some_arr = init_int64_tArray(some_var.datalen, __LINE__);
5041                         int64_t *some_arr_ptr = (int64_t*)(((uint8_t*)some_arr) + 8);
5042                         for (size_t p = 0; p < some_var.datalen; p++) {
5043                                 int64_t some_conv_15_ref = tag_ptr(&some_var.data[p], false);
5044                                 some_arr_ptr[p] = some_conv_15_ref;
5045                         }
5046                         
5047         return some_arr;
5048 }
5049 static inline LDKCVec_HTLCOutputInCommitmentZ CVec_HTLCOutputInCommitmentZ_clone(const LDKCVec_HTLCOutputInCommitmentZ *orig) {
5050         LDKCVec_HTLCOutputInCommitmentZ ret = { .data = MALLOC(sizeof(LDKHTLCOutputInCommitment) * orig->datalen, "LDKCVec_HTLCOutputInCommitmentZ clone bytes"), .datalen = orig->datalen };
5051         for (size_t i = 0; i < ret.datalen; i++) {
5052                 ret.data[i] = HTLCOutputInCommitment_clone(&orig->data[i]);
5053         }
5054         return ret;
5055 }
5056 static inline LDKCVec_HTLCDescriptorZ CVec_HTLCDescriptorZ_clone(const LDKCVec_HTLCDescriptorZ *orig) {
5057         LDKCVec_HTLCDescriptorZ ret = { .data = MALLOC(sizeof(LDKHTLCDescriptor) * orig->datalen, "LDKCVec_HTLCDescriptorZ clone bytes"), .datalen = orig->datalen };
5058         for (size_t i = 0; i < ret.datalen; i++) {
5059                 ret.data[i] = HTLCDescriptor_clone(&orig->data[i]);
5060         }
5061         return ret;
5062 }
5063 static inline LDKCVec_UtxoZ CVec_UtxoZ_clone(const LDKCVec_UtxoZ *orig) {
5064         LDKCVec_UtxoZ ret = { .data = MALLOC(sizeof(LDKUtxo) * orig->datalen, "LDKCVec_UtxoZ clone bytes"), .datalen = orig->datalen };
5065         for (size_t i = 0; i < ret.datalen; i++) {
5066                 ret.data[i] = Utxo_clone(&orig->data[i]);
5067         }
5068         return ret;
5069 }
5070 uint32_t CS_LDK_LDKCOption_TxOutZ_ty_from_ptr(int64_t ptr) {
5071         LDKCOption_TxOutZ *obj = (LDKCOption_TxOutZ*)untag_ptr(ptr);
5072         switch(obj->tag) {
5073                 case LDKCOption_TxOutZ_Some: return 0;
5074                 case LDKCOption_TxOutZ_None: return 1;
5075                 default: abort();
5076         }
5077 }
5078 int64_t CS_LDK_LDKCOption_TxOutZ_Some_get_some(int64_t ptr) {
5079         LDKCOption_TxOutZ *obj = (LDKCOption_TxOutZ*)untag_ptr(ptr);
5080         CHECK(obj->tag == LDKCOption_TxOutZ_Some);
5081         LDKTxOut* some_ref = &obj->some;
5082         return tag_ptr(some_ref, false);
5083 }
5084 static inline LDKCVec_InputZ CVec_InputZ_clone(const LDKCVec_InputZ *orig) {
5085         LDKCVec_InputZ ret = { .data = MALLOC(sizeof(LDKInput) * orig->datalen, "LDKCVec_InputZ clone bytes"), .datalen = orig->datalen };
5086         for (size_t i = 0; i < ret.datalen; i++) {
5087                 ret.data[i] = Input_clone(&orig->data[i]);
5088         }
5089         return ret;
5090 }
5091 static inline struct LDKCoinSelection CResult_CoinSelectionNoneZ_get_ok(LDKCResult_CoinSelectionNoneZ *NONNULL_PTR owner){
5092         LDKCoinSelection ret = *owner->contents.result;
5093         ret.is_owned = false;
5094         return ret;
5095 }
5096 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_get_ok(int64_t owner) {
5097         LDKCResult_CoinSelectionNoneZ* owner_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(owner);
5098         LDKCoinSelection ret_var = CResult_CoinSelectionNoneZ_get_ok(owner_conv);
5099         int64_t ret_ref = 0;
5100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5101         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5102         return ret_ref;
5103 }
5104
5105 static inline void CResult_CoinSelectionNoneZ_get_err(LDKCResult_CoinSelectionNoneZ *NONNULL_PTR owner){
5106 CHECK(!owner->result_ok);
5107         return *owner->contents.err;
5108 }
5109 void  CS_LDK_CResult_CoinSelectionNoneZ_get_err(int64_t owner) {
5110         LDKCResult_CoinSelectionNoneZ* owner_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(owner);
5111         CResult_CoinSelectionNoneZ_get_err(owner_conv);
5112 }
5113
5114 static inline struct LDKCVec_UtxoZ CResult_CVec_UtxoZNoneZ_get_ok(LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR owner){
5115 CHECK(owner->result_ok);
5116         return CVec_UtxoZ_clone(&*owner->contents.result);
5117 }
5118 int64_tArray  CS_LDK_CResult_CVec_UtxoZNoneZ_get_ok(int64_t owner) {
5119         LDKCResult_CVec_UtxoZNoneZ* owner_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(owner);
5120         LDKCVec_UtxoZ ret_var = CResult_CVec_UtxoZNoneZ_get_ok(owner_conv);
5121         int64_tArray ret_arr = NULL;
5122         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
5123         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
5124         for (size_t g = 0; g < ret_var.datalen; g++) {
5125                 LDKUtxo ret_conv_6_var = ret_var.data[g];
5126                 int64_t ret_conv_6_ref = 0;
5127                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
5128                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
5129                 ret_arr_ptr[g] = ret_conv_6_ref;
5130         }
5131         
5132         FREE(ret_var.data);
5133         return ret_arr;
5134 }
5135
5136 static inline void CResult_CVec_UtxoZNoneZ_get_err(LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR owner){
5137 CHECK(!owner->result_ok);
5138         return *owner->contents.err;
5139 }
5140 void  CS_LDK_CResult_CVec_UtxoZNoneZ_get_err(int64_t owner) {
5141         LDKCResult_CVec_UtxoZNoneZ* owner_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(owner);
5142         CResult_CVec_UtxoZNoneZ_get_err(owner_conv);
5143 }
5144
5145 static inline uint64_t C2Tuple_u64u16Z_get_a(LDKC2Tuple_u64u16Z *NONNULL_PTR owner){
5146         return owner->a;
5147 }
5148 int64_t  CS_LDK_C2Tuple_u64u16Z_get_a(int64_t owner) {
5149         LDKC2Tuple_u64u16Z* owner_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(owner);
5150         int64_t ret_conv = C2Tuple_u64u16Z_get_a(owner_conv);
5151         return ret_conv;
5152 }
5153
5154 static inline uint16_t C2Tuple_u64u16Z_get_b(LDKC2Tuple_u64u16Z *NONNULL_PTR owner){
5155         return owner->b;
5156 }
5157 int16_t  CS_LDK_C2Tuple_u64u16Z_get_b(int64_t owner) {
5158         LDKC2Tuple_u64u16Z* owner_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(owner);
5159         int16_t ret_conv = C2Tuple_u64u16Z_get_b(owner_conv);
5160         return ret_conv;
5161 }
5162
5163 uint32_t CS_LDK_LDKCOption_C2Tuple_u64u16ZZ_ty_from_ptr(int64_t ptr) {
5164         LDKCOption_C2Tuple_u64u16ZZ *obj = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(ptr);
5165         switch(obj->tag) {
5166                 case LDKCOption_C2Tuple_u64u16ZZ_Some: return 0;
5167                 case LDKCOption_C2Tuple_u64u16ZZ_None: return 1;
5168                 default: abort();
5169         }
5170 }
5171 int64_t CS_LDK_LDKCOption_C2Tuple_u64u16ZZ_Some_get_some(int64_t ptr) {
5172         LDKCOption_C2Tuple_u64u16ZZ *obj = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(ptr);
5173         CHECK(obj->tag == LDKCOption_C2Tuple_u64u16ZZ_Some);
5174         LDKC2Tuple_u64u16Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
5175         *some_conv = obj->some;
5176                         *some_conv = C2Tuple_u64u16Z_clone(some_conv);
5177         return tag_ptr(some_conv, true);
5178 }
5179 uint32_t CS_LDK_LDKCOption_ChannelShutdownStateZ_ty_from_ptr(int64_t ptr) {
5180         LDKCOption_ChannelShutdownStateZ *obj = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(ptr);
5181         switch(obj->tag) {
5182                 case LDKCOption_ChannelShutdownStateZ_Some: return 0;
5183                 case LDKCOption_ChannelShutdownStateZ_None: return 1;
5184                 default: abort();
5185         }
5186 }
5187 int32_t CS_LDK_LDKCOption_ChannelShutdownStateZ_Some_get_some(int64_t ptr) {
5188         LDKCOption_ChannelShutdownStateZ *obj = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(ptr);
5189         CHECK(obj->tag == LDKCOption_ChannelShutdownStateZ_Some);
5190         int32_t some_conv = LDKChannelShutdownState_to_cs(obj->some);
5191         return some_conv;
5192 }
5193 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesAPIErrorZ_get_ok(LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR owner){
5194 CHECK(owner->result_ok);
5195         return ThirtyTwoBytes_clone(&*owner->contents.result);
5196 }
5197 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_get_ok(int64_t owner) {
5198         LDKCResult_ThirtyTwoBytesAPIErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(owner);
5199         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5200         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesAPIErrorZ_get_ok(owner_conv).data, 32);
5201         return ret_arr;
5202 }
5203
5204 static inline struct LDKAPIError CResult_ThirtyTwoBytesAPIErrorZ_get_err(LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR owner){
5205 CHECK(!owner->result_ok);
5206         return APIError_clone(&*owner->contents.err);
5207 }
5208 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_get_err(int64_t owner) {
5209         LDKCResult_ThirtyTwoBytesAPIErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(owner);
5210         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5211         *ret_copy = CResult_ThirtyTwoBytesAPIErrorZ_get_err(owner_conv);
5212         int64_t ret_ref = tag_ptr(ret_copy, true);
5213         return ret_ref;
5214 }
5215
5216 uint32_t CS_LDK_LDKRecentPaymentDetails_ty_from_ptr(int64_t ptr) {
5217         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5218         switch(obj->tag) {
5219                 case LDKRecentPaymentDetails_AwaitingInvoice: return 0;
5220                 case LDKRecentPaymentDetails_Pending: return 1;
5221                 case LDKRecentPaymentDetails_Fulfilled: return 2;
5222                 case LDKRecentPaymentDetails_Abandoned: return 3;
5223                 default: abort();
5224         }
5225 }
5226 int8_tArray CS_LDK_LDKRecentPaymentDetails_AwaitingInvoice_get_payment_id(int64_t ptr) {
5227         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5228         CHECK(obj->tag == LDKRecentPaymentDetails_AwaitingInvoice);
5229         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5230         memcpy(payment_id_arr->elems, obj->awaiting_invoice.payment_id.data, 32);
5231         return payment_id_arr;
5232 }
5233 int8_tArray CS_LDK_LDKRecentPaymentDetails_Pending_get_payment_id(int64_t ptr) {
5234         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5235         CHECK(obj->tag == LDKRecentPaymentDetails_Pending);
5236         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5237         memcpy(payment_id_arr->elems, obj->pending.payment_id.data, 32);
5238         return payment_id_arr;
5239 }
5240 int8_tArray CS_LDK_LDKRecentPaymentDetails_Pending_get_payment_hash(int64_t ptr) {
5241         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5242         CHECK(obj->tag == LDKRecentPaymentDetails_Pending);
5243         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
5244         memcpy(payment_hash_arr->elems, obj->pending.payment_hash.data, 32);
5245         return payment_hash_arr;
5246 }
5247 int64_t CS_LDK_LDKRecentPaymentDetails_Pending_get_total_msat(int64_t ptr) {
5248         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5249         CHECK(obj->tag == LDKRecentPaymentDetails_Pending);
5250         int64_t total_msat_conv = obj->pending.total_msat;
5251         return total_msat_conv;
5252 }
5253 int8_tArray CS_LDK_LDKRecentPaymentDetails_Fulfilled_get_payment_id(int64_t ptr) {
5254         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5255         CHECK(obj->tag == LDKRecentPaymentDetails_Fulfilled);
5256         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5257         memcpy(payment_id_arr->elems, obj->fulfilled.payment_id.data, 32);
5258         return payment_id_arr;
5259 }
5260 int64_t CS_LDK_LDKRecentPaymentDetails_Fulfilled_get_payment_hash(int64_t ptr) {
5261         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5262         CHECK(obj->tag == LDKRecentPaymentDetails_Fulfilled);
5263         int64_t payment_hash_ref = tag_ptr(&obj->fulfilled.payment_hash, false);
5264         return payment_hash_ref;
5265 }
5266 int8_tArray CS_LDK_LDKRecentPaymentDetails_Abandoned_get_payment_id(int64_t ptr) {
5267         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5268         CHECK(obj->tag == LDKRecentPaymentDetails_Abandoned);
5269         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5270         memcpy(payment_id_arr->elems, obj->abandoned.payment_id.data, 32);
5271         return payment_id_arr;
5272 }
5273 int8_tArray CS_LDK_LDKRecentPaymentDetails_Abandoned_get_payment_hash(int64_t ptr) {
5274         LDKRecentPaymentDetails *obj = (LDKRecentPaymentDetails*)untag_ptr(ptr);
5275         CHECK(obj->tag == LDKRecentPaymentDetails_Abandoned);
5276         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
5277         memcpy(payment_hash_arr->elems, obj->abandoned.payment_hash.data, 32);
5278         return payment_hash_arr;
5279 }
5280 static inline LDKCVec_RecentPaymentDetailsZ CVec_RecentPaymentDetailsZ_clone(const LDKCVec_RecentPaymentDetailsZ *orig) {
5281         LDKCVec_RecentPaymentDetailsZ ret = { .data = MALLOC(sizeof(LDKRecentPaymentDetails) * orig->datalen, "LDKCVec_RecentPaymentDetailsZ clone bytes"), .datalen = orig->datalen };
5282         for (size_t i = 0; i < ret.datalen; i++) {
5283                 ret.data[i] = RecentPaymentDetails_clone(&orig->data[i]);
5284         }
5285         return ret;
5286 }
5287 uint32_t CS_LDK_LDKPaymentSendFailure_ty_from_ptr(int64_t ptr) {
5288         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5289         switch(obj->tag) {
5290                 case LDKPaymentSendFailure_ParameterError: return 0;
5291                 case LDKPaymentSendFailure_PathParameterError: return 1;
5292                 case LDKPaymentSendFailure_AllFailedResendSafe: return 2;
5293                 case LDKPaymentSendFailure_DuplicatePayment: return 3;
5294                 case LDKPaymentSendFailure_PartialFailure: return 4;
5295                 default: abort();
5296         }
5297 }
5298 int64_t CS_LDK_LDKPaymentSendFailure_ParameterError_get_parameter_error(int64_t ptr) {
5299         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5300         CHECK(obj->tag == LDKPaymentSendFailure_ParameterError);
5301         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
5302         return parameter_error_ref;
5303 }
5304 int64_tArray CS_LDK_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(int64_t ptr) {
5305         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5306         CHECK(obj->tag == LDKPaymentSendFailure_PathParameterError);
5307         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5308                         int64_tArray path_parameter_error_arr = NULL;
5309                         path_parameter_error_arr = init_int64_tArray(path_parameter_error_var.datalen, __LINE__);
5310                         int64_t *path_parameter_error_arr_ptr = (int64_t*)(((uint8_t*)path_parameter_error_arr) + 8);
5311                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5312                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5313                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5314                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5315                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
5316                         }
5317                         
5318         return path_parameter_error_arr;
5319 }
5320 int64_tArray CS_LDK_LDKPaymentSendFailure_AllFailedResendSafe_get_all_failed_resend_safe(int64_t ptr) {
5321         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5322         CHECK(obj->tag == LDKPaymentSendFailure_AllFailedResendSafe);
5323         LDKCVec_APIErrorZ all_failed_resend_safe_var = obj->all_failed_resend_safe;
5324                         int64_tArray all_failed_resend_safe_arr = NULL;
5325                         all_failed_resend_safe_arr = init_int64_tArray(all_failed_resend_safe_var.datalen, __LINE__);
5326                         int64_t *all_failed_resend_safe_arr_ptr = (int64_t*)(((uint8_t*)all_failed_resend_safe_arr) + 8);
5327                         for (size_t k = 0; k < all_failed_resend_safe_var.datalen; k++) {
5328                                 int64_t all_failed_resend_safe_conv_10_ref = tag_ptr(&all_failed_resend_safe_var.data[k], false);
5329                                 all_failed_resend_safe_arr_ptr[k] = all_failed_resend_safe_conv_10_ref;
5330                         }
5331                         
5332         return all_failed_resend_safe_arr;
5333 }
5334 int64_tArray CS_LDK_LDKPaymentSendFailure_PartialFailure_get_results(int64_t ptr) {
5335         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5336         CHECK(obj->tag == LDKPaymentSendFailure_PartialFailure);
5337         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
5338                         int64_tArray results_arr = NULL;
5339                         results_arr = init_int64_tArray(results_var.datalen, __LINE__);
5340                         int64_t *results_arr_ptr = (int64_t*)(((uint8_t*)results_arr) + 8);
5341                         for (size_t w = 0; w < results_var.datalen; w++) {
5342                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5343                                 *results_conv_22_conv = results_var.data[w];
5344                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
5345                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
5346                         }
5347                         
5348         return results_arr;
5349 }
5350 int64_t CS_LDK_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(int64_t ptr) {
5351         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5352         CHECK(obj->tag == LDKPaymentSendFailure_PartialFailure);
5353         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
5354                         int64_t failed_paths_retry_ref = 0;
5355                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
5356                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
5357         return failed_paths_retry_ref;
5358 }
5359 int8_tArray CS_LDK_LDKPaymentSendFailure_PartialFailure_get_payment_id(int64_t ptr) {
5360         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
5361         CHECK(obj->tag == LDKPaymentSendFailure_PartialFailure);
5362         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
5363         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
5364         return payment_id_arr;
5365 }
5366 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5367 CHECK(owner->result_ok);
5368         return *owner->contents.result;
5369 }
5370 void  CS_LDK_CResult_NonePaymentSendFailureZ_get_ok(int64_t owner) {
5371         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
5372         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
5373 }
5374
5375 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
5376 CHECK(!owner->result_ok);
5377         return PaymentSendFailure_clone(&*owner->contents.err);
5378 }
5379 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_get_err(int64_t owner) {
5380         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
5381         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5382         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
5383         int64_t ret_ref = tag_ptr(ret_copy, true);
5384         return ret_ref;
5385 }
5386
5387 static inline void CResult_NoneRetryableSendFailureZ_get_ok(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
5388 CHECK(owner->result_ok);
5389         return *owner->contents.result;
5390 }
5391 void  CS_LDK_CResult_NoneRetryableSendFailureZ_get_ok(int64_t owner) {
5392         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
5393         CResult_NoneRetryableSendFailureZ_get_ok(owner_conv);
5394 }
5395
5396 static inline enum LDKRetryableSendFailure CResult_NoneRetryableSendFailureZ_get_err(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR owner){
5397 CHECK(!owner->result_ok);
5398         return RetryableSendFailure_clone(&*owner->contents.err);
5399 }
5400 int32_t  CS_LDK_CResult_NoneRetryableSendFailureZ_get_err(int64_t owner) {
5401         LDKCResult_NoneRetryableSendFailureZ* owner_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(owner);
5402         int32_t ret_conv = LDKRetryableSendFailure_to_cs(CResult_NoneRetryableSendFailureZ_get_err(owner_conv));
5403         return ret_conv;
5404 }
5405
5406 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesPaymentSendFailureZ_get_ok(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ *NONNULL_PTR owner){
5407 CHECK(owner->result_ok);
5408         return ThirtyTwoBytes_clone(&*owner->contents.result);
5409 }
5410 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_get_ok(int64_t owner) {
5411         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(owner);
5412         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5413         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesPaymentSendFailureZ_get_ok(owner_conv).data, 32);
5414         return ret_arr;
5415 }
5416
5417 static inline struct LDKPaymentSendFailure CResult_ThirtyTwoBytesPaymentSendFailureZ_get_err(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ *NONNULL_PTR owner){
5418 CHECK(!owner->result_ok);
5419         return PaymentSendFailure_clone(&*owner->contents.err);
5420 }
5421 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_get_err(int64_t owner) {
5422         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(owner);
5423         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5424         *ret_copy = CResult_ThirtyTwoBytesPaymentSendFailureZ_get_err(owner_conv);
5425         int64_t ret_ref = tag_ptr(ret_copy, true);
5426         return ret_ref;
5427 }
5428
5429 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesRetryableSendFailureZ_get_ok(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ *NONNULL_PTR owner){
5430 CHECK(owner->result_ok);
5431         return ThirtyTwoBytes_clone(&*owner->contents.result);
5432 }
5433 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_get_ok(int64_t owner) {
5434         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(owner);
5435         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5436         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesRetryableSendFailureZ_get_ok(owner_conv).data, 32);
5437         return ret_arr;
5438 }
5439
5440 static inline enum LDKRetryableSendFailure CResult_ThirtyTwoBytesRetryableSendFailureZ_get_err(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ *NONNULL_PTR owner){
5441 CHECK(!owner->result_ok);
5442         return RetryableSendFailure_clone(&*owner->contents.err);
5443 }
5444 int32_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_get_err(int64_t owner) {
5445         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* owner_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(owner);
5446         int32_t ret_conv = LDKRetryableSendFailure_to_cs(CResult_ThirtyTwoBytesRetryableSendFailureZ_get_err(owner_conv));
5447         return ret_conv;
5448 }
5449
5450 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_a(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *NONNULL_PTR owner){
5451         return ThirtyTwoBytes_clone(&owner->a);
5452 }
5453 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_a(int64_t owner) {
5454         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(owner);
5455         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5456         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_a(owner_conv).data, 32);
5457         return ret_arr;
5458 }
5459
5460 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_b(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *NONNULL_PTR owner){
5461         return ThirtyTwoBytes_clone(&owner->b);
5462 }
5463 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_b(int64_t owner) {
5464         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(owner);
5465         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5466         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_get_b(owner_conv).data, 32);
5467         return ret_arr;
5468 }
5469
5470 static inline struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ *NONNULL_PTR owner){
5471 CHECK(owner->result_ok);
5472         return C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(&*owner->contents.result);
5473 }
5474 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_ok(int64_t owner) {
5475         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(owner);
5476         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
5477         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_ok(owner_conv);
5478         return tag_ptr(ret_conv, true);
5479 }
5480
5481 static inline struct LDKPaymentSendFailure CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ *NONNULL_PTR owner){
5482 CHECK(!owner->result_ok);
5483         return PaymentSendFailure_clone(&*owner->contents.err);
5484 }
5485 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_err(int64_t owner) {
5486         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(owner);
5487         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
5488         *ret_copy = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_get_err(owner_conv);
5489         int64_t ret_ref = tag_ptr(ret_copy, true);
5490         return ret_ref;
5491 }
5492
5493 static inline LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ *orig) {
5494         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ clone bytes"), .datalen = orig->datalen };
5495         for (size_t i = 0; i < ret.datalen; i++) {
5496                 ret.data[i] = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(&orig->data[i]);
5497         }
5498         return ret;
5499 }
5500 uint32_t CS_LDK_LDKProbeSendFailure_ty_from_ptr(int64_t ptr) {
5501         LDKProbeSendFailure *obj = (LDKProbeSendFailure*)untag_ptr(ptr);
5502         switch(obj->tag) {
5503                 case LDKProbeSendFailure_RouteNotFound: return 0;
5504                 case LDKProbeSendFailure_SendingFailed: return 1;
5505                 default: abort();
5506         }
5507 }
5508 int64_t CS_LDK_LDKProbeSendFailure_SendingFailed_get_sending_failed(int64_t ptr) {
5509         LDKProbeSendFailure *obj = (LDKProbeSendFailure*)untag_ptr(ptr);
5510         CHECK(obj->tag == LDKProbeSendFailure_SendingFailed);
5511         int64_t sending_failed_ref = tag_ptr(&obj->sending_failed, false);
5512         return sending_failed_ref;
5513 }
5514 static inline struct LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_ok(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ *NONNULL_PTR owner){
5515 CHECK(owner->result_ok);
5516         return CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_clone(&*owner->contents.result);
5517 }
5518 int64_tArray  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_ok(int64_t owner) {
5519         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(owner);
5520         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ ret_var = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_ok(owner_conv);
5521         int64_tArray ret_arr = NULL;
5522         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
5523         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
5524         for (size_t o = 0; o < ret_var.datalen; o++) {
5525                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
5526                 *ret_conv_40_conv = ret_var.data[o];
5527                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
5528         }
5529         
5530         FREE(ret_var.data);
5531         return ret_arr;
5532 }
5533
5534 static inline struct LDKProbeSendFailure CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_err(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ *NONNULL_PTR owner){
5535 CHECK(!owner->result_ok);
5536         return ProbeSendFailure_clone(&*owner->contents.err);
5537 }
5538 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_err(int64_t owner) {
5539         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(owner);
5540         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
5541         *ret_copy = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_get_err(owner_conv);
5542         int64_t ret_ref = tag_ptr(ret_copy, true);
5543         return ret_ref;
5544 }
5545
5546 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesPublicKeyZ_get_a(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *NONNULL_PTR owner){
5547         return ThirtyTwoBytes_clone(&owner->a);
5548 }
5549 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_get_a(int64_t owner) {
5550         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(owner);
5551         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5552         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesPublicKeyZ_get_a(owner_conv).data, 32);
5553         return ret_arr;
5554 }
5555
5556 static inline struct LDKPublicKey C2Tuple_ThirtyTwoBytesPublicKeyZ_get_b(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *NONNULL_PTR owner){
5557         return owner->b;
5558 }
5559 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_get_b(int64_t owner) {
5560         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(owner);
5561         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5562         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesPublicKeyZ_get_b(owner_conv).compressed_form, 33);
5563         return ret_arr;
5564 }
5565
5566 static inline LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ *orig) {
5567         LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ clone bytes"), .datalen = orig->datalen };
5568         for (size_t i = 0; i < ret.datalen; i++) {
5569                 ret.data[i] = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(&orig->data[i]);
5570         }
5571         return ret;
5572 }
5573 uint32_t CS_LDK_LDKCOption_StrZ_ty_from_ptr(int64_t ptr) {
5574         LDKCOption_StrZ *obj = (LDKCOption_StrZ*)untag_ptr(ptr);
5575         switch(obj->tag) {
5576                 case LDKCOption_StrZ_Some: return 0;
5577                 case LDKCOption_StrZ_None: return 1;
5578                 default: abort();
5579         }
5580 }
5581 jstring CS_LDK_LDKCOption_StrZ_Some_get_some(int64_t ptr) {
5582         LDKCOption_StrZ *obj = (LDKCOption_StrZ*)untag_ptr(ptr);
5583         CHECK(obj->tag == LDKCOption_StrZ_Some);
5584         LDKStr some_str = obj->some;
5585                         jstring some_conv = str_ref_to_cs(some_str.chars, some_str.len);
5586         return some_conv;
5587 }
5588 static inline void CResult_NoneBolt12SemanticErrorZ_get_ok(LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR owner){
5589 CHECK(owner->result_ok);
5590         return *owner->contents.result;
5591 }
5592 void  CS_LDK_CResult_NoneBolt12SemanticErrorZ_get_ok(int64_t owner) {
5593         LDKCResult_NoneBolt12SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(owner);
5594         CResult_NoneBolt12SemanticErrorZ_get_ok(owner_conv);
5595 }
5596
5597 static inline enum LDKBolt12SemanticError CResult_NoneBolt12SemanticErrorZ_get_err(LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR owner){
5598 CHECK(!owner->result_ok);
5599         return Bolt12SemanticError_clone(&*owner->contents.err);
5600 }
5601 int32_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_get_err(int64_t owner) {
5602         LDKCResult_NoneBolt12SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(owner);
5603         int32_t ret_conv = LDKBolt12SemanticError_to_cs(CResult_NoneBolt12SemanticErrorZ_get_err(owner_conv));
5604         return ret_conv;
5605 }
5606
5607 static inline struct LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR owner){
5608 CHECK(owner->result_ok);
5609         return C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(&*owner->contents.result);
5610 }
5611 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_ok(int64_t owner) {
5612         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(owner);
5613         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
5614         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_ok(owner_conv);
5615         return tag_ptr(ret_conv, true);
5616 }
5617
5618 static inline void CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR owner){
5619 CHECK(!owner->result_ok);
5620         return *owner->contents.err;
5621 }
5622 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_err(int64_t owner) {
5623         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(owner);
5624         CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_get_err(owner_conv);
5625 }
5626
5627 uint32_t CS_LDK_LDKOffersMessage_ty_from_ptr(int64_t ptr) {
5628         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5629         switch(obj->tag) {
5630                 case LDKOffersMessage_InvoiceRequest: return 0;
5631                 case LDKOffersMessage_Invoice: return 1;
5632                 case LDKOffersMessage_InvoiceError: return 2;
5633                 default: abort();
5634         }
5635 }
5636 int64_t CS_LDK_LDKOffersMessage_InvoiceRequest_get_invoice_request(int64_t ptr) {
5637         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5638         CHECK(obj->tag == LDKOffersMessage_InvoiceRequest);
5639         LDKInvoiceRequest invoice_request_var = obj->invoice_request;
5640                         int64_t invoice_request_ref = 0;
5641                         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_request_var);
5642                         invoice_request_ref = tag_ptr(invoice_request_var.inner, false);
5643         return invoice_request_ref;
5644 }
5645 int64_t CS_LDK_LDKOffersMessage_Invoice_get_invoice(int64_t ptr) {
5646         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5647         CHECK(obj->tag == LDKOffersMessage_Invoice);
5648         LDKBolt12Invoice invoice_var = obj->invoice;
5649                         int64_t invoice_ref = 0;
5650                         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_var);
5651                         invoice_ref = tag_ptr(invoice_var.inner, false);
5652         return invoice_ref;
5653 }
5654 int64_t CS_LDK_LDKOffersMessage_InvoiceError_get_invoice_error(int64_t ptr) {
5655         LDKOffersMessage *obj = (LDKOffersMessage*)untag_ptr(ptr);
5656         CHECK(obj->tag == LDKOffersMessage_InvoiceError);
5657         LDKInvoiceError invoice_error_var = obj->invoice_error;
5658                         int64_t invoice_error_ref = 0;
5659                         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_error_var);
5660                         invoice_error_ref = tag_ptr(invoice_error_var.inner, false);
5661         return invoice_error_ref;
5662 }
5663 uint32_t CS_LDK_LDKCOption_OffersMessageZ_ty_from_ptr(int64_t ptr) {
5664         LDKCOption_OffersMessageZ *obj = (LDKCOption_OffersMessageZ*)untag_ptr(ptr);
5665         switch(obj->tag) {
5666                 case LDKCOption_OffersMessageZ_Some: return 0;
5667                 case LDKCOption_OffersMessageZ_None: return 1;
5668                 default: abort();
5669         }
5670 }
5671 int64_t CS_LDK_LDKCOption_OffersMessageZ_Some_get_some(int64_t ptr) {
5672         LDKCOption_OffersMessageZ *obj = (LDKCOption_OffersMessageZ*)untag_ptr(ptr);
5673         CHECK(obj->tag == LDKCOption_OffersMessageZ_Some);
5674         int64_t some_ref = tag_ptr(&obj->some, false);
5675         return some_ref;
5676 }
5677 uint32_t CS_LDK_LDKDestination_ty_from_ptr(int64_t ptr) {
5678         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
5679         switch(obj->tag) {
5680                 case LDKDestination_Node: return 0;
5681                 case LDKDestination_BlindedPath: return 1;
5682                 default: abort();
5683         }
5684 }
5685 int8_tArray CS_LDK_LDKDestination_Node_get_node(int64_t ptr) {
5686         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
5687         CHECK(obj->tag == LDKDestination_Node);
5688         int8_tArray node_arr = init_int8_tArray(33, __LINE__);
5689         memcpy(node_arr->elems, obj->node.compressed_form, 33);
5690         return node_arr;
5691 }
5692 int64_t CS_LDK_LDKDestination_BlindedPath_get_blinded_path(int64_t ptr) {
5693         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
5694         CHECK(obj->tag == LDKDestination_BlindedPath);
5695         LDKBlindedPath blinded_path_var = obj->blinded_path;
5696                         int64_t blinded_path_ref = 0;
5697                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_path_var);
5698                         blinded_path_ref = tag_ptr(blinded_path_var.inner, false);
5699         return blinded_path_ref;
5700 }
5701 static inline struct LDKOffersMessage C3Tuple_OffersMessageDestinationBlindedPathZ_get_a(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR owner){
5702         return OffersMessage_clone(&owner->a);
5703 }
5704 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_get_a(int64_t owner) {
5705         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(owner);
5706         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
5707         *ret_copy = C3Tuple_OffersMessageDestinationBlindedPathZ_get_a(owner_conv);
5708         int64_t ret_ref = tag_ptr(ret_copy, true);
5709         return ret_ref;
5710 }
5711
5712 static inline struct LDKDestination C3Tuple_OffersMessageDestinationBlindedPathZ_get_b(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR owner){
5713         return Destination_clone(&owner->b);
5714 }
5715 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_get_b(int64_t owner) {
5716         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(owner);
5717         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
5718         *ret_copy = C3Tuple_OffersMessageDestinationBlindedPathZ_get_b(owner_conv);
5719         int64_t ret_ref = tag_ptr(ret_copy, true);
5720         return ret_ref;
5721 }
5722
5723 static inline struct LDKBlindedPath C3Tuple_OffersMessageDestinationBlindedPathZ_get_c(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR owner){
5724         LDKBlindedPath ret = owner->c;
5725         ret.is_owned = false;
5726         return ret;
5727 }
5728 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_get_c(int64_t owner) {
5729         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(owner);
5730         LDKBlindedPath ret_var = C3Tuple_OffersMessageDestinationBlindedPathZ_get_c(owner_conv);
5731         int64_t ret_ref = 0;
5732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5734         return ret_ref;
5735 }
5736
5737 static inline LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_clone(const LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ *orig) {
5738         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ) * orig->datalen, "LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ clone bytes"), .datalen = orig->datalen };
5739         for (size_t i = 0; i < ret.datalen; i++) {
5740                 ret.data[i] = C3Tuple_OffersMessageDestinationBlindedPathZ_clone(&orig->data[i]);
5741         }
5742         return ret;
5743 }
5744 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5745         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
5746         ret.is_owned = false;
5747         return ret;
5748 }
5749 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(int64_t owner) {
5750         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
5751         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
5752         int64_t ret_ref = 0;
5753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5754         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5755         return ret_ref;
5756 }
5757
5758 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
5759 CHECK(!owner->result_ok);
5760         return DecodeError_clone(&*owner->contents.err);
5761 }
5762 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(int64_t owner) {
5763         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
5764         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5765         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
5766         int64_t ret_ref = tag_ptr(ret_copy, true);
5767         return ret_ref;
5768 }
5769
5770 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5771         LDKChannelCounterparty ret = *owner->contents.result;
5772         ret.is_owned = false;
5773         return ret;
5774 }
5775 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(int64_t owner) {
5776         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
5777         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
5778         int64_t ret_ref = 0;
5779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5781         return ret_ref;
5782 }
5783
5784 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
5785 CHECK(!owner->result_ok);
5786         return DecodeError_clone(&*owner->contents.err);
5787 }
5788 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_get_err(int64_t owner) {
5789         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
5790         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5791         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
5792         int64_t ret_ref = tag_ptr(ret_copy, true);
5793         return ret_ref;
5794 }
5795
5796 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5797         LDKChannelDetails ret = *owner->contents.result;
5798         ret.is_owned = false;
5799         return ret;
5800 }
5801 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_get_ok(int64_t owner) {
5802         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
5803         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
5804         int64_t ret_ref = 0;
5805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5806         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5807         return ret_ref;
5808 }
5809
5810 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
5811 CHECK(!owner->result_ok);
5812         return DecodeError_clone(&*owner->contents.err);
5813 }
5814 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_get_err(int64_t owner) {
5815         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
5816         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5817         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
5818         int64_t ret_ref = tag_ptr(ret_copy, true);
5819         return ret_ref;
5820 }
5821
5822 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5823         LDKPhantomRouteHints ret = *owner->contents.result;
5824         ret.is_owned = false;
5825         return ret;
5826 }
5827 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(int64_t owner) {
5828         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
5829         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
5830         int64_t ret_ref = 0;
5831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5832         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5833         return ret_ref;
5834 }
5835
5836 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
5837 CHECK(!owner->result_ok);
5838         return DecodeError_clone(&*owner->contents.err);
5839 }
5840 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_get_err(int64_t owner) {
5841         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
5842         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5843         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
5844         int64_t ret_ref = tag_ptr(ret_copy, true);
5845         return ret_ref;
5846 }
5847
5848 static inline enum LDKChannelShutdownState CResult_ChannelShutdownStateDecodeErrorZ_get_ok(LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR owner){
5849 CHECK(owner->result_ok);
5850         return ChannelShutdownState_clone(&*owner->contents.result);
5851 }
5852 int32_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_get_ok(int64_t owner) {
5853         LDKCResult_ChannelShutdownStateDecodeErrorZ* owner_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(owner);
5854         int32_t ret_conv = LDKChannelShutdownState_to_cs(CResult_ChannelShutdownStateDecodeErrorZ_get_ok(owner_conv));
5855         return ret_conv;
5856 }
5857
5858 static inline struct LDKDecodeError CResult_ChannelShutdownStateDecodeErrorZ_get_err(LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR owner){
5859 CHECK(!owner->result_ok);
5860         return DecodeError_clone(&*owner->contents.err);
5861 }
5862 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_get_err(int64_t owner) {
5863         LDKCResult_ChannelShutdownStateDecodeErrorZ* owner_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(owner);
5864         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5865         *ret_copy = CResult_ChannelShutdownStateDecodeErrorZ_get_err(owner_conv);
5866         int64_t ret_ref = tag_ptr(ret_copy, true);
5867         return ret_ref;
5868 }
5869
5870 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
5871         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
5872         for (size_t i = 0; i < ret.datalen; i++) {
5873                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
5874         }
5875         return ret;
5876 }
5877 typedef struct LDKWatch_JCalls {
5878         atomic_size_t refcnt;
5879         uint32_t instance_ptr;
5880 } LDKWatch_JCalls;
5881 static void LDKWatch_JCalls_free(void* this_arg) {
5882         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5883         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5884                 FREE(j_calls);
5885         }
5886 }
5887 LDKCResult_ChannelMonitorUpdateStatusNoneZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
5888         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5889         LDKOutPoint funding_txo_var = funding_txo;
5890         int64_t funding_txo_ref = 0;
5891         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5892         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
5893         LDKChannelMonitor monitor_var = monitor;
5894         int64_t monitor_ref = 0;
5895         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5896         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
5897         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 26, funding_txo_ref, monitor_ref);
5898         void* ret_ptr = untag_ptr(ret);
5899         CHECK_ACCESS(ret_ptr);
5900         LDKCResult_ChannelMonitorUpdateStatusNoneZ ret_conv = *(LDKCResult_ChannelMonitorUpdateStatusNoneZ*)(ret_ptr);
5901         FREE(untag_ptr(ret));
5902         return ret_conv;
5903 }
5904 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, const LDKChannelMonitorUpdate * update) {
5905         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5906         LDKOutPoint funding_txo_var = funding_txo;
5907         int64_t funding_txo_ref = 0;
5908         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5909         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
5910         LDKChannelMonitorUpdate update_var = *update;
5911         int64_t update_ref = 0;
5912         update_var = ChannelMonitorUpdate_clone(&update_var);
5913         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5914         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
5915         uint64_t ret = js_invoke_function_ChannelMonitorUpdateStatus_ll(j_calls->instance_ptr, 27, funding_txo_ref, update_ref);
5916         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_cs(ret);
5917         return ret_conv;
5918 }
5919 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5920         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5921         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 28);
5922         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
5923         ret_constr.datalen = ret->arr_len;
5924         if (ret_constr.datalen > 0)
5925                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
5926         else
5927                 ret_constr.data = NULL;
5928         int64_t* ret_vals = ret->elems;
5929         for (size_t x = 0; x < ret_constr.datalen; x++) {
5930                 int64_t ret_conv_49 = ret_vals[x];
5931                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
5932                 CHECK_ACCESS(ret_conv_49_ptr);
5933                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
5934                 FREE(untag_ptr(ret_conv_49));
5935                 ret_constr.data[x] = ret_conv_49_conv;
5936         }
5937         FREE(ret);
5938         return ret_constr;
5939 }
5940 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5941         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5942         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5943 }
5944 static inline LDKWatch LDKWatch_init (int64_t o) {
5945         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5946         atomic_init(&calls->refcnt, 1);
5947         calls->instance_ptr = o;
5948
5949         LDKWatch ret = {
5950                 .this_arg = (void*) calls,
5951                 .watch_channel = watch_channel_LDKWatch_jcall,
5952                 .update_channel = update_channel_LDKWatch_jcall,
5953                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5954                 .free = LDKWatch_JCalls_free,
5955         };
5956         return ret;
5957 }
5958 uint64_t  CS_LDK_LDKWatch_new(int32_t o) {
5959         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5960         *res_ptr = LDKWatch_init(o);
5961         return tag_ptr(res_ptr, true);
5962 }
5963 int64_t  CS_LDK_Watch_watch_channel(int64_t this_arg, int64_t funding_txo, int64_t monitor) {
5964         void* this_arg_ptr = untag_ptr(this_arg);
5965         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5966         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5967         LDKOutPoint funding_txo_conv;
5968         funding_txo_conv.inner = untag_ptr(funding_txo);
5969         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
5970         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5971         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5972         LDKChannelMonitor monitor_conv;
5973         monitor_conv.inner = untag_ptr(monitor);
5974         monitor_conv.is_owned = ptr_is_owned(monitor);
5975         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5976         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5977         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
5978         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5979         return tag_ptr(ret_conv, true);
5980 }
5981
5982 int32_t  CS_LDK_Watch_update_channel(int64_t this_arg, int64_t funding_txo, int64_t update) {
5983         void* this_arg_ptr = untag_ptr(this_arg);
5984         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5985         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5986         LDKOutPoint funding_txo_conv;
5987         funding_txo_conv.inner = untag_ptr(funding_txo);
5988         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
5989         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5990         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5991         LDKChannelMonitorUpdate update_conv;
5992         update_conv.inner = untag_ptr(update);
5993         update_conv.is_owned = ptr_is_owned(update);
5994         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5995         update_conv.is_owned = false;
5996         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs((this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, &update_conv));
5997         return ret_conv;
5998 }
5999
6000 int64_tArray  CS_LDK_Watch_release_pending_monitor_events(int64_t this_arg) {
6001         void* this_arg_ptr = untag_ptr(this_arg);
6002         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6003         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6004         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6005         int64_tArray ret_arr = NULL;
6006         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
6007         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
6008         for (size_t x = 0; x < ret_var.datalen; x++) {
6009                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
6010                 *ret_conv_49_conv = ret_var.data[x];
6011                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
6012         }
6013         
6014         FREE(ret_var.data);
6015         return ret_arr;
6016 }
6017
6018 typedef struct LDKBroadcasterInterface_JCalls {
6019         atomic_size_t refcnt;
6020         uint32_t instance_ptr;
6021 } LDKBroadcasterInterface_JCalls;
6022 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6023         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6024         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6025                 FREE(j_calls);
6026         }
6027 }
6028 void broadcast_transactions_LDKBroadcasterInterface_jcall(const void* this_arg, LDKCVec_TransactionZ txs) {
6029         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6030         LDKCVec_TransactionZ txs_var = txs;
6031         ptrArray txs_arr = NULL;
6032         txs_arr = init_ptrArray(txs_var.datalen, __LINE__);
6033         int8_tArray *txs_arr_ptr = (int8_tArray*)(((uint8_t*)txs_arr) + 8);
6034         for (size_t i = 0; i < txs_var.datalen; i++) {
6035                 LDKTransaction txs_conv_8_var = txs_var.data[i];
6036                 int8_tArray txs_conv_8_arr = init_int8_tArray(txs_conv_8_var.datalen, __LINE__);
6037                 memcpy(txs_conv_8_arr->elems, txs_conv_8_var.data, txs_conv_8_var.datalen);
6038                 Transaction_free(txs_conv_8_var);
6039                 txs_arr_ptr[i] = txs_conv_8_arr;
6040         }
6041         
6042         FREE(txs_var.data);
6043         js_invoke_function_void_l(j_calls->instance_ptr, 29, (int64_t)txs_arr);
6044 }
6045 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6046         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6047         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6048 }
6049 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (int64_t o) {
6050         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6051         atomic_init(&calls->refcnt, 1);
6052         calls->instance_ptr = o;
6053
6054         LDKBroadcasterInterface ret = {
6055                 .this_arg = (void*) calls,
6056                 .broadcast_transactions = broadcast_transactions_LDKBroadcasterInterface_jcall,
6057                 .free = LDKBroadcasterInterface_JCalls_free,
6058         };
6059         return ret;
6060 }
6061 uint64_t  CS_LDK_LDKBroadcasterInterface_new(int32_t o) {
6062         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6063         *res_ptr = LDKBroadcasterInterface_init(o);
6064         return tag_ptr(res_ptr, true);
6065 }
6066 void  CS_LDK_BroadcasterInterface_broadcast_transactions(int64_t this_arg, ptrArray txs) {
6067         void* this_arg_ptr = untag_ptr(this_arg);
6068         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6069         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6070         LDKCVec_TransactionZ txs_constr;
6071         txs_constr.datalen = txs->arr_len;
6072         if (txs_constr.datalen > 0)
6073                 txs_constr.data = MALLOC(txs_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
6074         else
6075                 txs_constr.data = NULL;
6076         int8_tArray* txs_vals = (void*) txs->elems;
6077         for (size_t i = 0; i < txs_constr.datalen; i++) {
6078                 int8_tArray txs_conv_8 = txs_vals[i];
6079                 LDKTransaction txs_conv_8_ref;
6080                 txs_conv_8_ref.datalen = txs_conv_8->arr_len;
6081                 txs_conv_8_ref.data = MALLOC(txs_conv_8_ref.datalen, "LDKTransaction Bytes");
6082                 memcpy(txs_conv_8_ref.data, txs_conv_8->elems, txs_conv_8_ref.datalen); FREE(txs_conv_8);
6083                 txs_conv_8_ref.data_is_owned = true;
6084                 txs_constr.data[i] = txs_conv_8_ref;
6085         }
6086         FREE(txs);
6087         (this_arg_conv->broadcast_transactions)(this_arg_conv->this_arg, txs_constr);
6088 }
6089
6090 typedef struct LDKEntropySource_JCalls {
6091         atomic_size_t refcnt;
6092         uint32_t instance_ptr;
6093 } LDKEntropySource_JCalls;
6094 static void LDKEntropySource_JCalls_free(void* this_arg) {
6095         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
6096         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6097                 FREE(j_calls);
6098         }
6099 }
6100 LDKThirtyTwoBytes get_secure_random_bytes_LDKEntropySource_jcall(const void* this_arg) {
6101         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) this_arg;
6102         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 30);
6103         LDKThirtyTwoBytes ret_ref;
6104         CHECK(ret->arr_len == 32);
6105         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6106         return ret_ref;
6107 }
6108 static void LDKEntropySource_JCalls_cloned(LDKEntropySource* new_obj) {
6109         LDKEntropySource_JCalls *j_calls = (LDKEntropySource_JCalls*) new_obj->this_arg;
6110         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6111 }
6112 static inline LDKEntropySource LDKEntropySource_init (int64_t o) {
6113         LDKEntropySource_JCalls *calls = MALLOC(sizeof(LDKEntropySource_JCalls), "LDKEntropySource_JCalls");
6114         atomic_init(&calls->refcnt, 1);
6115         calls->instance_ptr = o;
6116
6117         LDKEntropySource ret = {
6118                 .this_arg = (void*) calls,
6119                 .get_secure_random_bytes = get_secure_random_bytes_LDKEntropySource_jcall,
6120                 .free = LDKEntropySource_JCalls_free,
6121         };
6122         return ret;
6123 }
6124 uint64_t  CS_LDK_LDKEntropySource_new(int32_t o) {
6125         LDKEntropySource *res_ptr = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
6126         *res_ptr = LDKEntropySource_init(o);
6127         return tag_ptr(res_ptr, true);
6128 }
6129 int8_tArray  CS_LDK_EntropySource_get_secure_random_bytes(int64_t this_arg) {
6130         void* this_arg_ptr = untag_ptr(this_arg);
6131         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6132         LDKEntropySource* this_arg_conv = (LDKEntropySource*)this_arg_ptr;
6133         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6134         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
6135         return ret_arr;
6136 }
6137
6138 uint32_t CS_LDK_LDKUnsignedGossipMessage_ty_from_ptr(int64_t ptr) {
6139         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6140         switch(obj->tag) {
6141                 case LDKUnsignedGossipMessage_ChannelAnnouncement: return 0;
6142                 case LDKUnsignedGossipMessage_ChannelUpdate: return 1;
6143                 case LDKUnsignedGossipMessage_NodeAnnouncement: return 2;
6144                 default: abort();
6145         }
6146 }
6147 int64_t CS_LDK_LDKUnsignedGossipMessage_ChannelAnnouncement_get_channel_announcement(int64_t ptr) {
6148         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6149         CHECK(obj->tag == LDKUnsignedGossipMessage_ChannelAnnouncement);
6150         LDKUnsignedChannelAnnouncement channel_announcement_var = obj->channel_announcement;
6151                         int64_t channel_announcement_ref = 0;
6152                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_announcement_var);
6153                         channel_announcement_ref = tag_ptr(channel_announcement_var.inner, false);
6154         return channel_announcement_ref;
6155 }
6156 int64_t CS_LDK_LDKUnsignedGossipMessage_ChannelUpdate_get_channel_update(int64_t ptr) {
6157         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6158         CHECK(obj->tag == LDKUnsignedGossipMessage_ChannelUpdate);
6159         LDKUnsignedChannelUpdate channel_update_var = obj->channel_update;
6160                         int64_t channel_update_ref = 0;
6161                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_update_var);
6162                         channel_update_ref = tag_ptr(channel_update_var.inner, false);
6163         return channel_update_ref;
6164 }
6165 int64_t CS_LDK_LDKUnsignedGossipMessage_NodeAnnouncement_get_node_announcement(int64_t ptr) {
6166         LDKUnsignedGossipMessage *obj = (LDKUnsignedGossipMessage*)untag_ptr(ptr);
6167         CHECK(obj->tag == LDKUnsignedGossipMessage_NodeAnnouncement);
6168         LDKUnsignedNodeAnnouncement node_announcement_var = obj->node_announcement;
6169                         int64_t node_announcement_ref = 0;
6170                         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_announcement_var);
6171                         node_announcement_ref = tag_ptr(node_announcement_var.inner, false);
6172         return node_announcement_ref;
6173 }
6174 typedef struct LDKNodeSigner_JCalls {
6175         atomic_size_t refcnt;
6176         uint32_t instance_ptr;
6177 } LDKNodeSigner_JCalls;
6178 static void LDKNodeSigner_JCalls_free(void* this_arg) {
6179         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6180         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6181                 FREE(j_calls);
6182         }
6183 }
6184 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKNodeSigner_jcall(const void* this_arg) {
6185         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6186         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 31);
6187         LDKThirtyTwoBytes ret_ref;
6188         CHECK(ret->arr_len == 32);
6189         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6190         return ret_ref;
6191 }
6192 LDKCResult_PublicKeyNoneZ get_node_id_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient) {
6193         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6194         int32_t recipient_conv = LDKRecipient_to_cs(recipient);
6195         uint64_t ret = js_invoke_function_l_Recipient(j_calls->instance_ptr, 32, recipient_conv);
6196         void* ret_ptr = untag_ptr(ret);
6197         CHECK_ACCESS(ret_ptr);
6198         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
6199         FREE(untag_ptr(ret));
6200         return ret_conv;
6201 }
6202 LDKCResult_ThirtyTwoBytesNoneZ ecdh_LDKNodeSigner_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_BigEndianScalarZ tweak) {
6203         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6204         int32_t recipient_conv = LDKRecipient_to_cs(recipient);
6205         int8_tArray other_key_arr = init_int8_tArray(33, __LINE__);
6206         memcpy(other_key_arr->elems, other_key.compressed_form, 33);
6207         LDKCOption_BigEndianScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
6208         *tweak_copy = tweak;
6209         int64_t tweak_ref = tag_ptr(tweak_copy, true);
6210         uint64_t ret = js_invoke_function_l_Recipientll(j_calls->instance_ptr, 33, recipient_conv, (int64_t)other_key_arr, tweak_ref);
6211         void* ret_ptr = untag_ptr(ret);
6212         CHECK_ACCESS(ret_ptr);
6213         LDKCResult_ThirtyTwoBytesNoneZ ret_conv = *(LDKCResult_ThirtyTwoBytesNoneZ*)(ret_ptr);
6214         FREE(untag_ptr(ret));
6215         return ret_conv;
6216 }
6217 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKNodeSigner_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_U5Z invoice_data, LDKRecipient recipient) {
6218         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6219         LDKu8slice hrp_bytes_var = hrp_bytes;
6220         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
6221         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
6222         LDKCVec_U5Z invoice_data_var = invoice_data;
6223         ptrArray invoice_data_arr = NULL;
6224         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
6225         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 8);
6226         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
6227                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
6228                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
6229         }
6230         
6231         FREE(invoice_data_var.data);
6232         int32_t recipient_conv = LDKRecipient_to_cs(recipient);
6233         uint64_t ret = js_invoke_function_l_llRecipient(j_calls->instance_ptr, 34, (int64_t)hrp_bytes_arr, (int64_t)invoice_data_arr, recipient_conv);
6234         void* ret_ptr = untag_ptr(ret);
6235         CHECK_ACCESS(ret_ptr);
6236         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6237         FREE(untag_ptr(ret));
6238         return ret_conv;
6239 }
6240 LDKCResult_SchnorrSignatureNoneZ sign_bolt12_invoice_request_LDKNodeSigner_jcall(const void* this_arg, const LDKUnsignedInvoiceRequest * invoice_request) {
6241         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6242         LDKUnsignedInvoiceRequest invoice_request_var = *invoice_request;
6243         int64_t invoice_request_ref = 0;
6244         // WARNING: we may need a move here but no clone is available for LDKUnsignedInvoiceRequest
6245         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_request_var);
6246         invoice_request_ref = tag_ptr(invoice_request_var.inner, invoice_request_var.is_owned);
6247         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 35, invoice_request_ref);
6248         void* ret_ptr = untag_ptr(ret);
6249         CHECK_ACCESS(ret_ptr);
6250         LDKCResult_SchnorrSignatureNoneZ ret_conv = *(LDKCResult_SchnorrSignatureNoneZ*)(ret_ptr);
6251         FREE(untag_ptr(ret));
6252         return ret_conv;
6253 }
6254 LDKCResult_SchnorrSignatureNoneZ sign_bolt12_invoice_LDKNodeSigner_jcall(const void* this_arg, const LDKUnsignedBolt12Invoice * invoice) {
6255         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6256         LDKUnsignedBolt12Invoice invoice_var = *invoice;
6257         int64_t invoice_ref = 0;
6258         // WARNING: we may need a move here but no clone is available for LDKUnsignedBolt12Invoice
6259         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_var);
6260         invoice_ref = tag_ptr(invoice_var.inner, invoice_var.is_owned);
6261         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 36, invoice_ref);
6262         void* ret_ptr = untag_ptr(ret);
6263         CHECK_ACCESS(ret_ptr);
6264         LDKCResult_SchnorrSignatureNoneZ ret_conv = *(LDKCResult_SchnorrSignatureNoneZ*)(ret_ptr);
6265         FREE(untag_ptr(ret));
6266         return ret_conv;
6267 }
6268 LDKCResult_ECDSASignatureNoneZ sign_gossip_message_LDKNodeSigner_jcall(const void* this_arg, LDKUnsignedGossipMessage msg) {
6269         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) this_arg;
6270         LDKUnsignedGossipMessage *msg_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
6271         *msg_copy = msg;
6272         int64_t msg_ref = tag_ptr(msg_copy, true);
6273         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 37, msg_ref);
6274         void* ret_ptr = untag_ptr(ret);
6275         CHECK_ACCESS(ret_ptr);
6276         LDKCResult_ECDSASignatureNoneZ ret_conv = *(LDKCResult_ECDSASignatureNoneZ*)(ret_ptr);
6277         FREE(untag_ptr(ret));
6278         return ret_conv;
6279 }
6280 static void LDKNodeSigner_JCalls_cloned(LDKNodeSigner* new_obj) {
6281         LDKNodeSigner_JCalls *j_calls = (LDKNodeSigner_JCalls*) new_obj->this_arg;
6282         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6283 }
6284 static inline LDKNodeSigner LDKNodeSigner_init (int64_t o) {
6285         LDKNodeSigner_JCalls *calls = MALLOC(sizeof(LDKNodeSigner_JCalls), "LDKNodeSigner_JCalls");
6286         atomic_init(&calls->refcnt, 1);
6287         calls->instance_ptr = o;
6288
6289         LDKNodeSigner ret = {
6290                 .this_arg = (void*) calls,
6291                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKNodeSigner_jcall,
6292                 .get_node_id = get_node_id_LDKNodeSigner_jcall,
6293                 .ecdh = ecdh_LDKNodeSigner_jcall,
6294                 .sign_invoice = sign_invoice_LDKNodeSigner_jcall,
6295                 .sign_bolt12_invoice_request = sign_bolt12_invoice_request_LDKNodeSigner_jcall,
6296                 .sign_bolt12_invoice = sign_bolt12_invoice_LDKNodeSigner_jcall,
6297                 .sign_gossip_message = sign_gossip_message_LDKNodeSigner_jcall,
6298                 .free = LDKNodeSigner_JCalls_free,
6299         };
6300         return ret;
6301 }
6302 uint64_t  CS_LDK_LDKNodeSigner_new(int32_t o) {
6303         LDKNodeSigner *res_ptr = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
6304         *res_ptr = LDKNodeSigner_init(o);
6305         return tag_ptr(res_ptr, true);
6306 }
6307 int8_tArray  CS_LDK_NodeSigner_get_inbound_payment_key_material(int64_t this_arg) {
6308         void* this_arg_ptr = untag_ptr(this_arg);
6309         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6310         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6311         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6312         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
6313         return ret_arr;
6314 }
6315
6316 int64_t  CS_LDK_NodeSigner_get_node_id(int64_t this_arg, int32_t recipient) {
6317         void* this_arg_ptr = untag_ptr(this_arg);
6318         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6319         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6320         LDKRecipient recipient_conv = LDKRecipient_from_cs(recipient);
6321         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
6322         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
6323         return tag_ptr(ret_conv, true);
6324 }
6325
6326 int64_t  CS_LDK_NodeSigner_ecdh(int64_t this_arg, int32_t recipient, int8_tArray other_key, int64_t tweak) {
6327         void* this_arg_ptr = untag_ptr(this_arg);
6328         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6329         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6330         LDKRecipient recipient_conv = LDKRecipient_from_cs(recipient);
6331         LDKPublicKey other_key_ref;
6332         CHECK(other_key->arr_len == 33);
6333         memcpy(other_key_ref.compressed_form, other_key->elems, 33); FREE(other_key);
6334         void* tweak_ptr = untag_ptr(tweak);
6335         CHECK_ACCESS(tweak_ptr);
6336         LDKCOption_BigEndianScalarZ tweak_conv = *(LDKCOption_BigEndianScalarZ*)(tweak_ptr);
6337         tweak_conv = COption_BigEndianScalarZ_clone((LDKCOption_BigEndianScalarZ*)untag_ptr(tweak));
6338         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
6339         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
6340         return tag_ptr(ret_conv, true);
6341 }
6342
6343 int64_t  CS_LDK_NodeSigner_sign_invoice(int64_t this_arg, int8_tArray hrp_bytes, ptrArray invoice_data, int32_t recipient) {
6344         void* this_arg_ptr = untag_ptr(this_arg);
6345         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6346         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6347         LDKu8slice hrp_bytes_ref;
6348         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
6349         hrp_bytes_ref.data = hrp_bytes->elems;
6350         LDKCVec_U5Z invoice_data_constr;
6351         invoice_data_constr.datalen = invoice_data->arr_len;
6352         if (invoice_data_constr.datalen > 0)
6353                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
6354         else
6355                 invoice_data_constr.data = NULL;
6356         int8_t* invoice_data_vals = (void*) invoice_data->elems;
6357         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
6358                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
6359                 
6360                 invoice_data_constr.data[h] = (LDKU5){ ._0 = invoice_data_conv_7 };
6361         }
6362         FREE(invoice_data);
6363         LDKRecipient recipient_conv = LDKRecipient_from_cs(recipient);
6364         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6365         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, recipient_conv);
6366         FREE(hrp_bytes);
6367         return tag_ptr(ret_conv, true);
6368 }
6369
6370 int64_t  CS_LDK_NodeSigner_sign_bolt12_invoice_request(int64_t this_arg, int64_t invoice_request) {
6371         void* this_arg_ptr = untag_ptr(this_arg);
6372         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6373         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6374         LDKUnsignedInvoiceRequest invoice_request_conv;
6375         invoice_request_conv.inner = untag_ptr(invoice_request);
6376         invoice_request_conv.is_owned = ptr_is_owned(invoice_request);
6377         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_request_conv);
6378         invoice_request_conv.is_owned = false;
6379         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
6380         *ret_conv = (this_arg_conv->sign_bolt12_invoice_request)(this_arg_conv->this_arg, &invoice_request_conv);
6381         return tag_ptr(ret_conv, true);
6382 }
6383
6384 int64_t  CS_LDK_NodeSigner_sign_bolt12_invoice(int64_t this_arg, int64_t invoice) {
6385         void* this_arg_ptr = untag_ptr(this_arg);
6386         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6387         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6388         LDKUnsignedBolt12Invoice invoice_conv;
6389         invoice_conv.inner = untag_ptr(invoice);
6390         invoice_conv.is_owned = ptr_is_owned(invoice);
6391         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
6392         invoice_conv.is_owned = false;
6393         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
6394         *ret_conv = (this_arg_conv->sign_bolt12_invoice)(this_arg_conv->this_arg, &invoice_conv);
6395         return tag_ptr(ret_conv, true);
6396 }
6397
6398 int64_t  CS_LDK_NodeSigner_sign_gossip_message(int64_t this_arg, int64_t msg) {
6399         void* this_arg_ptr = untag_ptr(this_arg);
6400         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6401         LDKNodeSigner* this_arg_conv = (LDKNodeSigner*)this_arg_ptr;
6402         void* msg_ptr = untag_ptr(msg);
6403         CHECK_ACCESS(msg_ptr);
6404         LDKUnsignedGossipMessage msg_conv = *(LDKUnsignedGossipMessage*)(msg_ptr);
6405         msg_conv = UnsignedGossipMessage_clone((LDKUnsignedGossipMessage*)untag_ptr(msg));
6406         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
6407         *ret_conv = (this_arg_conv->sign_gossip_message)(this_arg_conv->this_arg, msg_conv);
6408         return tag_ptr(ret_conv, true);
6409 }
6410
6411 typedef struct LDKSignerProvider_JCalls {
6412         atomic_size_t refcnt;
6413         uint32_t instance_ptr;
6414 } LDKSignerProvider_JCalls;
6415 static void LDKSignerProvider_JCalls_free(void* this_arg) {
6416         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6417         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6418                 FREE(j_calls);
6419         }
6420 }
6421 LDKThirtyTwoBytes generate_channel_keys_id_LDKSignerProvider_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis, LDKU128 user_channel_id) {
6422         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6423         jboolean inbound_conv = inbound;
6424         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6425         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
6426         memcpy(user_channel_id_arr->elems, user_channel_id.le_bytes, 16);
6427         int8_tArray ret = (int8_tArray)js_invoke_function_l_bll(j_calls->instance_ptr, 38, inbound_conv, channel_value_satoshis_conv, (int64_t)user_channel_id_arr);
6428         LDKThirtyTwoBytes ret_ref;
6429         CHECK(ret->arr_len == 32);
6430         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6431         return ret_ref;
6432 }
6433 LDKWriteableEcdsaChannelSigner derive_channel_signer_LDKSignerProvider_jcall(const void* this_arg, uint64_t channel_value_satoshis, LDKThirtyTwoBytes channel_keys_id) {
6434         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6435         int64_t channel_value_satoshis_conv = channel_value_satoshis;
6436         int8_tArray channel_keys_id_arr = init_int8_tArray(32, __LINE__);
6437         memcpy(channel_keys_id_arr->elems, channel_keys_id.data, 32);
6438         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 39, channel_value_satoshis_conv, (int64_t)channel_keys_id_arr);
6439         void* ret_ptr = untag_ptr(ret);
6440         CHECK_ACCESS(ret_ptr);
6441         LDKWriteableEcdsaChannelSigner ret_conv = *(LDKWriteableEcdsaChannelSigner*)(ret_ptr);
6442         FREE(untag_ptr(ret));
6443         return ret_conv;
6444 }
6445 LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ read_chan_signer_LDKSignerProvider_jcall(const void* this_arg, LDKu8slice reader) {
6446         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6447         LDKu8slice reader_var = reader;
6448         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
6449         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
6450         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 40, (int64_t)reader_arr);
6451         void* ret_ptr = untag_ptr(ret);
6452         CHECK_ACCESS(ret_ptr);
6453         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ ret_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(ret_ptr);
6454         FREE(untag_ptr(ret));
6455         return ret_conv;
6456 }
6457 LDKCResult_CVec_u8ZNoneZ get_destination_script_LDKSignerProvider_jcall(const void* this_arg) {
6458         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6459         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 41);
6460         void* ret_ptr = untag_ptr(ret);
6461         CHECK_ACCESS(ret_ptr);
6462         LDKCResult_CVec_u8ZNoneZ ret_conv = *(LDKCResult_CVec_u8ZNoneZ*)(ret_ptr);
6463         FREE(untag_ptr(ret));
6464         return ret_conv;
6465 }
6466 LDKCResult_ShutdownScriptNoneZ get_shutdown_scriptpubkey_LDKSignerProvider_jcall(const void* this_arg) {
6467         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) this_arg;
6468         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 42);
6469         void* ret_ptr = untag_ptr(ret);
6470         CHECK_ACCESS(ret_ptr);
6471         LDKCResult_ShutdownScriptNoneZ ret_conv = *(LDKCResult_ShutdownScriptNoneZ*)(ret_ptr);
6472         FREE(untag_ptr(ret));
6473         return ret_conv;
6474 }
6475 static void LDKSignerProvider_JCalls_cloned(LDKSignerProvider* new_obj) {
6476         LDKSignerProvider_JCalls *j_calls = (LDKSignerProvider_JCalls*) new_obj->this_arg;
6477         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6478 }
6479 static inline LDKSignerProvider LDKSignerProvider_init (int64_t o) {
6480         LDKSignerProvider_JCalls *calls = MALLOC(sizeof(LDKSignerProvider_JCalls), "LDKSignerProvider_JCalls");
6481         atomic_init(&calls->refcnt, 1);
6482         calls->instance_ptr = o;
6483
6484         LDKSignerProvider ret = {
6485                 .this_arg = (void*) calls,
6486                 .generate_channel_keys_id = generate_channel_keys_id_LDKSignerProvider_jcall,
6487                 .derive_channel_signer = derive_channel_signer_LDKSignerProvider_jcall,
6488                 .read_chan_signer = read_chan_signer_LDKSignerProvider_jcall,
6489                 .get_destination_script = get_destination_script_LDKSignerProvider_jcall,
6490                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKSignerProvider_jcall,
6491                 .free = LDKSignerProvider_JCalls_free,
6492         };
6493         return ret;
6494 }
6495 uint64_t  CS_LDK_LDKSignerProvider_new(int32_t o) {
6496         LDKSignerProvider *res_ptr = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
6497         *res_ptr = LDKSignerProvider_init(o);
6498         return tag_ptr(res_ptr, true);
6499 }
6500 int8_tArray  CS_LDK_SignerProvider_generate_channel_keys_id(int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis, int8_tArray user_channel_id) {
6501         void* this_arg_ptr = untag_ptr(this_arg);
6502         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6503         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6504         LDKU128 user_channel_id_ref;
6505         CHECK(user_channel_id->arr_len == 16);
6506         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
6507         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6508         memcpy(ret_arr->elems, (this_arg_conv->generate_channel_keys_id)(this_arg_conv->this_arg, inbound, channel_value_satoshis, user_channel_id_ref).data, 32);
6509         return ret_arr;
6510 }
6511
6512 int64_t  CS_LDK_SignerProvider_derive_channel_signer(int64_t this_arg, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
6513         void* this_arg_ptr = untag_ptr(this_arg);
6514         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6515         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6516         LDKThirtyTwoBytes channel_keys_id_ref;
6517         CHECK(channel_keys_id->arr_len == 32);
6518         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
6519         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
6520         *ret_ret = (this_arg_conv->derive_channel_signer)(this_arg_conv->this_arg, channel_value_satoshis, channel_keys_id_ref);
6521         return tag_ptr(ret_ret, true);
6522 }
6523
6524 int64_t  CS_LDK_SignerProvider_read_chan_signer(int64_t this_arg, int8_tArray reader) {
6525         void* this_arg_ptr = untag_ptr(this_arg);
6526         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6527         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6528         LDKu8slice reader_ref;
6529         reader_ref.datalen = reader->arr_len;
6530         reader_ref.data = reader->elems;
6531         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
6532         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6533         FREE(reader);
6534         return tag_ptr(ret_conv, true);
6535 }
6536
6537 int64_t  CS_LDK_SignerProvider_get_destination_script(int64_t this_arg) {
6538         void* this_arg_ptr = untag_ptr(this_arg);
6539         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6540         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6541         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
6542         *ret_conv = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6543         return tag_ptr(ret_conv, true);
6544 }
6545
6546 int64_t  CS_LDK_SignerProvider_get_shutdown_scriptpubkey(int64_t this_arg) {
6547         void* this_arg_ptr = untag_ptr(this_arg);
6548         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6549         LDKSignerProvider* this_arg_conv = (LDKSignerProvider*)this_arg_ptr;
6550         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
6551         *ret_conv = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6552         return tag_ptr(ret_conv, true);
6553 }
6554
6555 typedef struct LDKFeeEstimator_JCalls {
6556         atomic_size_t refcnt;
6557         uint32_t instance_ptr;
6558 } LDKFeeEstimator_JCalls;
6559 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6560         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6561         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6562                 FREE(j_calls);
6563         }
6564 }
6565 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6566         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6567         int32_t confirmation_target_conv = LDKConfirmationTarget_to_cs(confirmation_target);
6568         return js_invoke_function_i_ConfirmationTarget(j_calls->instance_ptr, 43, confirmation_target_conv);
6569 }
6570 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6571         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6572         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6573 }
6574 static inline LDKFeeEstimator LDKFeeEstimator_init (int64_t o) {
6575         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6576         atomic_init(&calls->refcnt, 1);
6577         calls->instance_ptr = o;
6578
6579         LDKFeeEstimator ret = {
6580                 .this_arg = (void*) calls,
6581                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6582                 .free = LDKFeeEstimator_JCalls_free,
6583         };
6584         return ret;
6585 }
6586 uint64_t  CS_LDK_LDKFeeEstimator_new(int32_t o) {
6587         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6588         *res_ptr = LDKFeeEstimator_init(o);
6589         return tag_ptr(res_ptr, true);
6590 }
6591 int32_t  CS_LDK_FeeEstimator_get_est_sat_per_1000_weight(int64_t this_arg, int32_t confirmation_target) {
6592         void* this_arg_ptr = untag_ptr(this_arg);
6593         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6594         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6595         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_cs(confirmation_target);
6596         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6597         return ret_conv;
6598 }
6599
6600 typedef struct LDKRouter_JCalls {
6601         atomic_size_t refcnt;
6602         uint32_t instance_ptr;
6603 } LDKRouter_JCalls;
6604 static void LDKRouter_JCalls_free(void* this_arg) {
6605         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
6606         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6607                 FREE(j_calls);
6608         }
6609 }
6610 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
6611         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
6612         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
6613         memcpy(payer_arr->elems, payer.compressed_form, 33);
6614         LDKRouteParameters route_params_var = *route_params;
6615         int64_t route_params_ref = 0;
6616         route_params_var = RouteParameters_clone(&route_params_var);
6617         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
6618         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
6619         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
6620         int64_tArray first_hops_arr = NULL;
6621         if (first_hops != NULL) {
6622                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
6623                 first_hops_arr = init_int64_tArray(first_hops_var.datalen, __LINE__);
6624                 int64_t *first_hops_arr_ptr = (int64_t*)(((uint8_t*)first_hops_arr) + 8);
6625                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
6626                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
6627                         int64_t first_hops_conv_16_ref = 0;
6628                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
6629                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
6630                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
6631                 }
6632         
6633         }
6634         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
6635         int64_t inflight_htlcs_ref = 0;
6636         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
6637         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
6638         uint64_t ret = js_invoke_function_l_llll(j_calls->instance_ptr, 44, (int64_t)payer_arr, route_params_ref, (int64_t)first_hops_arr, inflight_htlcs_ref);
6639         void* ret_ptr = untag_ptr(ret);
6640         CHECK_ACCESS(ret_ptr);
6641         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
6642         FREE(untag_ptr(ret));
6643         return ret_conv;
6644 }
6645 LDKCResult_RouteLightningErrorZ find_route_with_id_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs, LDKThirtyTwoBytes _payment_hash, LDKThirtyTwoBytes _payment_id) {
6646         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
6647         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
6648         memcpy(payer_arr->elems, payer.compressed_form, 33);
6649         LDKRouteParameters route_params_var = *route_params;
6650         int64_t route_params_ref = 0;
6651         route_params_var = RouteParameters_clone(&route_params_var);
6652         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
6653         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
6654         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
6655         int64_tArray first_hops_arr = NULL;
6656         if (first_hops != NULL) {
6657                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
6658                 first_hops_arr = init_int64_tArray(first_hops_var.datalen, __LINE__);
6659                 int64_t *first_hops_arr_ptr = (int64_t*)(((uint8_t*)first_hops_arr) + 8);
6660                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
6661                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
6662                         int64_t first_hops_conv_16_ref = 0;
6663                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
6664                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
6665                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
6666                 }
6667         
6668         }
6669         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
6670         int64_t inflight_htlcs_ref = 0;
6671         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
6672         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
6673         int8_tArray _payment_hash_arr = init_int8_tArray(32, __LINE__);
6674         memcpy(_payment_hash_arr->elems, _payment_hash.data, 32);
6675         int8_tArray _payment_id_arr = init_int8_tArray(32, __LINE__);
6676         memcpy(_payment_id_arr->elems, _payment_id.data, 32);
6677         uint64_t ret = js_invoke_function_l_llllll(j_calls->instance_ptr, 45, (int64_t)payer_arr, route_params_ref, (int64_t)first_hops_arr, inflight_htlcs_ref, (int64_t)_payment_hash_arr, (int64_t)_payment_id_arr);
6678         void* ret_ptr = untag_ptr(ret);
6679         CHECK_ACCESS(ret_ptr);
6680         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
6681         FREE(untag_ptr(ret));
6682         return ret_conv;
6683 }
6684 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
6685         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
6686         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6687 }
6688 static inline LDKRouter LDKRouter_init (int64_t o) {
6689         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
6690         atomic_init(&calls->refcnt, 1);
6691         calls->instance_ptr = o;
6692
6693         LDKRouter ret = {
6694                 .this_arg = (void*) calls,
6695                 .find_route = find_route_LDKRouter_jcall,
6696                 .find_route_with_id = find_route_with_id_LDKRouter_jcall,
6697                 .free = LDKRouter_JCalls_free,
6698         };
6699         return ret;
6700 }
6701 uint64_t  CS_LDK_LDKRouter_new(int32_t o) {
6702         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
6703         *res_ptr = LDKRouter_init(o);
6704         return tag_ptr(res_ptr, true);
6705 }
6706 int64_t  CS_LDK_Router_find_route(int64_t this_arg, int8_tArray payer, int64_t route_params, int64_tArray first_hops, int64_t inflight_htlcs) {
6707         void* this_arg_ptr = untag_ptr(this_arg);
6708         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6709         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
6710         LDKPublicKey payer_ref;
6711         CHECK(payer->arr_len == 33);
6712         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
6713         LDKRouteParameters route_params_conv;
6714         route_params_conv.inner = untag_ptr(route_params);
6715         route_params_conv.is_owned = ptr_is_owned(route_params);
6716         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
6717         route_params_conv.is_owned = false;
6718         LDKCVec_ChannelDetailsZ first_hops_constr;
6719         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
6720         if (first_hops != NULL) {
6721                 first_hops_constr.datalen = first_hops->arr_len;
6722                 if (first_hops_constr.datalen > 0)
6723                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
6724                 else
6725                         first_hops_constr.data = NULL;
6726                 int64_t* first_hops_vals = first_hops->elems;
6727                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
6728                         int64_t first_hops_conv_16 = first_hops_vals[q];
6729                         LDKChannelDetails first_hops_conv_16_conv;
6730                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
6731                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
6732                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
6733                         first_hops_conv_16_conv.is_owned = false;
6734                         first_hops_constr.data[q] = first_hops_conv_16_conv;
6735                 }
6736                 FREE(first_hops);
6737                 first_hops_ptr = &first_hops_constr;
6738         }
6739         LDKInFlightHtlcs inflight_htlcs_conv;
6740         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
6741         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
6742         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
6743         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
6744         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6745         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv);
6746         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
6747         return tag_ptr(ret_conv, true);
6748 }
6749
6750 int64_t  CS_LDK_Router_find_route_with_id(int64_t this_arg, int8_tArray payer, int64_t route_params, int64_tArray first_hops, int64_t inflight_htlcs, int8_tArray _payment_hash, int8_tArray _payment_id) {
6751         void* this_arg_ptr = untag_ptr(this_arg);
6752         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6753         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
6754         LDKPublicKey payer_ref;
6755         CHECK(payer->arr_len == 33);
6756         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
6757         LDKRouteParameters route_params_conv;
6758         route_params_conv.inner = untag_ptr(route_params);
6759         route_params_conv.is_owned = ptr_is_owned(route_params);
6760         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
6761         route_params_conv.is_owned = false;
6762         LDKCVec_ChannelDetailsZ first_hops_constr;
6763         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
6764         if (first_hops != NULL) {
6765                 first_hops_constr.datalen = first_hops->arr_len;
6766                 if (first_hops_constr.datalen > 0)
6767                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
6768                 else
6769                         first_hops_constr.data = NULL;
6770                 int64_t* first_hops_vals = first_hops->elems;
6771                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
6772                         int64_t first_hops_conv_16 = first_hops_vals[q];
6773                         LDKChannelDetails first_hops_conv_16_conv;
6774                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
6775                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
6776                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
6777                         first_hops_conv_16_conv.is_owned = false;
6778                         first_hops_constr.data[q] = first_hops_conv_16_conv;
6779                 }
6780                 FREE(first_hops);
6781                 first_hops_ptr = &first_hops_constr;
6782         }
6783         LDKInFlightHtlcs inflight_htlcs_conv;
6784         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
6785         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
6786         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
6787         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
6788         LDKThirtyTwoBytes _payment_hash_ref;
6789         CHECK(_payment_hash->arr_len == 32);
6790         memcpy(_payment_hash_ref.data, _payment_hash->elems, 32); FREE(_payment_hash);
6791         LDKThirtyTwoBytes _payment_id_ref;
6792         CHECK(_payment_id->arr_len == 32);
6793         memcpy(_payment_id_ref.data, _payment_id->elems, 32); FREE(_payment_id);
6794         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6795         *ret_conv = (this_arg_conv->find_route_with_id)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv, _payment_hash_ref, _payment_id_ref);
6796         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
6797         return tag_ptr(ret_conv, true);
6798 }
6799
6800 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesChannelManagerZ_get_a(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ *NONNULL_PTR owner){
6801         return ThirtyTwoBytes_clone(&owner->a);
6802 }
6803 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_get_a(int64_t owner) {
6804         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)untag_ptr(owner);
6805         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6806         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesChannelManagerZ_get_a(owner_conv).data, 32);
6807         return ret_arr;
6808 }
6809
6810 static inline struct LDKChannelManager C2Tuple_ThirtyTwoBytesChannelManagerZ_get_b(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ *NONNULL_PTR owner){
6811         LDKChannelManager ret = owner->b;
6812         ret.is_owned = false;
6813         return ret;
6814 }
6815 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_get_b(int64_t owner) {
6816         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)untag_ptr(owner);
6817         LDKChannelManager ret_var = C2Tuple_ThirtyTwoBytesChannelManagerZ_get_b(owner_conv);
6818         int64_t ret_ref = 0;
6819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6820         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6821         return ret_ref;
6822 }
6823
6824 static inline struct LDKC2Tuple_ThirtyTwoBytesChannelManagerZ *CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6825 CHECK(owner->result_ok);
6826         return &*owner->contents.result;
6827 }
6828 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_ok(int64_t owner) {
6829         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)untag_ptr(owner);
6830         int64_t ret_ret = tag_ptr(CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
6831         return ret_ret;
6832 }
6833
6834 static inline struct LDKDecodeError CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6835 CHECK(!owner->result_ok);
6836         return DecodeError_clone(&*owner->contents.err);
6837 }
6838 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_err(int64_t owner) {
6839         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)untag_ptr(owner);
6840         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6841         *ret_copy = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_get_err(owner_conv);
6842         int64_t ret_ref = tag_ptr(ret_copy, true);
6843         return ret_ref;
6844 }
6845
6846 uint32_t CS_LDK_LDKMaxDustHTLCExposure_ty_from_ptr(int64_t ptr) {
6847         LDKMaxDustHTLCExposure *obj = (LDKMaxDustHTLCExposure*)untag_ptr(ptr);
6848         switch(obj->tag) {
6849                 case LDKMaxDustHTLCExposure_FixedLimitMsat: return 0;
6850                 case LDKMaxDustHTLCExposure_FeeRateMultiplier: return 1;
6851                 default: abort();
6852         }
6853 }
6854 int64_t CS_LDK_LDKMaxDustHTLCExposure_FixedLimitMsat_get_fixed_limit_msat(int64_t ptr) {
6855         LDKMaxDustHTLCExposure *obj = (LDKMaxDustHTLCExposure*)untag_ptr(ptr);
6856         CHECK(obj->tag == LDKMaxDustHTLCExposure_FixedLimitMsat);
6857         int64_t fixed_limit_msat_conv = obj->fixed_limit_msat;
6858         return fixed_limit_msat_conv;
6859 }
6860 int64_t CS_LDK_LDKMaxDustHTLCExposure_FeeRateMultiplier_get_fee_rate_multiplier(int64_t ptr) {
6861         LDKMaxDustHTLCExposure *obj = (LDKMaxDustHTLCExposure*)untag_ptr(ptr);
6862         CHECK(obj->tag == LDKMaxDustHTLCExposure_FeeRateMultiplier);
6863         int64_t fee_rate_multiplier_conv = obj->fee_rate_multiplier;
6864         return fee_rate_multiplier_conv;
6865 }
6866 static inline struct LDKMaxDustHTLCExposure CResult_MaxDustHTLCExposureDecodeErrorZ_get_ok(LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR owner){
6867 CHECK(owner->result_ok);
6868         return MaxDustHTLCExposure_clone(&*owner->contents.result);
6869 }
6870 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_get_ok(int64_t owner) {
6871         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* owner_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(owner);
6872         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
6873         *ret_copy = CResult_MaxDustHTLCExposureDecodeErrorZ_get_ok(owner_conv);
6874         int64_t ret_ref = tag_ptr(ret_copy, true);
6875         return ret_ref;
6876 }
6877
6878 static inline struct LDKDecodeError CResult_MaxDustHTLCExposureDecodeErrorZ_get_err(LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR owner){
6879 CHECK(!owner->result_ok);
6880         return DecodeError_clone(&*owner->contents.err);
6881 }
6882 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_get_err(int64_t owner) {
6883         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* owner_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(owner);
6884         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6885         *ret_copy = CResult_MaxDustHTLCExposureDecodeErrorZ_get_err(owner_conv);
6886         int64_t ret_ref = tag_ptr(ret_copy, true);
6887         return ret_ref;
6888 }
6889
6890 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6891         LDKChannelConfig ret = *owner->contents.result;
6892         ret.is_owned = false;
6893         return ret;
6894 }
6895 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_get_ok(int64_t owner) {
6896         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
6897         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
6898         int64_t ret_ref = 0;
6899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6901         return ret_ref;
6902 }
6903
6904 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
6905 CHECK(!owner->result_ok);
6906         return DecodeError_clone(&*owner->contents.err);
6907 }
6908 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_get_err(int64_t owner) {
6909         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
6910         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6911         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
6912         int64_t ret_ref = tag_ptr(ret_copy, true);
6913         return ret_ref;
6914 }
6915
6916 uint32_t CS_LDK_LDKCOption_MaxDustHTLCExposureZ_ty_from_ptr(int64_t ptr) {
6917         LDKCOption_MaxDustHTLCExposureZ *obj = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(ptr);
6918         switch(obj->tag) {
6919                 case LDKCOption_MaxDustHTLCExposureZ_Some: return 0;
6920                 case LDKCOption_MaxDustHTLCExposureZ_None: return 1;
6921                 default: abort();
6922         }
6923 }
6924 int64_t CS_LDK_LDKCOption_MaxDustHTLCExposureZ_Some_get_some(int64_t ptr) {
6925         LDKCOption_MaxDustHTLCExposureZ *obj = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(ptr);
6926         CHECK(obj->tag == LDKCOption_MaxDustHTLCExposureZ_Some);
6927         int64_t some_ref = tag_ptr(&obj->some, false);
6928         return some_ref;
6929 }
6930 uint32_t CS_LDK_LDKCOption_APIErrorZ_ty_from_ptr(int64_t ptr) {
6931         LDKCOption_APIErrorZ *obj = (LDKCOption_APIErrorZ*)untag_ptr(ptr);
6932         switch(obj->tag) {
6933                 case LDKCOption_APIErrorZ_Some: return 0;
6934                 case LDKCOption_APIErrorZ_None: return 1;
6935                 default: abort();
6936         }
6937 }
6938 int64_t CS_LDK_LDKCOption_APIErrorZ_Some_get_some(int64_t ptr) {
6939         LDKCOption_APIErrorZ *obj = (LDKCOption_APIErrorZ*)untag_ptr(ptr);
6940         CHECK(obj->tag == LDKCOption_APIErrorZ_Some);
6941         int64_t some_ref = tag_ptr(&obj->some, false);
6942         return some_ref;
6943 }
6944 static inline struct LDKCOption_APIErrorZ CResult_COption_APIErrorZDecodeErrorZ_get_ok(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
6945 CHECK(owner->result_ok);
6946         return COption_APIErrorZ_clone(&*owner->contents.result);
6947 }
6948 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_get_ok(int64_t owner) {
6949         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
6950         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
6951         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_ok(owner_conv);
6952         int64_t ret_ref = tag_ptr(ret_copy, true);
6953         return ret_ref;
6954 }
6955
6956 static inline struct LDKDecodeError CResult_COption_APIErrorZDecodeErrorZ_get_err(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR owner){
6957 CHECK(!owner->result_ok);
6958         return DecodeError_clone(&*owner->contents.err);
6959 }
6960 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_get_err(int64_t owner) {
6961         LDKCResult_COption_APIErrorZDecodeErrorZ* owner_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(owner);
6962         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6963         *ret_copy = CResult_COption_APIErrorZDecodeErrorZ_get_err(owner_conv);
6964         int64_t ret_ref = tag_ptr(ret_copy, true);
6965         return ret_ref;
6966 }
6967
6968 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6969         LDKChannelMonitorUpdate ret = *owner->contents.result;
6970         ret.is_owned = false;
6971         return ret;
6972 }
6973 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(int64_t owner) {
6974         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
6975         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6976         int64_t ret_ref = 0;
6977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6979         return ret_ref;
6980 }
6981
6982 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6983 CHECK(!owner->result_ok);
6984         return DecodeError_clone(&*owner->contents.err);
6985 }
6986 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(int64_t owner) {
6987         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
6988         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6989         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6990         int64_t ret_ref = tag_ptr(ret_copy, true);
6991         return ret_ref;
6992 }
6993
6994 uint32_t CS_LDK_LDKCOption_MonitorEventZ_ty_from_ptr(int64_t ptr) {
6995         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
6996         switch(obj->tag) {
6997                 case LDKCOption_MonitorEventZ_Some: return 0;
6998                 case LDKCOption_MonitorEventZ_None: return 1;
6999                 default: abort();
7000         }
7001 }
7002 int64_t CS_LDK_LDKCOption_MonitorEventZ_Some_get_some(int64_t ptr) {
7003         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
7004         CHECK(obj->tag == LDKCOption_MonitorEventZ_Some);
7005         int64_t some_ref = tag_ptr(&obj->some, false);
7006         return some_ref;
7007 }
7008 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7009 CHECK(owner->result_ok);
7010         return COption_MonitorEventZ_clone(&*owner->contents.result);
7011 }
7012 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(int64_t owner) {
7013         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
7014         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
7015         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
7016         int64_t ret_ref = tag_ptr(ret_copy, true);
7017         return ret_ref;
7018 }
7019
7020 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
7021 CHECK(!owner->result_ok);
7022         return DecodeError_clone(&*owner->contents.err);
7023 }
7024 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_get_err(int64_t owner) {
7025         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
7026         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7027         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
7028         int64_t ret_ref = tag_ptr(ret_copy, true);
7029         return ret_ref;
7030 }
7031
7032 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7033         LDKHTLCUpdate ret = *owner->contents.result;
7034         ret.is_owned = false;
7035         return ret;
7036 }
7037 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_get_ok(int64_t owner) {
7038         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
7039         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
7040         int64_t ret_ref = 0;
7041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7043         return ret_ref;
7044 }
7045
7046 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
7047 CHECK(!owner->result_ok);
7048         return DecodeError_clone(&*owner->contents.err);
7049 }
7050 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_get_err(int64_t owner) {
7051         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
7052         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7053         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
7054         int64_t ret_ref = tag_ptr(ret_copy, true);
7055         return ret_ref;
7056 }
7057
7058 static inline struct LDKOutPoint C2Tuple_OutPointCVec_u8ZZ_get_a(LDKC2Tuple_OutPointCVec_u8ZZ *NONNULL_PTR owner){
7059         LDKOutPoint ret = owner->a;
7060         ret.is_owned = false;
7061         return ret;
7062 }
7063 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_get_a(int64_t owner) {
7064         LDKC2Tuple_OutPointCVec_u8ZZ* owner_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(owner);
7065         LDKOutPoint ret_var = C2Tuple_OutPointCVec_u8ZZ_get_a(owner_conv);
7066         int64_t ret_ref = 0;
7067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7069         return ret_ref;
7070 }
7071
7072 static inline struct LDKCVec_u8Z C2Tuple_OutPointCVec_u8ZZ_get_b(LDKC2Tuple_OutPointCVec_u8ZZ *NONNULL_PTR owner){
7073         return CVec_u8Z_clone(&owner->b);
7074 }
7075 int8_tArray  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_get_b(int64_t owner) {
7076         LDKC2Tuple_OutPointCVec_u8ZZ* owner_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(owner);
7077         LDKCVec_u8Z ret_var = C2Tuple_OutPointCVec_u8ZZ_get_b(owner_conv);
7078         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7079         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7080         CVec_u8Z_free(ret_var);
7081         return ret_arr;
7082 }
7083
7084 static inline uint32_t C2Tuple_u32CVec_u8ZZ_get_a(LDKC2Tuple_u32CVec_u8ZZ *NONNULL_PTR owner){
7085         return owner->a;
7086 }
7087 int32_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_get_a(int64_t owner) {
7088         LDKC2Tuple_u32CVec_u8ZZ* owner_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(owner);
7089         int32_t ret_conv = C2Tuple_u32CVec_u8ZZ_get_a(owner_conv);
7090         return ret_conv;
7091 }
7092
7093 static inline struct LDKCVec_u8Z C2Tuple_u32CVec_u8ZZ_get_b(LDKC2Tuple_u32CVec_u8ZZ *NONNULL_PTR owner){
7094         return CVec_u8Z_clone(&owner->b);
7095 }
7096 int8_tArray  CS_LDK_C2Tuple_u32CVec_u8ZZ_get_b(int64_t owner) {
7097         LDKC2Tuple_u32CVec_u8ZZ* owner_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(owner);
7098         LDKCVec_u8Z ret_var = C2Tuple_u32CVec_u8ZZ_get_b(owner_conv);
7099         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7100         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7101         CVec_u8Z_free(ret_var);
7102         return ret_arr;
7103 }
7104
7105 static inline LDKCVec_C2Tuple_u32CVec_u8ZZZ CVec_C2Tuple_u32CVec_u8ZZZ_clone(const LDKCVec_C2Tuple_u32CVec_u8ZZZ *orig) {
7106         LDKCVec_C2Tuple_u32CVec_u8ZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ) * orig->datalen, "LDKCVec_C2Tuple_u32CVec_u8ZZZ clone bytes"), .datalen = orig->datalen };
7107         for (size_t i = 0; i < ret.datalen; i++) {
7108                 ret.data[i] = C2Tuple_u32CVec_u8ZZ_clone(&orig->data[i]);
7109         }
7110         return ret;
7111 }
7112 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_a(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ *NONNULL_PTR owner){
7113         return ThirtyTwoBytes_clone(&owner->a);
7114 }
7115 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_a(int64_t owner) {
7116         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(owner);
7117         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
7118         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_a(owner_conv).data, 32);
7119         return ret_arr;
7120 }
7121
7122 static inline struct LDKCVec_C2Tuple_u32CVec_u8ZZZ C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_b(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ *NONNULL_PTR owner){
7123         return CVec_C2Tuple_u32CVec_u8ZZZ_clone(&owner->b);
7124 }
7125 int64_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_b(int64_t owner) {
7126         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(owner);
7127         LDKCVec_C2Tuple_u32CVec_u8ZZZ ret_var = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_get_b(owner_conv);
7128         int64_tArray ret_arr = NULL;
7129         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
7130         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
7131         for (size_t x = 0; x < ret_var.datalen; x++) {
7132                 LDKC2Tuple_u32CVec_u8ZZ* ret_conv_23_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
7133                 *ret_conv_23_conv = ret_var.data[x];
7134                 ret_arr_ptr[x] = tag_ptr(ret_conv_23_conv, true);
7135         }
7136         
7137         FREE(ret_var.data);
7138         return ret_arr;
7139 }
7140
7141 static inline LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ *orig) {
7142         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ clone bytes"), .datalen = orig->datalen };
7143         for (size_t i = 0; i < ret.datalen; i++) {
7144                 ret.data[i] = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(&orig->data[i]);
7145         }
7146         return ret;
7147 }
7148 static inline LDKCVec_CommitmentTransactionZ CVec_CommitmentTransactionZ_clone(const LDKCVec_CommitmentTransactionZ *orig) {
7149         LDKCVec_CommitmentTransactionZ ret = { .data = MALLOC(sizeof(LDKCommitmentTransaction) * orig->datalen, "LDKCVec_CommitmentTransactionZ clone bytes"), .datalen = orig->datalen };
7150         for (size_t i = 0; i < ret.datalen; i++) {
7151                 ret.data[i] = CommitmentTransaction_clone(&orig->data[i]);
7152         }
7153         return ret;
7154 }
7155 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7156         return owner->a;
7157 }
7158 int32_t  CS_LDK_C2Tuple_u32TxOutZ_get_a(int64_t owner) {
7159         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
7160         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
7161         return ret_conv;
7162 }
7163
7164 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
7165         return TxOut_clone(&owner->b);
7166 }
7167 int64_t  CS_LDK_C2Tuple_u32TxOutZ_get_b(int64_t owner) {
7168         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
7169         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
7170         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
7171         return tag_ptr(ret_ref, true);
7172 }
7173
7174 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
7175         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
7176         for (size_t i = 0; i < ret.datalen; i++) {
7177                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
7178         }
7179         return ret;
7180 }
7181 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7182         return ThirtyTwoBytes_clone(&owner->a);
7183 }
7184 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_a(int64_t owner) {
7185         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
7186         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
7187         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
7188         return ret_arr;
7189 }
7190
7191 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
7192         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
7193 }
7194 int64_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_b(int64_t owner) {
7195         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
7196         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
7197         int64_tArray ret_arr = NULL;
7198         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
7199         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
7200         for (size_t u = 0; u < ret_var.datalen; u++) {
7201                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
7202                 *ret_conv_20_conv = ret_var.data[u];
7203                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
7204         }
7205         
7206         FREE(ret_var.data);
7207         return ret_arr;
7208 }
7209
7210 static inline LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ *orig) {
7211         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
7212         for (size_t i = 0; i < ret.datalen; i++) {
7213                 ret.data[i] = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
7214         }
7215         return ret;
7216 }
7217 uint32_t CS_LDK_LDKBalance_ty_from_ptr(int64_t ptr) {
7218         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7219         switch(obj->tag) {
7220                 case LDKBalance_ClaimableOnChannelClose: return 0;
7221                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
7222                 case LDKBalance_ContentiousClaimable: return 2;
7223                 case LDKBalance_MaybeTimeoutClaimableHTLC: return 3;
7224                 case LDKBalance_MaybePreimageClaimableHTLC: return 4;
7225                 case LDKBalance_CounterpartyRevokedOutputClaimable: return 5;
7226                 default: abort();
7227         }
7228 }
7229 int64_t CS_LDK_LDKBalance_ClaimableOnChannelClose_get_amount_satoshis(int64_t ptr) {
7230         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7231         CHECK(obj->tag == LDKBalance_ClaimableOnChannelClose);
7232         int64_t amount_satoshis_conv = obj->claimable_on_channel_close.amount_satoshis;
7233         return amount_satoshis_conv;
7234 }
7235 int64_t CS_LDK_LDKBalance_ClaimableAwaitingConfirmations_get_amount_satoshis(int64_t ptr) {
7236         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7237         CHECK(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
7238         int64_t amount_satoshis_conv = obj->claimable_awaiting_confirmations.amount_satoshis;
7239         return amount_satoshis_conv;
7240 }
7241 int32_t CS_LDK_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(int64_t ptr) {
7242         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7243         CHECK(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
7244         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
7245         return confirmation_height_conv;
7246 }
7247 int64_t CS_LDK_LDKBalance_ContentiousClaimable_get_amount_satoshis(int64_t ptr) {
7248         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7249         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7250         int64_t amount_satoshis_conv = obj->contentious_claimable.amount_satoshis;
7251         return amount_satoshis_conv;
7252 }
7253 int32_t CS_LDK_LDKBalance_ContentiousClaimable_get_timeout_height(int64_t ptr) {
7254         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7255         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7256         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
7257         return timeout_height_conv;
7258 }
7259 int8_tArray CS_LDK_LDKBalance_ContentiousClaimable_get_payment_hash(int64_t ptr) {
7260         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7261         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7262         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
7263         memcpy(payment_hash_arr->elems, obj->contentious_claimable.payment_hash.data, 32);
7264         return payment_hash_arr;
7265 }
7266 int8_tArray CS_LDK_LDKBalance_ContentiousClaimable_get_payment_preimage(int64_t ptr) {
7267         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7268         CHECK(obj->tag == LDKBalance_ContentiousClaimable);
7269         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
7270         memcpy(payment_preimage_arr->elems, obj->contentious_claimable.payment_preimage.data, 32);
7271         return payment_preimage_arr;
7272 }
7273 int64_t CS_LDK_LDKBalance_MaybeTimeoutClaimableHTLC_get_amount_satoshis(int64_t ptr) {
7274         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7275         CHECK(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
7276         int64_t amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.amount_satoshis;
7277         return amount_satoshis_conv;
7278 }
7279 int32_t CS_LDK_LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_height(int64_t ptr) {
7280         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7281         CHECK(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
7282         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
7283         return claimable_height_conv;
7284 }
7285 int8_tArray CS_LDK_LDKBalance_MaybeTimeoutClaimableHTLC_get_payment_hash(int64_t ptr) {
7286         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7287         CHECK(obj->tag == LDKBalance_MaybeTimeoutClaimableHTLC);
7288         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
7289         memcpy(payment_hash_arr->elems, obj->maybe_timeout_claimable_htlc.payment_hash.data, 32);
7290         return payment_hash_arr;
7291 }
7292 int64_t CS_LDK_LDKBalance_MaybePreimageClaimableHTLC_get_amount_satoshis(int64_t ptr) {
7293         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7294         CHECK(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
7295         int64_t amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.amount_satoshis;
7296         return amount_satoshis_conv;
7297 }
7298 int32_t CS_LDK_LDKBalance_MaybePreimageClaimableHTLC_get_expiry_height(int64_t ptr) {
7299         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7300         CHECK(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
7301         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
7302         return expiry_height_conv;
7303 }
7304 int8_tArray CS_LDK_LDKBalance_MaybePreimageClaimableHTLC_get_payment_hash(int64_t ptr) {
7305         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7306         CHECK(obj->tag == LDKBalance_MaybePreimageClaimableHTLC);
7307         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
7308         memcpy(payment_hash_arr->elems, obj->maybe_preimage_claimable_htlc.payment_hash.data, 32);
7309         return payment_hash_arr;
7310 }
7311 int64_t CS_LDK_LDKBalance_CounterpartyRevokedOutputClaimable_get_amount_satoshis(int64_t ptr) {
7312         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
7313         CHECK(obj->tag == LDKBalance_CounterpartyRevokedOutputClaimable);
7314         int64_t amount_satoshis_conv = obj->counterparty_revoked_output_claimable.amount_satoshis;
7315         return amount_satoshis_conv;
7316 }
7317 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
7318         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
7319         for (size_t i = 0; i < ret.datalen; i++) {
7320                 ret.data[i] = Balance_clone(&orig->data[i]);
7321         }
7322         return ret;
7323 }
7324 static inline struct LDKThirtyTwoBytes C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_a(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ *NONNULL_PTR owner){
7325         return ThirtyTwoBytes_clone(&owner->a);
7326 }
7327 int8_tArray  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_a(int64_t owner) {
7328         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(owner);
7329         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
7330         memcpy(ret_arr->elems, C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_a(owner_conv).data, 32);
7331         return ret_arr;
7332 }
7333
7334 static inline struct LDKChannelMonitor C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_b(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ *NONNULL_PTR owner){
7335         LDKChannelMonitor ret = owner->b;
7336         ret.is_owned = false;
7337         return ret;
7338 }
7339 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_b(int64_t owner) {
7340         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* owner_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(owner);
7341         LDKChannelMonitor ret_var = C2Tuple_ThirtyTwoBytesChannelMonitorZ_get_b(owner_conv);
7342         int64_t ret_ref = 0;
7343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7344         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7345         return ret_ref;
7346 }
7347
7348 static inline struct LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7349 CHECK(owner->result_ok);
7350         return C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(&*owner->contents.result);
7351 }
7352 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_ok(int64_t owner) {
7353         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
7354         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
7355         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
7356         return tag_ptr(ret_conv, true);
7357 }
7358
7359 static inline struct LDKDecodeError CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
7360 CHECK(!owner->result_ok);
7361         return DecodeError_clone(&*owner->contents.err);
7362 }
7363 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_err(int64_t owner) {
7364         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
7365         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7366         *ret_copy = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_get_err(owner_conv);
7367         int64_t ret_ref = tag_ptr(ret_copy, true);
7368         return ret_ref;
7369 }
7370
7371 typedef struct LDKType_JCalls {
7372         atomic_size_t refcnt;
7373         uint32_t instance_ptr;
7374 } LDKType_JCalls;
7375 static void LDKType_JCalls_free(void* this_arg) {
7376         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7377         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7378                 FREE(j_calls);
7379         }
7380 }
7381 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7382         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7383         return js_invoke_function_s_(j_calls->instance_ptr, 46);
7384 }
7385 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7386         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7387         jstring ret = (jstring)js_invoke_function_l_(j_calls->instance_ptr, 47);
7388         LDKStr ret_conv = str_ref_to_owned_c(ret);
7389         return ret_conv;
7390 }
7391 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7392         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7393         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 48);
7394         LDKCVec_u8Z ret_ref;
7395         ret_ref.datalen = ret->arr_len;
7396         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7397         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
7398         return ret_ref;
7399 }
7400 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7401         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7402         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7403 }
7404 static inline LDKType LDKType_init (int64_t o) {
7405         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7406         atomic_init(&calls->refcnt, 1);
7407         calls->instance_ptr = o;
7408
7409         LDKType ret = {
7410                 .this_arg = (void*) calls,
7411                 .type_id = type_id_LDKType_jcall,
7412                 .debug_str = debug_str_LDKType_jcall,
7413                 .write = write_LDKType_jcall,
7414                 .cloned = LDKType_JCalls_cloned,
7415                 .free = LDKType_JCalls_free,
7416         };
7417         return ret;
7418 }
7419 uint64_t  CS_LDK_LDKType_new(int32_t o) {
7420         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7421         *res_ptr = LDKType_init(o);
7422         return tag_ptr(res_ptr, true);
7423 }
7424 int16_t  CS_LDK_Type_type_id(int64_t this_arg) {
7425         void* this_arg_ptr = untag_ptr(this_arg);
7426         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7427         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7428         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7429         return ret_conv;
7430 }
7431
7432 jstring  CS_LDK_Type_debug_str(int64_t this_arg) {
7433         void* this_arg_ptr = untag_ptr(this_arg);
7434         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7435         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7436         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7437         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
7438         Str_free(ret_str);
7439         return ret_conv;
7440 }
7441
7442 int8_tArray  CS_LDK_Type_write(int64_t this_arg) {
7443         void* this_arg_ptr = untag_ptr(this_arg);
7444         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7445         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7446         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7447         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7448         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7449         CVec_u8Z_free(ret_var);
7450         return ret_arr;
7451 }
7452
7453 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7454         return owner->a;
7455 }
7456 int8_tArray  CS_LDK_C2Tuple_PublicKeyTypeZ_get_a(int64_t owner) {
7457         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
7458         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
7459         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
7460         return ret_arr;
7461 }
7462
7463 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
7464         return Type_clone(&owner->b);
7465 }
7466 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_get_b(int64_t owner) {
7467         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
7468         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
7469         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
7470         return tag_ptr(ret_ret, true);
7471 }
7472
7473 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
7474         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
7475         for (size_t i = 0; i < ret.datalen; i++) {
7476                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
7477         }
7478         return ret;
7479 }
7480 typedef struct LDKOnionMessageContents_JCalls {
7481         atomic_size_t refcnt;
7482         uint32_t instance_ptr;
7483 } LDKOnionMessageContents_JCalls;
7484 static void LDKOnionMessageContents_JCalls_free(void* this_arg) {
7485         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) this_arg;
7486         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7487                 FREE(j_calls);
7488         }
7489 }
7490 uint64_t tlv_type_LDKOnionMessageContents_jcall(const void* this_arg) {
7491         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) this_arg;
7492         return js_invoke_function_l_(j_calls->instance_ptr, 49);
7493 }
7494 LDKCVec_u8Z write_LDKOnionMessageContents_jcall(const void* this_arg) {
7495         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) this_arg;
7496         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 50);
7497         LDKCVec_u8Z ret_ref;
7498         ret_ref.datalen = ret->arr_len;
7499         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7500         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
7501         return ret_ref;
7502 }
7503 static void LDKOnionMessageContents_JCalls_cloned(LDKOnionMessageContents* new_obj) {
7504         LDKOnionMessageContents_JCalls *j_calls = (LDKOnionMessageContents_JCalls*) new_obj->this_arg;
7505         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7506 }
7507 static inline LDKOnionMessageContents LDKOnionMessageContents_init (int64_t o) {
7508         LDKOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKOnionMessageContents_JCalls), "LDKOnionMessageContents_JCalls");
7509         atomic_init(&calls->refcnt, 1);
7510         calls->instance_ptr = o;
7511
7512         LDKOnionMessageContents ret = {
7513                 .this_arg = (void*) calls,
7514                 .tlv_type = tlv_type_LDKOnionMessageContents_jcall,
7515                 .write = write_LDKOnionMessageContents_jcall,
7516                 .cloned = LDKOnionMessageContents_JCalls_cloned,
7517                 .free = LDKOnionMessageContents_JCalls_free,
7518         };
7519         return ret;
7520 }
7521 uint64_t  CS_LDK_LDKOnionMessageContents_new(int32_t o) {
7522         LDKOnionMessageContents *res_ptr = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
7523         *res_ptr = LDKOnionMessageContents_init(o);
7524         return tag_ptr(res_ptr, true);
7525 }
7526 int64_t  CS_LDK_OnionMessageContents_tlv_type(int64_t this_arg) {
7527         void* this_arg_ptr = untag_ptr(this_arg);
7528         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7529         LDKOnionMessageContents* this_arg_conv = (LDKOnionMessageContents*)this_arg_ptr;
7530         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
7531         return ret_conv;
7532 }
7533
7534 int8_tArray  CS_LDK_OnionMessageContents_write(int64_t this_arg) {
7535         void* this_arg_ptr = untag_ptr(this_arg);
7536         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7537         LDKOnionMessageContents* this_arg_conv = (LDKOnionMessageContents*)this_arg_ptr;
7538         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7539         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7540         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7541         CVec_u8Z_free(ret_var);
7542         return ret_arr;
7543 }
7544
7545 uint32_t CS_LDK_LDKCOption_OnionMessageContentsZ_ty_from_ptr(int64_t ptr) {
7546         LDKCOption_OnionMessageContentsZ *obj = (LDKCOption_OnionMessageContentsZ*)untag_ptr(ptr);
7547         switch(obj->tag) {
7548                 case LDKCOption_OnionMessageContentsZ_Some: return 0;
7549                 case LDKCOption_OnionMessageContentsZ_None: return 1;
7550                 default: abort();
7551         }
7552 }
7553 int64_t CS_LDK_LDKCOption_OnionMessageContentsZ_Some_get_some(int64_t ptr) {
7554         LDKCOption_OnionMessageContentsZ *obj = (LDKCOption_OnionMessageContentsZ*)untag_ptr(ptr);
7555         CHECK(obj->tag == LDKCOption_OnionMessageContentsZ_Some);
7556         LDKOnionMessageContents* some_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
7557         *some_ret = OnionMessageContents_clone(&obj->some);
7558         return tag_ptr(some_ret, true);
7559 }
7560 static inline struct LDKCOption_OnionMessageContentsZ CResult_COption_OnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
7561 CHECK(owner->result_ok);
7562         return COption_OnionMessageContentsZ_clone(&*owner->contents.result);
7563 }
7564 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_get_ok(int64_t owner) {
7565         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
7566         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
7567         *ret_copy = CResult_COption_OnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
7568         int64_t ret_ref = tag_ptr(ret_copy, true);
7569         return ret_ref;
7570 }
7571
7572 static inline struct LDKDecodeError CResult_COption_OnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
7573 CHECK(!owner->result_ok);
7574         return DecodeError_clone(&*owner->contents.err);
7575 }
7576 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_get_err(int64_t owner) {
7577         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
7578         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7579         *ret_copy = CResult_COption_OnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
7580         int64_t ret_ref = tag_ptr(ret_copy, true);
7581         return ret_ref;
7582 }
7583
7584 static inline struct LDKOnionMessageContents C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_a(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR owner){
7585         return OnionMessageContents_clone(&owner->a);
7586 }
7587 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_a(int64_t owner) {
7588         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(owner);
7589         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
7590         *ret_ret = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_a(owner_conv);
7591         return tag_ptr(ret_ret, true);
7592 }
7593
7594 static inline struct LDKDestination C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_b(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR owner){
7595         return Destination_clone(&owner->b);
7596 }
7597 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_b(int64_t owner) {
7598         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(owner);
7599         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
7600         *ret_copy = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_b(owner_conv);
7601         int64_t ret_ref = tag_ptr(ret_copy, true);
7602         return ret_ref;
7603 }
7604
7605 static inline struct LDKBlindedPath C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_c(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR owner){
7606         LDKBlindedPath ret = owner->c;
7607         ret.is_owned = false;
7608         return ret;
7609 }
7610 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_c(int64_t owner) {
7611         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* owner_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(owner);
7612         LDKBlindedPath ret_var = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_get_c(owner_conv);
7613         int64_t ret_ref = 0;
7614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7616         return ret_ref;
7617 }
7618
7619 static inline LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_clone(const LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ *orig) {
7620         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ) * orig->datalen, "LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ clone bytes"), .datalen = orig->datalen };
7621         for (size_t i = 0; i < ret.datalen; i++) {
7622                 ret.data[i] = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(&orig->data[i]);
7623         }
7624         return ret;
7625 }
7626 uint32_t CS_LDK_LDKCOption_TypeZ_ty_from_ptr(int64_t ptr) {
7627         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
7628         switch(obj->tag) {
7629                 case LDKCOption_TypeZ_Some: return 0;
7630                 case LDKCOption_TypeZ_None: return 1;
7631                 default: abort();
7632         }
7633 }
7634 int64_t CS_LDK_LDKCOption_TypeZ_Some_get_some(int64_t ptr) {
7635         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
7636         CHECK(obj->tag == LDKCOption_TypeZ_Some);
7637         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7638         *some_ret = Type_clone(&obj->some);
7639         return tag_ptr(some_ret, true);
7640 }
7641 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7642 CHECK(owner->result_ok);
7643         return COption_TypeZ_clone(&*owner->contents.result);
7644 }
7645 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_get_ok(int64_t owner) {
7646         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7647         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7648         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7649         int64_t ret_ref = tag_ptr(ret_copy, true);
7650         return ret_ref;
7651 }
7652
7653 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7654 CHECK(!owner->result_ok);
7655         return DecodeError_clone(&*owner->contents.err);
7656 }
7657 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_get_err(int64_t owner) {
7658         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7659         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7660         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7661         int64_t ret_ref = tag_ptr(ret_copy, true);
7662         return ret_ref;
7663 }
7664
7665 uint32_t CS_LDK_LDKCOption_SocketAddressZ_ty_from_ptr(int64_t ptr) {
7666         LDKCOption_SocketAddressZ *obj = (LDKCOption_SocketAddressZ*)untag_ptr(ptr);
7667         switch(obj->tag) {
7668                 case LDKCOption_SocketAddressZ_Some: return 0;
7669                 case LDKCOption_SocketAddressZ_None: return 1;
7670                 default: abort();
7671         }
7672 }
7673 int64_t CS_LDK_LDKCOption_SocketAddressZ_Some_get_some(int64_t ptr) {
7674         LDKCOption_SocketAddressZ *obj = (LDKCOption_SocketAddressZ*)untag_ptr(ptr);
7675         CHECK(obj->tag == LDKCOption_SocketAddressZ_Some);
7676         int64_t some_ref = tag_ptr(&obj->some, false);
7677         return some_ref;
7678 }
7679 static inline struct LDKPublicKey C2Tuple_PublicKeyCOption_SocketAddressZZ_get_a(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *NONNULL_PTR owner){
7680         return owner->a;
7681 }
7682 int8_tArray  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_get_a(int64_t owner) {
7683         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(owner);
7684         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
7685         memcpy(ret_arr->elems, C2Tuple_PublicKeyCOption_SocketAddressZZ_get_a(owner_conv).compressed_form, 33);
7686         return ret_arr;
7687 }
7688
7689 static inline struct LDKCOption_SocketAddressZ C2Tuple_PublicKeyCOption_SocketAddressZZ_get_b(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *NONNULL_PTR owner){
7690         return COption_SocketAddressZ_clone(&owner->b);
7691 }
7692 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_get_b(int64_t owner) {
7693         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* owner_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(owner);
7694         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
7695         *ret_copy = C2Tuple_PublicKeyCOption_SocketAddressZZ_get_b(owner_conv);
7696         int64_t ret_ref = tag_ptr(ret_copy, true);
7697         return ret_ref;
7698 }
7699
7700 static inline LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_clone(const LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ *orig) {
7701         LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ clone bytes"), .datalen = orig->datalen };
7702         for (size_t i = 0; i < ret.datalen; i++) {
7703                 ret.data[i] = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(&orig->data[i]);
7704         }
7705         return ret;
7706 }
7707 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7708 CHECK(owner->result_ok);
7709         return CVec_u8Z_clone(&*owner->contents.result);
7710 }
7711 int8_tArray  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(int64_t owner) {
7712         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
7713         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
7714         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7715         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7716         CVec_u8Z_free(ret_var);
7717         return ret_arr;
7718 }
7719
7720 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
7721         LDKPeerHandleError ret = *owner->contents.err;
7722         ret.is_owned = false;
7723         return ret;
7724 }
7725 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_get_err(int64_t owner) {
7726         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
7727         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
7728         int64_t ret_ref = 0;
7729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7731         return ret_ref;
7732 }
7733
7734 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7735 CHECK(owner->result_ok);
7736         return *owner->contents.result;
7737 }
7738 void  CS_LDK_CResult_NonePeerHandleErrorZ_get_ok(int64_t owner) {
7739         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
7740         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
7741 }
7742
7743 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
7744         LDKPeerHandleError ret = *owner->contents.err;
7745         ret.is_owned = false;
7746         return ret;
7747 }
7748 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_get_err(int64_t owner) {
7749         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
7750         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
7751         int64_t ret_ref = 0;
7752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7753         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7754         return ret_ref;
7755 }
7756
7757 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7758 CHECK(owner->result_ok);
7759         return *owner->contents.result;
7760 }
7761 jboolean  CS_LDK_CResult_boolPeerHandleErrorZ_get_ok(int64_t owner) {
7762         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
7763         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
7764         return ret_conv;
7765 }
7766
7767 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
7768         LDKPeerHandleError ret = *owner->contents.err;
7769         ret.is_owned = false;
7770         return ret;
7771 }
7772 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_get_err(int64_t owner) {
7773         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
7774         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
7775         int64_t ret_ref = 0;
7776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7778         return ret_ref;
7779 }
7780
7781 uint32_t CS_LDK_LDKGraphSyncError_ty_from_ptr(int64_t ptr) {
7782         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
7783         switch(obj->tag) {
7784                 case LDKGraphSyncError_DecodeError: return 0;
7785                 case LDKGraphSyncError_LightningError: return 1;
7786                 default: abort();
7787         }
7788 }
7789 int64_t CS_LDK_LDKGraphSyncError_DecodeError_get_decode_error(int64_t ptr) {
7790         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
7791         CHECK(obj->tag == LDKGraphSyncError_DecodeError);
7792         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
7793         return decode_error_ref;
7794 }
7795 int64_t CS_LDK_LDKGraphSyncError_LightningError_get_lightning_error(int64_t ptr) {
7796         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
7797         CHECK(obj->tag == LDKGraphSyncError_LightningError);
7798         LDKLightningError lightning_error_var = obj->lightning_error;
7799                         int64_t lightning_error_ref = 0;
7800                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
7801                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
7802         return lightning_error_ref;
7803 }
7804 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
7805 CHECK(owner->result_ok);
7806         return *owner->contents.result;
7807 }
7808 int32_t  CS_LDK_CResult_u32GraphSyncErrorZ_get_ok(int64_t owner) {
7809         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
7810         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
7811         return ret_conv;
7812 }
7813
7814 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
7815 CHECK(!owner->result_ok);
7816         return GraphSyncError_clone(&*owner->contents.err);
7817 }
7818 int64_t  CS_LDK_CResult_u32GraphSyncErrorZ_get_err(int64_t owner) {
7819         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
7820         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
7821         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
7822         int64_t ret_ref = tag_ptr(ret_copy, true);
7823         return ret_ref;
7824 }
7825
7826 static inline struct LDKCVec_u8Z CResult_CVec_u8ZIOErrorZ_get_ok(LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR owner){
7827 CHECK(owner->result_ok);
7828         return CVec_u8Z_clone(&*owner->contents.result);
7829 }
7830 int8_tArray  CS_LDK_CResult_CVec_u8ZIOErrorZ_get_ok(int64_t owner) {
7831         LDKCResult_CVec_u8ZIOErrorZ* owner_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(owner);
7832         LDKCVec_u8Z ret_var = CResult_CVec_u8ZIOErrorZ_get_ok(owner_conv);
7833         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
7834         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
7835         CVec_u8Z_free(ret_var);
7836         return ret_arr;
7837 }
7838
7839 static inline enum LDKIOError CResult_CVec_u8ZIOErrorZ_get_err(LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR owner){
7840 CHECK(!owner->result_ok);
7841         return *owner->contents.err;
7842 }
7843 int32_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_get_err(int64_t owner) {
7844         LDKCResult_CVec_u8ZIOErrorZ* owner_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(owner);
7845         int32_t ret_conv = LDKIOError_to_cs(CResult_CVec_u8ZIOErrorZ_get_err(owner_conv));
7846         return ret_conv;
7847 }
7848
7849 static inline struct LDKCVec_StrZ CResult_CVec_StrZIOErrorZ_get_ok(LDKCResult_CVec_StrZIOErrorZ *NONNULL_PTR owner){
7850 CHECK(owner->result_ok);
7851         return *owner->contents.result;
7852 }
7853 ptrArray  CS_LDK_CResult_CVec_StrZIOErrorZ_get_ok(int64_t owner) {
7854         LDKCResult_CVec_StrZIOErrorZ* owner_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(owner);
7855         LDKCVec_StrZ ret_var = CResult_CVec_StrZIOErrorZ_get_ok(owner_conv);
7856         ptrArray ret_arr = NULL;
7857         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
7858         jstring *ret_arr_ptr = (jstring*)(((uint8_t*)ret_arr) + 8);
7859         for (size_t i = 0; i < ret_var.datalen; i++) {
7860                 LDKStr ret_conv_8_str = ret_var.data[i];
7861                 jstring ret_conv_8_conv = str_ref_to_cs(ret_conv_8_str.chars, ret_conv_8_str.len);
7862                 ret_arr_ptr[i] = ret_conv_8_conv;
7863         }
7864         
7865         return ret_arr;
7866 }
7867
7868 static inline enum LDKIOError CResult_CVec_StrZIOErrorZ_get_err(LDKCResult_CVec_StrZIOErrorZ *NONNULL_PTR owner){
7869 CHECK(!owner->result_ok);
7870         return *owner->contents.err;
7871 }
7872 int32_t  CS_LDK_CResult_CVec_StrZIOErrorZ_get_err(int64_t owner) {
7873         LDKCResult_CVec_StrZIOErrorZ* owner_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(owner);
7874         int32_t ret_conv = LDKIOError_to_cs(CResult_CVec_StrZIOErrorZ_get_err(owner_conv));
7875         return ret_conv;
7876 }
7877
7878 static inline LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_clone(const LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ *orig) {
7879         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
7880         for (size_t i = 0; i < ret.datalen; i++) {
7881                 ret.data[i] = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(&orig->data[i]);
7882         }
7883         return ret;
7884 }
7885 static inline struct LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_ok(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ *NONNULL_PTR owner){
7886 CHECK(owner->result_ok);
7887         return CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_clone(&*owner->contents.result);
7888 }
7889 int64_tArray  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_ok(int64_t owner) {
7890         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(owner);
7891         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_ok(owner_conv);
7892         int64_tArray ret_arr = NULL;
7893         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
7894         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
7895         for (size_t o = 0; o < ret_var.datalen; o++) {
7896                 LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
7897                 *ret_conv_40_conv = ret_var.data[o];
7898                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
7899         }
7900         
7901         FREE(ret_var.data);
7902         return ret_arr;
7903 }
7904
7905 static inline enum LDKIOError CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_err(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ *NONNULL_PTR owner){
7906 CHECK(!owner->result_ok);
7907         return *owner->contents.err;
7908 }
7909 int32_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_err(int64_t owner) {
7910         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(owner);
7911         int32_t ret_conv = LDKIOError_to_cs(CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_get_err(owner_conv));
7912         return ret_conv;
7913 }
7914
7915 static inline struct LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_ok(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ *NONNULL_PTR owner){
7916 CHECK(owner->result_ok);
7917         return C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(&*owner->contents.result);
7918 }
7919 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_ok(int64_t owner) {
7920         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(owner);
7921         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
7922         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_ok(owner_conv);
7923         return tag_ptr(ret_conv, true);
7924 }
7925
7926 static inline enum LDKIOError CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_err(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ *NONNULL_PTR owner){
7927 CHECK(!owner->result_ok);
7928         return *owner->contents.err;
7929 }
7930 int32_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_err(int64_t owner) {
7931         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* owner_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(owner);
7932         int32_t ret_conv = LDKIOError_to_cs(CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_get_err(owner_conv));
7933         return ret_conv;
7934 }
7935
7936 uint32_t CS_LDK_LDKCOption_SecretKeyZ_ty_from_ptr(int64_t ptr) {
7937         LDKCOption_SecretKeyZ *obj = (LDKCOption_SecretKeyZ*)untag_ptr(ptr);
7938         switch(obj->tag) {
7939                 case LDKCOption_SecretKeyZ_Some: return 0;
7940                 case LDKCOption_SecretKeyZ_None: return 1;
7941                 default: abort();
7942         }
7943 }
7944 int8_tArray CS_LDK_LDKCOption_SecretKeyZ_Some_get_some(int64_t ptr) {
7945         LDKCOption_SecretKeyZ *obj = (LDKCOption_SecretKeyZ*)untag_ptr(ptr);
7946         CHECK(obj->tag == LDKCOption_SecretKeyZ_Some);
7947         int8_tArray some_arr = init_int8_tArray(32, __LINE__);
7948         memcpy(some_arr->elems, obj->some.bytes, 32);
7949         return some_arr;
7950 }
7951 static inline struct LDKVerifiedInvoiceRequest CResult_VerifiedInvoiceRequestNoneZ_get_ok(LDKCResult_VerifiedInvoiceRequestNoneZ *NONNULL_PTR owner){
7952         LDKVerifiedInvoiceRequest ret = *owner->contents.result;
7953         ret.is_owned = false;
7954         return ret;
7955 }
7956 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_get_ok(int64_t owner) {
7957         LDKCResult_VerifiedInvoiceRequestNoneZ* owner_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(owner);
7958         LDKVerifiedInvoiceRequest ret_var = CResult_VerifiedInvoiceRequestNoneZ_get_ok(owner_conv);
7959         int64_t ret_ref = 0;
7960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7962         return ret_ref;
7963 }
7964
7965 static inline void CResult_VerifiedInvoiceRequestNoneZ_get_err(LDKCResult_VerifiedInvoiceRequestNoneZ *NONNULL_PTR owner){
7966 CHECK(!owner->result_ok);
7967         return *owner->contents.err;
7968 }
7969 void  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_get_err(int64_t owner) {
7970         LDKCResult_VerifiedInvoiceRequestNoneZ* owner_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(owner);
7971         CResult_VerifiedInvoiceRequestNoneZ_get_err(owner_conv);
7972 }
7973
7974 static inline LDKCVec_WitnessZ CVec_WitnessZ_clone(const LDKCVec_WitnessZ *orig) {
7975         LDKCVec_WitnessZ ret = { .data = MALLOC(sizeof(LDKWitness) * orig->datalen, "LDKCVec_WitnessZ clone bytes"), .datalen = orig->datalen };
7976         for (size_t i = 0; i < ret.datalen; i++) {
7977                 ret.data[i] = Witness_clone(&orig->data[i]);
7978         }
7979         return ret;
7980 }
7981 uint32_t CS_LDK_LDKCOption_i64Z_ty_from_ptr(int64_t ptr) {
7982         LDKCOption_i64Z *obj = (LDKCOption_i64Z*)untag_ptr(ptr);
7983         switch(obj->tag) {
7984                 case LDKCOption_i64Z_Some: return 0;
7985                 case LDKCOption_i64Z_None: return 1;
7986                 default: abort();
7987         }
7988 }
7989 int64_t CS_LDK_LDKCOption_i64Z_Some_get_some(int64_t ptr) {
7990         LDKCOption_i64Z *obj = (LDKCOption_i64Z*)untag_ptr(ptr);
7991         CHECK(obj->tag == LDKCOption_i64Z_Some);
7992         int64_t some_conv = obj->some;
7993         return some_conv;
7994 }
7995 static inline struct LDKSocketAddress CResult_SocketAddressDecodeErrorZ_get_ok(LDKCResult_SocketAddressDecodeErrorZ *NONNULL_PTR owner){
7996 CHECK(owner->result_ok);
7997         return SocketAddress_clone(&*owner->contents.result);
7998 }
7999 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_get_ok(int64_t owner) {
8000         LDKCResult_SocketAddressDecodeErrorZ* owner_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(owner);
8001         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
8002         *ret_copy = CResult_SocketAddressDecodeErrorZ_get_ok(owner_conv);
8003         int64_t ret_ref = tag_ptr(ret_copy, true);
8004         return ret_ref;
8005 }
8006
8007 static inline struct LDKDecodeError CResult_SocketAddressDecodeErrorZ_get_err(LDKCResult_SocketAddressDecodeErrorZ *NONNULL_PTR owner){
8008 CHECK(!owner->result_ok);
8009         return DecodeError_clone(&*owner->contents.err);
8010 }
8011 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_get_err(int64_t owner) {
8012         LDKCResult_SocketAddressDecodeErrorZ* owner_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(owner);
8013         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8014         *ret_copy = CResult_SocketAddressDecodeErrorZ_get_err(owner_conv);
8015         int64_t ret_ref = tag_ptr(ret_copy, true);
8016         return ret_ref;
8017 }
8018
8019 static inline struct LDKSocketAddress CResult_SocketAddressSocketAddressParseErrorZ_get_ok(LDKCResult_SocketAddressSocketAddressParseErrorZ *NONNULL_PTR owner){
8020 CHECK(owner->result_ok);
8021         return SocketAddress_clone(&*owner->contents.result);
8022 }
8023 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_get_ok(int64_t owner) {
8024         LDKCResult_SocketAddressSocketAddressParseErrorZ* owner_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(owner);
8025         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
8026         *ret_copy = CResult_SocketAddressSocketAddressParseErrorZ_get_ok(owner_conv);
8027         int64_t ret_ref = tag_ptr(ret_copy, true);
8028         return ret_ref;
8029 }
8030
8031 static inline enum LDKSocketAddressParseError CResult_SocketAddressSocketAddressParseErrorZ_get_err(LDKCResult_SocketAddressSocketAddressParseErrorZ *NONNULL_PTR owner){
8032 CHECK(!owner->result_ok);
8033         return SocketAddressParseError_clone(&*owner->contents.err);
8034 }
8035 int32_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_get_err(int64_t owner) {
8036         LDKCResult_SocketAddressSocketAddressParseErrorZ* owner_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(owner);
8037         int32_t ret_conv = LDKSocketAddressParseError_to_cs(CResult_SocketAddressSocketAddressParseErrorZ_get_err(owner_conv));
8038         return ret_conv;
8039 }
8040
8041 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
8042         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
8043         for (size_t i = 0; i < ret.datalen; i++) {
8044                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
8045         }
8046         return ret;
8047 }
8048 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
8049         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
8050         for (size_t i = 0; i < ret.datalen; i++) {
8051                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
8052         }
8053         return ret;
8054 }
8055 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
8056         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
8057         for (size_t i = 0; i < ret.datalen; i++) {
8058                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
8059         }
8060         return ret;
8061 }
8062 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
8063         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
8064         for (size_t i = 0; i < ret.datalen; i++) {
8065                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
8066         }
8067         return ret;
8068 }
8069 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8070         LDKAcceptChannel ret = *owner->contents.result;
8071         ret.is_owned = false;
8072         return ret;
8073 }
8074 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_get_ok(int64_t owner) {
8075         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
8076         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
8077         int64_t ret_ref = 0;
8078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8080         return ret_ref;
8081 }
8082
8083 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
8084 CHECK(!owner->result_ok);
8085         return DecodeError_clone(&*owner->contents.err);
8086 }
8087 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_get_err(int64_t owner) {
8088         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
8089         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8090         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
8091         int64_t ret_ref = tag_ptr(ret_copy, true);
8092         return ret_ref;
8093 }
8094
8095 static inline struct LDKAcceptChannelV2 CResult_AcceptChannelV2DecodeErrorZ_get_ok(LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR owner){
8096         LDKAcceptChannelV2 ret = *owner->contents.result;
8097         ret.is_owned = false;
8098         return ret;
8099 }
8100 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_get_ok(int64_t owner) {
8101         LDKCResult_AcceptChannelV2DecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(owner);
8102         LDKAcceptChannelV2 ret_var = CResult_AcceptChannelV2DecodeErrorZ_get_ok(owner_conv);
8103         int64_t ret_ref = 0;
8104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8106         return ret_ref;
8107 }
8108
8109 static inline struct LDKDecodeError CResult_AcceptChannelV2DecodeErrorZ_get_err(LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR owner){
8110 CHECK(!owner->result_ok);
8111         return DecodeError_clone(&*owner->contents.err);
8112 }
8113 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_get_err(int64_t owner) {
8114         LDKCResult_AcceptChannelV2DecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(owner);
8115         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8116         *ret_copy = CResult_AcceptChannelV2DecodeErrorZ_get_err(owner_conv);
8117         int64_t ret_ref = tag_ptr(ret_copy, true);
8118         return ret_ref;
8119 }
8120
8121 static inline struct LDKTxAddInput CResult_TxAddInputDecodeErrorZ_get_ok(LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR owner){
8122         LDKTxAddInput ret = *owner->contents.result;
8123         ret.is_owned = false;
8124         return ret;
8125 }
8126 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_get_ok(int64_t owner) {
8127         LDKCResult_TxAddInputDecodeErrorZ* owner_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(owner);
8128         LDKTxAddInput ret_var = CResult_TxAddInputDecodeErrorZ_get_ok(owner_conv);
8129         int64_t ret_ref = 0;
8130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8132         return ret_ref;
8133 }
8134
8135 static inline struct LDKDecodeError CResult_TxAddInputDecodeErrorZ_get_err(LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR owner){
8136 CHECK(!owner->result_ok);
8137         return DecodeError_clone(&*owner->contents.err);
8138 }
8139 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_get_err(int64_t owner) {
8140         LDKCResult_TxAddInputDecodeErrorZ* owner_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(owner);
8141         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8142         *ret_copy = CResult_TxAddInputDecodeErrorZ_get_err(owner_conv);
8143         int64_t ret_ref = tag_ptr(ret_copy, true);
8144         return ret_ref;
8145 }
8146
8147 static inline struct LDKTxAddOutput CResult_TxAddOutputDecodeErrorZ_get_ok(LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR owner){
8148         LDKTxAddOutput ret = *owner->contents.result;
8149         ret.is_owned = false;
8150         return ret;
8151 }
8152 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_get_ok(int64_t owner) {
8153         LDKCResult_TxAddOutputDecodeErrorZ* owner_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(owner);
8154         LDKTxAddOutput ret_var = CResult_TxAddOutputDecodeErrorZ_get_ok(owner_conv);
8155         int64_t ret_ref = 0;
8156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8158         return ret_ref;
8159 }
8160
8161 static inline struct LDKDecodeError CResult_TxAddOutputDecodeErrorZ_get_err(LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR owner){
8162 CHECK(!owner->result_ok);
8163         return DecodeError_clone(&*owner->contents.err);
8164 }
8165 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_get_err(int64_t owner) {
8166         LDKCResult_TxAddOutputDecodeErrorZ* owner_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(owner);
8167         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8168         *ret_copy = CResult_TxAddOutputDecodeErrorZ_get_err(owner_conv);
8169         int64_t ret_ref = tag_ptr(ret_copy, true);
8170         return ret_ref;
8171 }
8172
8173 static inline struct LDKTxRemoveInput CResult_TxRemoveInputDecodeErrorZ_get_ok(LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR owner){
8174         LDKTxRemoveInput ret = *owner->contents.result;
8175         ret.is_owned = false;
8176         return ret;
8177 }
8178 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_get_ok(int64_t owner) {
8179         LDKCResult_TxRemoveInputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(owner);
8180         LDKTxRemoveInput ret_var = CResult_TxRemoveInputDecodeErrorZ_get_ok(owner_conv);
8181         int64_t ret_ref = 0;
8182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8183         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8184         return ret_ref;
8185 }
8186
8187 static inline struct LDKDecodeError CResult_TxRemoveInputDecodeErrorZ_get_err(LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR owner){
8188 CHECK(!owner->result_ok);
8189         return DecodeError_clone(&*owner->contents.err);
8190 }
8191 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_get_err(int64_t owner) {
8192         LDKCResult_TxRemoveInputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(owner);
8193         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8194         *ret_copy = CResult_TxRemoveInputDecodeErrorZ_get_err(owner_conv);
8195         int64_t ret_ref = tag_ptr(ret_copy, true);
8196         return ret_ref;
8197 }
8198
8199 static inline struct LDKTxRemoveOutput CResult_TxRemoveOutputDecodeErrorZ_get_ok(LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR owner){
8200         LDKTxRemoveOutput ret = *owner->contents.result;
8201         ret.is_owned = false;
8202         return ret;
8203 }
8204 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_get_ok(int64_t owner) {
8205         LDKCResult_TxRemoveOutputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(owner);
8206         LDKTxRemoveOutput ret_var = CResult_TxRemoveOutputDecodeErrorZ_get_ok(owner_conv);
8207         int64_t ret_ref = 0;
8208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8210         return ret_ref;
8211 }
8212
8213 static inline struct LDKDecodeError CResult_TxRemoveOutputDecodeErrorZ_get_err(LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR owner){
8214 CHECK(!owner->result_ok);
8215         return DecodeError_clone(&*owner->contents.err);
8216 }
8217 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_get_err(int64_t owner) {
8218         LDKCResult_TxRemoveOutputDecodeErrorZ* owner_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(owner);
8219         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8220         *ret_copy = CResult_TxRemoveOutputDecodeErrorZ_get_err(owner_conv);
8221         int64_t ret_ref = tag_ptr(ret_copy, true);
8222         return ret_ref;
8223 }
8224
8225 static inline struct LDKTxComplete CResult_TxCompleteDecodeErrorZ_get_ok(LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR owner){
8226         LDKTxComplete ret = *owner->contents.result;
8227         ret.is_owned = false;
8228         return ret;
8229 }
8230 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_get_ok(int64_t owner) {
8231         LDKCResult_TxCompleteDecodeErrorZ* owner_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(owner);
8232         LDKTxComplete ret_var = CResult_TxCompleteDecodeErrorZ_get_ok(owner_conv);
8233         int64_t ret_ref = 0;
8234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8236         return ret_ref;
8237 }
8238
8239 static inline struct LDKDecodeError CResult_TxCompleteDecodeErrorZ_get_err(LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR owner){
8240 CHECK(!owner->result_ok);
8241         return DecodeError_clone(&*owner->contents.err);
8242 }
8243 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_get_err(int64_t owner) {
8244         LDKCResult_TxCompleteDecodeErrorZ* owner_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(owner);
8245         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8246         *ret_copy = CResult_TxCompleteDecodeErrorZ_get_err(owner_conv);
8247         int64_t ret_ref = tag_ptr(ret_copy, true);
8248         return ret_ref;
8249 }
8250
8251 static inline struct LDKTxSignatures CResult_TxSignaturesDecodeErrorZ_get_ok(LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR owner){
8252         LDKTxSignatures ret = *owner->contents.result;
8253         ret.is_owned = false;
8254         return ret;
8255 }
8256 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_get_ok(int64_t owner) {
8257         LDKCResult_TxSignaturesDecodeErrorZ* owner_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(owner);
8258         LDKTxSignatures ret_var = CResult_TxSignaturesDecodeErrorZ_get_ok(owner_conv);
8259         int64_t ret_ref = 0;
8260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8262         return ret_ref;
8263 }
8264
8265 static inline struct LDKDecodeError CResult_TxSignaturesDecodeErrorZ_get_err(LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR owner){
8266 CHECK(!owner->result_ok);
8267         return DecodeError_clone(&*owner->contents.err);
8268 }
8269 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_get_err(int64_t owner) {
8270         LDKCResult_TxSignaturesDecodeErrorZ* owner_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(owner);
8271         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8272         *ret_copy = CResult_TxSignaturesDecodeErrorZ_get_err(owner_conv);
8273         int64_t ret_ref = tag_ptr(ret_copy, true);
8274         return ret_ref;
8275 }
8276
8277 static inline struct LDKTxInitRbf CResult_TxInitRbfDecodeErrorZ_get_ok(LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR owner){
8278         LDKTxInitRbf ret = *owner->contents.result;
8279         ret.is_owned = false;
8280         return ret;
8281 }
8282 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_get_ok(int64_t owner) {
8283         LDKCResult_TxInitRbfDecodeErrorZ* owner_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(owner);
8284         LDKTxInitRbf ret_var = CResult_TxInitRbfDecodeErrorZ_get_ok(owner_conv);
8285         int64_t ret_ref = 0;
8286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8288         return ret_ref;
8289 }
8290
8291 static inline struct LDKDecodeError CResult_TxInitRbfDecodeErrorZ_get_err(LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR owner){
8292 CHECK(!owner->result_ok);
8293         return DecodeError_clone(&*owner->contents.err);
8294 }
8295 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_get_err(int64_t owner) {
8296         LDKCResult_TxInitRbfDecodeErrorZ* owner_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(owner);
8297         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8298         *ret_copy = CResult_TxInitRbfDecodeErrorZ_get_err(owner_conv);
8299         int64_t ret_ref = tag_ptr(ret_copy, true);
8300         return ret_ref;
8301 }
8302
8303 static inline struct LDKTxAckRbf CResult_TxAckRbfDecodeErrorZ_get_ok(LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR owner){
8304         LDKTxAckRbf ret = *owner->contents.result;
8305         ret.is_owned = false;
8306         return ret;
8307 }
8308 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_get_ok(int64_t owner) {
8309         LDKCResult_TxAckRbfDecodeErrorZ* owner_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(owner);
8310         LDKTxAckRbf ret_var = CResult_TxAckRbfDecodeErrorZ_get_ok(owner_conv);
8311         int64_t ret_ref = 0;
8312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8314         return ret_ref;
8315 }
8316
8317 static inline struct LDKDecodeError CResult_TxAckRbfDecodeErrorZ_get_err(LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR owner){
8318 CHECK(!owner->result_ok);
8319         return DecodeError_clone(&*owner->contents.err);
8320 }
8321 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_get_err(int64_t owner) {
8322         LDKCResult_TxAckRbfDecodeErrorZ* owner_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(owner);
8323         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8324         *ret_copy = CResult_TxAckRbfDecodeErrorZ_get_err(owner_conv);
8325         int64_t ret_ref = tag_ptr(ret_copy, true);
8326         return ret_ref;
8327 }
8328
8329 static inline struct LDKTxAbort CResult_TxAbortDecodeErrorZ_get_ok(LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR owner){
8330         LDKTxAbort ret = *owner->contents.result;
8331         ret.is_owned = false;
8332         return ret;
8333 }
8334 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_get_ok(int64_t owner) {
8335         LDKCResult_TxAbortDecodeErrorZ* owner_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(owner);
8336         LDKTxAbort ret_var = CResult_TxAbortDecodeErrorZ_get_ok(owner_conv);
8337         int64_t ret_ref = 0;
8338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8340         return ret_ref;
8341 }
8342
8343 static inline struct LDKDecodeError CResult_TxAbortDecodeErrorZ_get_err(LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR owner){
8344 CHECK(!owner->result_ok);
8345         return DecodeError_clone(&*owner->contents.err);
8346 }
8347 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_get_err(int64_t owner) {
8348         LDKCResult_TxAbortDecodeErrorZ* owner_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(owner);
8349         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8350         *ret_copy = CResult_TxAbortDecodeErrorZ_get_err(owner_conv);
8351         int64_t ret_ref = tag_ptr(ret_copy, true);
8352         return ret_ref;
8353 }
8354
8355 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8356         LDKAnnouncementSignatures ret = *owner->contents.result;
8357         ret.is_owned = false;
8358         return ret;
8359 }
8360 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(int64_t owner) {
8361         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
8362         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
8363         int64_t ret_ref = 0;
8364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8366         return ret_ref;
8367 }
8368
8369 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
8370 CHECK(!owner->result_ok);
8371         return DecodeError_clone(&*owner->contents.err);
8372 }
8373 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(int64_t owner) {
8374         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
8375         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8376         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
8377         int64_t ret_ref = tag_ptr(ret_copy, true);
8378         return ret_ref;
8379 }
8380
8381 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8382         LDKChannelReestablish ret = *owner->contents.result;
8383         ret.is_owned = false;
8384         return ret;
8385 }
8386 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_get_ok(int64_t owner) {
8387         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
8388         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
8389         int64_t ret_ref = 0;
8390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8391         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8392         return ret_ref;
8393 }
8394
8395 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
8396 CHECK(!owner->result_ok);
8397         return DecodeError_clone(&*owner->contents.err);
8398 }
8399 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_get_err(int64_t owner) {
8400         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
8401         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8402         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
8403         int64_t ret_ref = tag_ptr(ret_copy, true);
8404         return ret_ref;
8405 }
8406
8407 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8408         LDKClosingSigned ret = *owner->contents.result;
8409         ret.is_owned = false;
8410         return ret;
8411 }
8412 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_get_ok(int64_t owner) {
8413         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
8414         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
8415         int64_t ret_ref = 0;
8416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8417         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8418         return ret_ref;
8419 }
8420
8421 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
8422 CHECK(!owner->result_ok);
8423         return DecodeError_clone(&*owner->contents.err);
8424 }
8425 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_get_err(int64_t owner) {
8426         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
8427         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8428         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
8429         int64_t ret_ref = tag_ptr(ret_copy, true);
8430         return ret_ref;
8431 }
8432
8433 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8434         LDKClosingSignedFeeRange ret = *owner->contents.result;
8435         ret.is_owned = false;
8436         return ret;
8437 }
8438 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(int64_t owner) {
8439         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
8440         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
8441         int64_t ret_ref = 0;
8442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8444         return ret_ref;
8445 }
8446
8447 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
8448 CHECK(!owner->result_ok);
8449         return DecodeError_clone(&*owner->contents.err);
8450 }
8451 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(int64_t owner) {
8452         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
8453         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8454         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
8455         int64_t ret_ref = tag_ptr(ret_copy, true);
8456         return ret_ref;
8457 }
8458
8459 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8460         LDKCommitmentSigned ret = *owner->contents.result;
8461         ret.is_owned = false;
8462         return ret;
8463 }
8464 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_get_ok(int64_t owner) {
8465         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
8466         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
8467         int64_t ret_ref = 0;
8468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8470         return ret_ref;
8471 }
8472
8473 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
8474 CHECK(!owner->result_ok);
8475         return DecodeError_clone(&*owner->contents.err);
8476 }
8477 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_get_err(int64_t owner) {
8478         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
8479         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8480         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
8481         int64_t ret_ref = tag_ptr(ret_copy, true);
8482         return ret_ref;
8483 }
8484
8485 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8486         LDKFundingCreated ret = *owner->contents.result;
8487         ret.is_owned = false;
8488         return ret;
8489 }
8490 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_get_ok(int64_t owner) {
8491         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
8492         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
8493         int64_t ret_ref = 0;
8494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8495         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8496         return ret_ref;
8497 }
8498
8499 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
8500 CHECK(!owner->result_ok);
8501         return DecodeError_clone(&*owner->contents.err);
8502 }
8503 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_get_err(int64_t owner) {
8504         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
8505         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8506         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
8507         int64_t ret_ref = tag_ptr(ret_copy, true);
8508         return ret_ref;
8509 }
8510
8511 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8512         LDKFundingSigned ret = *owner->contents.result;
8513         ret.is_owned = false;
8514         return ret;
8515 }
8516 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_get_ok(int64_t owner) {
8517         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
8518         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
8519         int64_t ret_ref = 0;
8520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8522         return ret_ref;
8523 }
8524
8525 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
8526 CHECK(!owner->result_ok);
8527         return DecodeError_clone(&*owner->contents.err);
8528 }
8529 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_get_err(int64_t owner) {
8530         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
8531         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8532         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
8533         int64_t ret_ref = tag_ptr(ret_copy, true);
8534         return ret_ref;
8535 }
8536
8537 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8538         LDKChannelReady ret = *owner->contents.result;
8539         ret.is_owned = false;
8540         return ret;
8541 }
8542 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_get_ok(int64_t owner) {
8543         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
8544         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
8545         int64_t ret_ref = 0;
8546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8548         return ret_ref;
8549 }
8550
8551 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
8552 CHECK(!owner->result_ok);
8553         return DecodeError_clone(&*owner->contents.err);
8554 }
8555 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_get_err(int64_t owner) {
8556         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
8557         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8558         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
8559         int64_t ret_ref = tag_ptr(ret_copy, true);
8560         return ret_ref;
8561 }
8562
8563 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8564         LDKInit ret = *owner->contents.result;
8565         ret.is_owned = false;
8566         return ret;
8567 }
8568 int64_t  CS_LDK_CResult_InitDecodeErrorZ_get_ok(int64_t owner) {
8569         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
8570         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
8571         int64_t ret_ref = 0;
8572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8573         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8574         return ret_ref;
8575 }
8576
8577 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
8578 CHECK(!owner->result_ok);
8579         return DecodeError_clone(&*owner->contents.err);
8580 }
8581 int64_t  CS_LDK_CResult_InitDecodeErrorZ_get_err(int64_t owner) {
8582         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
8583         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8584         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
8585         int64_t ret_ref = tag_ptr(ret_copy, true);
8586         return ret_ref;
8587 }
8588
8589 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8590         LDKOpenChannel ret = *owner->contents.result;
8591         ret.is_owned = false;
8592         return ret;
8593 }
8594 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_get_ok(int64_t owner) {
8595         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
8596         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
8597         int64_t ret_ref = 0;
8598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8599         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8600         return ret_ref;
8601 }
8602
8603 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
8604 CHECK(!owner->result_ok);
8605         return DecodeError_clone(&*owner->contents.err);
8606 }
8607 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_get_err(int64_t owner) {
8608         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
8609         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8610         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
8611         int64_t ret_ref = tag_ptr(ret_copy, true);
8612         return ret_ref;
8613 }
8614
8615 static inline struct LDKOpenChannelV2 CResult_OpenChannelV2DecodeErrorZ_get_ok(LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR owner){
8616         LDKOpenChannelV2 ret = *owner->contents.result;
8617         ret.is_owned = false;
8618         return ret;
8619 }
8620 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_get_ok(int64_t owner) {
8621         LDKCResult_OpenChannelV2DecodeErrorZ* owner_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(owner);
8622         LDKOpenChannelV2 ret_var = CResult_OpenChannelV2DecodeErrorZ_get_ok(owner_conv);
8623         int64_t ret_ref = 0;
8624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8626         return ret_ref;
8627 }
8628
8629 static inline struct LDKDecodeError CResult_OpenChannelV2DecodeErrorZ_get_err(LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR owner){
8630 CHECK(!owner->result_ok);
8631         return DecodeError_clone(&*owner->contents.err);
8632 }
8633 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_get_err(int64_t owner) {
8634         LDKCResult_OpenChannelV2DecodeErrorZ* owner_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(owner);
8635         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8636         *ret_copy = CResult_OpenChannelV2DecodeErrorZ_get_err(owner_conv);
8637         int64_t ret_ref = tag_ptr(ret_copy, true);
8638         return ret_ref;
8639 }
8640
8641 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8642         LDKRevokeAndACK ret = *owner->contents.result;
8643         ret.is_owned = false;
8644         return ret;
8645 }
8646 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_get_ok(int64_t owner) {
8647         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
8648         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
8649         int64_t ret_ref = 0;
8650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8652         return ret_ref;
8653 }
8654
8655 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
8656 CHECK(!owner->result_ok);
8657         return DecodeError_clone(&*owner->contents.err);
8658 }
8659 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_get_err(int64_t owner) {
8660         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
8661         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8662         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
8663         int64_t ret_ref = tag_ptr(ret_copy, true);
8664         return ret_ref;
8665 }
8666
8667 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8668         LDKShutdown ret = *owner->contents.result;
8669         ret.is_owned = false;
8670         return ret;
8671 }
8672 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_get_ok(int64_t owner) {
8673         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
8674         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
8675         int64_t ret_ref = 0;
8676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8678         return ret_ref;
8679 }
8680
8681 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
8682 CHECK(!owner->result_ok);
8683         return DecodeError_clone(&*owner->contents.err);
8684 }
8685 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_get_err(int64_t owner) {
8686         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
8687         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8688         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
8689         int64_t ret_ref = tag_ptr(ret_copy, true);
8690         return ret_ref;
8691 }
8692
8693 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8694         LDKUpdateFailHTLC ret = *owner->contents.result;
8695         ret.is_owned = false;
8696         return ret;
8697 }
8698 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(int64_t owner) {
8699         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
8700         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
8701         int64_t ret_ref = 0;
8702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8704         return ret_ref;
8705 }
8706
8707 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
8708 CHECK(!owner->result_ok);
8709         return DecodeError_clone(&*owner->contents.err);
8710 }
8711 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_get_err(int64_t owner) {
8712         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
8713         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8714         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
8715         int64_t ret_ref = tag_ptr(ret_copy, true);
8716         return ret_ref;
8717 }
8718
8719 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8720         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
8721         ret.is_owned = false;
8722         return ret;
8723 }
8724 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(int64_t owner) {
8725         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
8726         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
8727         int64_t ret_ref = 0;
8728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8729         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8730         return ret_ref;
8731 }
8732
8733 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
8734 CHECK(!owner->result_ok);
8735         return DecodeError_clone(&*owner->contents.err);
8736 }
8737 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(int64_t owner) {
8738         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
8739         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8740         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
8741         int64_t ret_ref = tag_ptr(ret_copy, true);
8742         return ret_ref;
8743 }
8744
8745 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8746         LDKUpdateFee ret = *owner->contents.result;
8747         ret.is_owned = false;
8748         return ret;
8749 }
8750 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_get_ok(int64_t owner) {
8751         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
8752         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
8753         int64_t ret_ref = 0;
8754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8756         return ret_ref;
8757 }
8758
8759 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
8760 CHECK(!owner->result_ok);
8761         return DecodeError_clone(&*owner->contents.err);
8762 }
8763 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_get_err(int64_t owner) {
8764         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
8765         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8766         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
8767         int64_t ret_ref = tag_ptr(ret_copy, true);
8768         return ret_ref;
8769 }
8770
8771 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8772         LDKUpdateFulfillHTLC ret = *owner->contents.result;
8773         ret.is_owned = false;
8774         return ret;
8775 }
8776 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(int64_t owner) {
8777         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
8778         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
8779         int64_t ret_ref = 0;
8780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8782         return ret_ref;
8783 }
8784
8785 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
8786 CHECK(!owner->result_ok);
8787         return DecodeError_clone(&*owner->contents.err);
8788 }
8789 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(int64_t owner) {
8790         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
8791         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8792         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
8793         int64_t ret_ref = tag_ptr(ret_copy, true);
8794         return ret_ref;
8795 }
8796
8797 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8798         LDKUpdateAddHTLC ret = *owner->contents.result;
8799         ret.is_owned = false;
8800         return ret;
8801 }
8802 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(int64_t owner) {
8803         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
8804         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
8805         int64_t ret_ref = 0;
8806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8807         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8808         return ret_ref;
8809 }
8810
8811 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
8812 CHECK(!owner->result_ok);
8813         return DecodeError_clone(&*owner->contents.err);
8814 }
8815 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_get_err(int64_t owner) {
8816         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
8817         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8818         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
8819         int64_t ret_ref = tag_ptr(ret_copy, true);
8820         return ret_ref;
8821 }
8822
8823 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
8824         LDKOnionMessage ret = *owner->contents.result;
8825         ret.is_owned = false;
8826         return ret;
8827 }
8828 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_get_ok(int64_t owner) {
8829         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
8830         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
8831         int64_t ret_ref = 0;
8832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8834         return ret_ref;
8835 }
8836
8837 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
8838 CHECK(!owner->result_ok);
8839         return DecodeError_clone(&*owner->contents.err);
8840 }
8841 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_get_err(int64_t owner) {
8842         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
8843         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8844         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
8845         int64_t ret_ref = tag_ptr(ret_copy, true);
8846         return ret_ref;
8847 }
8848
8849 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8850         LDKPing ret = *owner->contents.result;
8851         ret.is_owned = false;
8852         return ret;
8853 }
8854 int64_t  CS_LDK_CResult_PingDecodeErrorZ_get_ok(int64_t owner) {
8855         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
8856         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
8857         int64_t ret_ref = 0;
8858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8860         return ret_ref;
8861 }
8862
8863 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
8864 CHECK(!owner->result_ok);
8865         return DecodeError_clone(&*owner->contents.err);
8866 }
8867 int64_t  CS_LDK_CResult_PingDecodeErrorZ_get_err(int64_t owner) {
8868         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
8869         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8870         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
8871         int64_t ret_ref = tag_ptr(ret_copy, true);
8872         return ret_ref;
8873 }
8874
8875 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8876         LDKPong ret = *owner->contents.result;
8877         ret.is_owned = false;
8878         return ret;
8879 }
8880 int64_t  CS_LDK_CResult_PongDecodeErrorZ_get_ok(int64_t owner) {
8881         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
8882         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
8883         int64_t ret_ref = 0;
8884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8886         return ret_ref;
8887 }
8888
8889 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
8890 CHECK(!owner->result_ok);
8891         return DecodeError_clone(&*owner->contents.err);
8892 }
8893 int64_t  CS_LDK_CResult_PongDecodeErrorZ_get_err(int64_t owner) {
8894         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
8895         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8896         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
8897         int64_t ret_ref = tag_ptr(ret_copy, true);
8898         return ret_ref;
8899 }
8900
8901 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8902         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
8903         ret.is_owned = false;
8904         return ret;
8905 }
8906 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
8907         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8908         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8909         int64_t ret_ref = 0;
8910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8912         return ret_ref;
8913 }
8914
8915 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8916 CHECK(!owner->result_ok);
8917         return DecodeError_clone(&*owner->contents.err);
8918 }
8919 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(int64_t owner) {
8920         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8921         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8922         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8923         int64_t ret_ref = tag_ptr(ret_copy, true);
8924         return ret_ref;
8925 }
8926
8927 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8928         LDKChannelAnnouncement ret = *owner->contents.result;
8929         ret.is_owned = false;
8930         return ret;
8931 }
8932 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
8933         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8934         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
8935         int64_t ret_ref = 0;
8936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8937         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8938         return ret_ref;
8939 }
8940
8941 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
8942 CHECK(!owner->result_ok);
8943         return DecodeError_clone(&*owner->contents.err);
8944 }
8945 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_get_err(int64_t owner) {
8946         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
8947         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8948         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
8949         int64_t ret_ref = tag_ptr(ret_copy, true);
8950         return ret_ref;
8951 }
8952
8953 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8954         LDKUnsignedChannelUpdate ret = *owner->contents.result;
8955         ret.is_owned = false;
8956         return ret;
8957 }
8958 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(int64_t owner) {
8959         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8960         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8961         int64_t ret_ref = 0;
8962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8964         return ret_ref;
8965 }
8966
8967 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8968 CHECK(!owner->result_ok);
8969         return DecodeError_clone(&*owner->contents.err);
8970 }
8971 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(int64_t owner) {
8972         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8973         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8974         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
8975         int64_t ret_ref = tag_ptr(ret_copy, true);
8976         return ret_ref;
8977 }
8978
8979 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8980         LDKChannelUpdate ret = *owner->contents.result;
8981         ret.is_owned = false;
8982         return ret;
8983 }
8984 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_get_ok(int64_t owner) {
8985         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8986         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
8987         int64_t ret_ref = 0;
8988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8989         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8990         return ret_ref;
8991 }
8992
8993 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
8994 CHECK(!owner->result_ok);
8995         return DecodeError_clone(&*owner->contents.err);
8996 }
8997 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_get_err(int64_t owner) {
8998         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
8999         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9000         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9001         int64_t ret_ref = tag_ptr(ret_copy, true);
9002         return ret_ref;
9003 }
9004
9005 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9006         LDKErrorMessage ret = *owner->contents.result;
9007         ret.is_owned = false;
9008         return ret;
9009 }
9010 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_get_ok(int64_t owner) {
9011         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
9012         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9013         int64_t ret_ref = 0;
9014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9016         return ret_ref;
9017 }
9018
9019 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9020 CHECK(!owner->result_ok);
9021         return DecodeError_clone(&*owner->contents.err);
9022 }
9023 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_get_err(int64_t owner) {
9024         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
9025         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9026         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9027         int64_t ret_ref = tag_ptr(ret_copy, true);
9028         return ret_ref;
9029 }
9030
9031 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9032         LDKWarningMessage ret = *owner->contents.result;
9033         ret.is_owned = false;
9034         return ret;
9035 }
9036 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_get_ok(int64_t owner) {
9037         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
9038         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9039         int64_t ret_ref = 0;
9040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9042         return ret_ref;
9043 }
9044
9045 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9046 CHECK(!owner->result_ok);
9047         return DecodeError_clone(&*owner->contents.err);
9048 }
9049 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_get_err(int64_t owner) {
9050         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
9051         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9052         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9053         int64_t ret_ref = tag_ptr(ret_copy, true);
9054         return ret_ref;
9055 }
9056
9057 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9058         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
9059         ret.is_owned = false;
9060         return ret;
9061 }
9062 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
9063         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9064         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9065         int64_t ret_ref = 0;
9066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9067         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9068         return ret_ref;
9069 }
9070
9071 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9072 CHECK(!owner->result_ok);
9073         return DecodeError_clone(&*owner->contents.err);
9074 }
9075 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(int64_t owner) {
9076         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9077         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9078         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9079         int64_t ret_ref = tag_ptr(ret_copy, true);
9080         return ret_ref;
9081 }
9082
9083 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9084         LDKNodeAnnouncement ret = *owner->contents.result;
9085         ret.is_owned = false;
9086         return ret;
9087 }
9088 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_get_ok(int64_t owner) {
9089         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9090         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9091         int64_t ret_ref = 0;
9092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9093         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9094         return ret_ref;
9095 }
9096
9097 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9098 CHECK(!owner->result_ok);
9099         return DecodeError_clone(&*owner->contents.err);
9100 }
9101 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_get_err(int64_t owner) {
9102         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9103         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9104         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
9105         int64_t ret_ref = tag_ptr(ret_copy, true);
9106         return ret_ref;
9107 }
9108
9109 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9110         LDKQueryShortChannelIds ret = *owner->contents.result;
9111         ret.is_owned = false;
9112         return ret;
9113 }
9114 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(int64_t owner) {
9115         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
9116         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
9117         int64_t ret_ref = 0;
9118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9120         return ret_ref;
9121 }
9122
9123 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
9124 CHECK(!owner->result_ok);
9125         return DecodeError_clone(&*owner->contents.err);
9126 }
9127 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(int64_t owner) {
9128         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
9129         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9130         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
9131         int64_t ret_ref = tag_ptr(ret_copy, true);
9132         return ret_ref;
9133 }
9134
9135 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9136         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
9137         ret.is_owned = false;
9138         return ret;
9139 }
9140 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(int64_t owner) {
9141         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
9142         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
9143         int64_t ret_ref = 0;
9144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9145         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9146         return ret_ref;
9147 }
9148
9149 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
9150 CHECK(!owner->result_ok);
9151         return DecodeError_clone(&*owner->contents.err);
9152 }
9153 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(int64_t owner) {
9154         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
9155         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9156         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
9157         int64_t ret_ref = tag_ptr(ret_copy, true);
9158         return ret_ref;
9159 }
9160
9161 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9162         LDKQueryChannelRange ret = *owner->contents.result;
9163         ret.is_owned = false;
9164         return ret;
9165 }
9166 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_get_ok(int64_t owner) {
9167         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
9168         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
9169         int64_t ret_ref = 0;
9170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9172         return ret_ref;
9173 }
9174
9175 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9176 CHECK(!owner->result_ok);
9177         return DecodeError_clone(&*owner->contents.err);
9178 }
9179 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_get_err(int64_t owner) {
9180         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
9181         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9182         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
9183         int64_t ret_ref = tag_ptr(ret_copy, true);
9184         return ret_ref;
9185 }
9186
9187 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9188         LDKReplyChannelRange ret = *owner->contents.result;
9189         ret.is_owned = false;
9190         return ret;
9191 }
9192 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(int64_t owner) {
9193         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
9194         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
9195         int64_t ret_ref = 0;
9196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9198         return ret_ref;
9199 }
9200
9201 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
9202 CHECK(!owner->result_ok);
9203         return DecodeError_clone(&*owner->contents.err);
9204 }
9205 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_get_err(int64_t owner) {
9206         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
9207         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9208         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
9209         int64_t ret_ref = tag_ptr(ret_copy, true);
9210         return ret_ref;
9211 }
9212
9213 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9214         LDKGossipTimestampFilter ret = *owner->contents.result;
9215         ret.is_owned = false;
9216         return ret;
9217 }
9218 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(int64_t owner) {
9219         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
9220         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
9221         int64_t ret_ref = 0;
9222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9223         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9224         return ret_ref;
9225 }
9226
9227 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
9228 CHECK(!owner->result_ok);
9229         return DecodeError_clone(&*owner->contents.err);
9230 }
9231 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_get_err(int64_t owner) {
9232         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
9233         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9234         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
9235         int64_t ret_ref = tag_ptr(ret_copy, true);
9236         return ret_ref;
9237 }
9238
9239 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
9240         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
9241         for (size_t i = 0; i < ret.datalen; i++) {
9242                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
9243         }
9244         return ret;
9245 }
9246 uint32_t CS_LDK_LDKSignOrCreationError_ty_from_ptr(int64_t ptr) {
9247         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
9248         switch(obj->tag) {
9249                 case LDKSignOrCreationError_SignError: return 0;
9250                 case LDKSignOrCreationError_CreationError: return 1;
9251                 default: abort();
9252         }
9253 }
9254 int32_t CS_LDK_LDKSignOrCreationError_CreationError_get_creation_error(int64_t ptr) {
9255         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
9256         CHECK(obj->tag == LDKSignOrCreationError_CreationError);
9257         int32_t creation_error_conv = LDKCreationError_to_cs(obj->creation_error);
9258         return creation_error_conv;
9259 }
9260 static inline struct LDKBolt11Invoice CResult_Bolt11InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9261         LDKBolt11Invoice ret = *owner->contents.result;
9262         ret.is_owned = false;
9263         return ret;
9264 }
9265 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_get_ok(int64_t owner) {
9266         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
9267         LDKBolt11Invoice ret_var = CResult_Bolt11InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
9268         int64_t ret_ref = 0;
9269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9270         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9271         return ret_ref;
9272 }
9273
9274 static inline struct LDKSignOrCreationError CResult_Bolt11InvoiceSignOrCreationErrorZ_get_err(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
9275 CHECK(!owner->result_ok);
9276         return SignOrCreationError_clone(&*owner->contents.err);
9277 }
9278 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_get_err(int64_t owner) {
9279         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
9280         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
9281         *ret_copy = CResult_Bolt11InvoiceSignOrCreationErrorZ_get_err(owner_conv);
9282         int64_t ret_ref = tag_ptr(ret_copy, true);
9283         return ret_ref;
9284 }
9285
9286 static inline LDKCVec_FutureZ CVec_FutureZ_clone(const LDKCVec_FutureZ *orig) {
9287         LDKCVec_FutureZ ret = { .data = MALLOC(sizeof(LDKFuture) * orig->datalen, "LDKCVec_FutureZ clone bytes"), .datalen = orig->datalen };
9288         for (size_t i = 0; i < ret.datalen; i++) {
9289                 ret.data[i] = Future_clone(&orig->data[i]);
9290         }
9291         return ret;
9292 }
9293 static inline struct LDKOffersMessage CResult_OffersMessageDecodeErrorZ_get_ok(LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR owner){
9294 CHECK(owner->result_ok);
9295         return OffersMessage_clone(&*owner->contents.result);
9296 }
9297 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_get_ok(int64_t owner) {
9298         LDKCResult_OffersMessageDecodeErrorZ* owner_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(owner);
9299         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
9300         *ret_copy = CResult_OffersMessageDecodeErrorZ_get_ok(owner_conv);
9301         int64_t ret_ref = tag_ptr(ret_copy, true);
9302         return ret_ref;
9303 }
9304
9305 static inline struct LDKDecodeError CResult_OffersMessageDecodeErrorZ_get_err(LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR owner){
9306 CHECK(!owner->result_ok);
9307         return DecodeError_clone(&*owner->contents.err);
9308 }
9309 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_get_err(int64_t owner) {
9310         LDKCResult_OffersMessageDecodeErrorZ* owner_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(owner);
9311         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9312         *ret_copy = CResult_OffersMessageDecodeErrorZ_get_err(owner_conv);
9313         int64_t ret_ref = tag_ptr(ret_copy, true);
9314         return ret_ref;
9315 }
9316
9317 uint32_t CS_LDK_LDKCOption_HTLCClaimZ_ty_from_ptr(int64_t ptr) {
9318         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
9319         switch(obj->tag) {
9320                 case LDKCOption_HTLCClaimZ_Some: return 0;
9321                 case LDKCOption_HTLCClaimZ_None: return 1;
9322                 default: abort();
9323         }
9324 }
9325 int32_t CS_LDK_LDKCOption_HTLCClaimZ_Some_get_some(int64_t ptr) {
9326         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
9327         CHECK(obj->tag == LDKCOption_HTLCClaimZ_Some);
9328         int32_t some_conv = LDKHTLCClaim_to_cs(obj->some);
9329         return some_conv;
9330 }
9331 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
9332         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
9333         ret.is_owned = false;
9334         return ret;
9335 }
9336 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(int64_t owner) {
9337         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
9338         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
9339         int64_t ret_ref = 0;
9340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9342         return ret_ref;
9343 }
9344
9345 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
9346 CHECK(!owner->result_ok);
9347         return DecodeError_clone(&*owner->contents.err);
9348 }
9349 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(int64_t owner) {
9350         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
9351         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9352         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
9353         int64_t ret_ref = tag_ptr(ret_copy, true);
9354         return ret_ref;
9355 }
9356
9357 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
9358         LDKTxCreationKeys ret = *owner->contents.result;
9359         ret.is_owned = false;
9360         return ret;
9361 }
9362 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_get_ok(int64_t owner) {
9363         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
9364         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
9365         int64_t ret_ref = 0;
9366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9368         return ret_ref;
9369 }
9370
9371 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
9372 CHECK(!owner->result_ok);
9373         return DecodeError_clone(&*owner->contents.err);
9374 }
9375 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_get_err(int64_t owner) {
9376         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
9377         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9378         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
9379         int64_t ret_ref = tag_ptr(ret_copy, true);
9380         return ret_ref;
9381 }
9382
9383 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
9384         LDKChannelPublicKeys ret = *owner->contents.result;
9385         ret.is_owned = false;
9386         return ret;
9387 }
9388 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(int64_t owner) {
9389         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
9390         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
9391         int64_t ret_ref = 0;
9392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9394         return ret_ref;
9395 }
9396
9397 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
9398 CHECK(!owner->result_ok);
9399         return DecodeError_clone(&*owner->contents.err);
9400 }
9401 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_get_err(int64_t owner) {
9402         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
9403         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9404         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
9405         int64_t ret_ref = tag_ptr(ret_copy, true);
9406         return ret_ref;
9407 }
9408
9409 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
9410         LDKHTLCOutputInCommitment ret = *owner->contents.result;
9411         ret.is_owned = false;
9412         return ret;
9413 }
9414 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(int64_t owner) {
9415         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
9416         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
9417         int64_t ret_ref = 0;
9418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9420         return ret_ref;
9421 }
9422
9423 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
9424 CHECK(!owner->result_ok);
9425         return DecodeError_clone(&*owner->contents.err);
9426 }
9427 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(int64_t owner) {
9428         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
9429         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9430         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
9431         int64_t ret_ref = tag_ptr(ret_copy, true);
9432         return ret_ref;
9433 }
9434
9435 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9436         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
9437         ret.is_owned = false;
9438         return ret;
9439 }
9440 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(int64_t owner) {
9441         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9442         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
9443         int64_t ret_ref = 0;
9444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9446         return ret_ref;
9447 }
9448
9449 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9450 CHECK(!owner->result_ok);
9451         return DecodeError_clone(&*owner->contents.err);
9452 }
9453 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(int64_t owner) {
9454         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9455         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9456         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
9457         int64_t ret_ref = tag_ptr(ret_copy, true);
9458         return ret_ref;
9459 }
9460
9461 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9462         LDKChannelTransactionParameters ret = *owner->contents.result;
9463         ret.is_owned = false;
9464         return ret;
9465 }
9466 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(int64_t owner) {
9467         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9468         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
9469         int64_t ret_ref = 0;
9470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9472         return ret_ref;
9473 }
9474
9475 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
9476 CHECK(!owner->result_ok);
9477         return DecodeError_clone(&*owner->contents.err);
9478 }
9479 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(int64_t owner) {
9480         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
9481         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9482         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
9483         int64_t ret_ref = tag_ptr(ret_copy, true);
9484         return ret_ref;
9485 }
9486
9487 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9488         LDKHolderCommitmentTransaction ret = *owner->contents.result;
9489         ret.is_owned = false;
9490         return ret;
9491 }
9492 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(int64_t owner) {
9493         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9494         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
9495         int64_t ret_ref = 0;
9496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9498         return ret_ref;
9499 }
9500
9501 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9502 CHECK(!owner->result_ok);
9503         return DecodeError_clone(&*owner->contents.err);
9504 }
9505 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(int64_t owner) {
9506         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9507         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9508         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
9509         int64_t ret_ref = tag_ptr(ret_copy, true);
9510         return ret_ref;
9511 }
9512
9513 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9514         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
9515         ret.is_owned = false;
9516         return ret;
9517 }
9518 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(int64_t owner) {
9519         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9520         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
9521         int64_t ret_ref = 0;
9522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9523         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9524         return ret_ref;
9525 }
9526
9527 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9528 CHECK(!owner->result_ok);
9529         return DecodeError_clone(&*owner->contents.err);
9530 }
9531 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(int64_t owner) {
9532         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9533         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9534         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
9535         int64_t ret_ref = tag_ptr(ret_copy, true);
9536         return ret_ref;
9537 }
9538
9539 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
9540         LDKTrustedClosingTransaction ret = *owner->contents.result;
9541         ret.is_owned = false;
9542         return ret;
9543 }
9544 int64_t  CS_LDK_CResult_TrustedClosingTransactionNoneZ_get_ok(int64_t owner) {
9545         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
9546         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
9547         int64_t ret_ref = 0;
9548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9549         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9550         return ret_ref;
9551 }
9552
9553 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
9554 CHECK(!owner->result_ok);
9555         return *owner->contents.err;
9556 }
9557 void  CS_LDK_CResult_TrustedClosingTransactionNoneZ_get_err(int64_t owner) {
9558         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
9559         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
9560 }
9561
9562 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9563         LDKCommitmentTransaction ret = *owner->contents.result;
9564         ret.is_owned = false;
9565         return ret;
9566 }
9567 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_get_ok(int64_t owner) {
9568         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9569         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
9570         int64_t ret_ref = 0;
9571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9572         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9573         return ret_ref;
9574 }
9575
9576 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
9577 CHECK(!owner->result_ok);
9578         return DecodeError_clone(&*owner->contents.err);
9579 }
9580 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_get_err(int64_t owner) {
9581         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
9582         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9583         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
9584         int64_t ret_ref = tag_ptr(ret_copy, true);
9585         return ret_ref;
9586 }
9587
9588 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
9589         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
9590         ret.is_owned = false;
9591         return ret;
9592 }
9593 int64_t  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_get_ok(int64_t owner) {
9594         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
9595         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
9596         int64_t ret_ref = 0;
9597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9599         return ret_ref;
9600 }
9601
9602 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
9603 CHECK(!owner->result_ok);
9604         return *owner->contents.err;
9605 }
9606 void  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_get_err(int64_t owner) {
9607         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
9608         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
9609 }
9610
9611 static inline struct LDKCVec_ECDSASignatureZ CResult_CVec_ECDSASignatureZNoneZ_get_ok(LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR owner){
9612 CHECK(owner->result_ok);
9613         return *owner->contents.result;
9614 }
9615 ptrArray  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_get_ok(int64_t owner) {
9616         LDKCResult_CVec_ECDSASignatureZNoneZ* owner_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(owner);
9617         LDKCVec_ECDSASignatureZ ret_var = CResult_CVec_ECDSASignatureZNoneZ_get_ok(owner_conv);
9618         ptrArray ret_arr = NULL;
9619         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
9620         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
9621         for (size_t i = 0; i < ret_var.datalen; i++) {
9622                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
9623                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
9624                 ret_arr_ptr[i] = ret_conv_8_arr;
9625         }
9626         
9627         return ret_arr;
9628 }
9629
9630 static inline void CResult_CVec_ECDSASignatureZNoneZ_get_err(LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR owner){
9631 CHECK(!owner->result_ok);
9632         return *owner->contents.err;
9633 }
9634 void  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_get_err(int64_t owner) {
9635         LDKCResult_CVec_ECDSASignatureZNoneZ* owner_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(owner);
9636         CResult_CVec_ECDSASignatureZNoneZ_get_err(owner_conv);
9637 }
9638
9639 uint32_t CS_LDK_LDKCOption_usizeZ_ty_from_ptr(int64_t ptr) {
9640         LDKCOption_usizeZ *obj = (LDKCOption_usizeZ*)untag_ptr(ptr);
9641         switch(obj->tag) {
9642                 case LDKCOption_usizeZ_Some: return 0;
9643                 case LDKCOption_usizeZ_None: return 1;
9644                 default: abort();
9645         }
9646 }
9647 int64_t CS_LDK_LDKCOption_usizeZ_Some_get_some(int64_t ptr) {
9648         LDKCOption_usizeZ *obj = (LDKCOption_usizeZ*)untag_ptr(ptr);
9649         CHECK(obj->tag == LDKCOption_usizeZ_Some);
9650         int64_t some_conv = obj->some;
9651         return some_conv;
9652 }
9653 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
9654         LDKShutdownScript ret = *owner->contents.result;
9655         ret.is_owned = false;
9656         return ret;
9657 }
9658 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_get_ok(int64_t owner) {
9659         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
9660         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
9661         int64_t ret_ref = 0;
9662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9664         return ret_ref;
9665 }
9666
9667 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
9668 CHECK(!owner->result_ok);
9669         return DecodeError_clone(&*owner->contents.err);
9670 }
9671 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_get_err(int64_t owner) {
9672         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
9673         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9674         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
9675         int64_t ret_ref = tag_ptr(ret_copy, true);
9676         return ret_ref;
9677 }
9678
9679 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
9680         LDKShutdownScript ret = *owner->contents.result;
9681         ret.is_owned = false;
9682         return ret;
9683 }
9684 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(int64_t owner) {
9685         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
9686         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
9687         int64_t ret_ref = 0;
9688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9690         return ret_ref;
9691 }
9692
9693 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
9694         LDKInvalidShutdownScript ret = *owner->contents.err;
9695         ret.is_owned = false;
9696         return ret;
9697 }
9698 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(int64_t owner) {
9699         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
9700         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
9701         int64_t ret_ref = 0;
9702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9704         return ret_ref;
9705 }
9706
9707 uint32_t CS_LDK_LDKPaymentPurpose_ty_from_ptr(int64_t ptr) {
9708         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9709         switch(obj->tag) {
9710                 case LDKPaymentPurpose_InvoicePayment: return 0;
9711                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
9712                 default: abort();
9713         }
9714 }
9715 int64_t CS_LDK_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(int64_t ptr) {
9716         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9717         CHECK(obj->tag == LDKPaymentPurpose_InvoicePayment);
9718         int64_t payment_preimage_ref = tag_ptr(&obj->invoice_payment.payment_preimage, false);
9719         return payment_preimage_ref;
9720 }
9721 int8_tArray CS_LDK_LDKPaymentPurpose_InvoicePayment_get_payment_secret(int64_t ptr) {
9722         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9723         CHECK(obj->tag == LDKPaymentPurpose_InvoicePayment);
9724         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
9725         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
9726         return payment_secret_arr;
9727 }
9728 int8_tArray CS_LDK_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(int64_t ptr) {
9729         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
9730         CHECK(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
9731         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
9732         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
9733         return spontaneous_payment_arr;
9734 }
9735 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
9736 CHECK(owner->result_ok);
9737         return PaymentPurpose_clone(&*owner->contents.result);
9738 }
9739 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_get_ok(int64_t owner) {
9740         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
9741         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
9742         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
9743         int64_t ret_ref = tag_ptr(ret_copy, true);
9744         return ret_ref;
9745 }
9746
9747 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
9748 CHECK(!owner->result_ok);
9749         return DecodeError_clone(&*owner->contents.err);
9750 }
9751 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_get_err(int64_t owner) {
9752         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
9753         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9754         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
9755         int64_t ret_ref = tag_ptr(ret_copy, true);
9756         return ret_ref;
9757 }
9758
9759 static inline struct LDKClaimedHTLC CResult_ClaimedHTLCDecodeErrorZ_get_ok(LDKCResult_ClaimedHTLCDecodeErrorZ *NONNULL_PTR owner){
9760         LDKClaimedHTLC ret = *owner->contents.result;
9761         ret.is_owned = false;
9762         return ret;
9763 }
9764 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_get_ok(int64_t owner) {
9765         LDKCResult_ClaimedHTLCDecodeErrorZ* owner_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(owner);
9766         LDKClaimedHTLC ret_var = CResult_ClaimedHTLCDecodeErrorZ_get_ok(owner_conv);
9767         int64_t ret_ref = 0;
9768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9770         return ret_ref;
9771 }
9772
9773 static inline struct LDKDecodeError CResult_ClaimedHTLCDecodeErrorZ_get_err(LDKCResult_ClaimedHTLCDecodeErrorZ *NONNULL_PTR owner){
9774 CHECK(!owner->result_ok);
9775         return DecodeError_clone(&*owner->contents.err);
9776 }
9777 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_get_err(int64_t owner) {
9778         LDKCResult_ClaimedHTLCDecodeErrorZ* owner_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(owner);
9779         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9780         *ret_copy = CResult_ClaimedHTLCDecodeErrorZ_get_err(owner_conv);
9781         int64_t ret_ref = tag_ptr(ret_copy, true);
9782         return ret_ref;
9783 }
9784
9785 uint32_t CS_LDK_LDKPathFailure_ty_from_ptr(int64_t ptr) {
9786         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
9787         switch(obj->tag) {
9788                 case LDKPathFailure_InitialSend: return 0;
9789                 case LDKPathFailure_OnPath: return 1;
9790                 default: abort();
9791         }
9792 }
9793 int64_t CS_LDK_LDKPathFailure_InitialSend_get_err(int64_t ptr) {
9794         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
9795         CHECK(obj->tag == LDKPathFailure_InitialSend);
9796         int64_t err_ref = tag_ptr(&obj->initial_send.err, false);
9797         return err_ref;
9798 }
9799 int64_t CS_LDK_LDKPathFailure_OnPath_get_network_update(int64_t ptr) {
9800         LDKPathFailure *obj = (LDKPathFailure*)untag_ptr(ptr);
9801         CHECK(obj->tag == LDKPathFailure_OnPath);
9802         int64_t network_update_ref = tag_ptr(&obj->on_path.network_update, false);
9803         return network_update_ref;
9804 }
9805 uint32_t CS_LDK_LDKCOption_PathFailureZ_ty_from_ptr(int64_t ptr) {
9806         LDKCOption_PathFailureZ *obj = (LDKCOption_PathFailureZ*)untag_ptr(ptr);
9807         switch(obj->tag) {
9808                 case LDKCOption_PathFailureZ_Some: return 0;
9809                 case LDKCOption_PathFailureZ_None: return 1;
9810                 default: abort();
9811         }
9812 }
9813 int64_t CS_LDK_LDKCOption_PathFailureZ_Some_get_some(int64_t ptr) {
9814         LDKCOption_PathFailureZ *obj = (LDKCOption_PathFailureZ*)untag_ptr(ptr);
9815         CHECK(obj->tag == LDKCOption_PathFailureZ_Some);
9816         int64_t some_ref = tag_ptr(&obj->some, false);
9817         return some_ref;
9818 }
9819 static inline struct LDKCOption_PathFailureZ CResult_COption_PathFailureZDecodeErrorZ_get_ok(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
9820 CHECK(owner->result_ok);
9821         return COption_PathFailureZ_clone(&*owner->contents.result);
9822 }
9823 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_get_ok(int64_t owner) {
9824         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
9825         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
9826         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_ok(owner_conv);
9827         int64_t ret_ref = tag_ptr(ret_copy, true);
9828         return ret_ref;
9829 }
9830
9831 static inline struct LDKDecodeError CResult_COption_PathFailureZDecodeErrorZ_get_err(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR owner){
9832 CHECK(!owner->result_ok);
9833         return DecodeError_clone(&*owner->contents.err);
9834 }
9835 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_get_err(int64_t owner) {
9836         LDKCResult_COption_PathFailureZDecodeErrorZ* owner_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(owner);
9837         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9838         *ret_copy = CResult_COption_PathFailureZDecodeErrorZ_get_err(owner_conv);
9839         int64_t ret_ref = tag_ptr(ret_copy, true);
9840         return ret_ref;
9841 }
9842
9843 uint32_t CS_LDK_LDKClosureReason_ty_from_ptr(int64_t ptr) {
9844         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
9845         switch(obj->tag) {
9846                 case LDKClosureReason_CounterpartyForceClosed: return 0;
9847                 case LDKClosureReason_HolderForceClosed: return 1;
9848                 case LDKClosureReason_CooperativeClosure: return 2;
9849                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
9850                 case LDKClosureReason_FundingTimedOut: return 4;
9851                 case LDKClosureReason_ProcessingError: return 5;
9852                 case LDKClosureReason_DisconnectedPeer: return 6;
9853                 case LDKClosureReason_OutdatedChannelManager: return 7;
9854                 case LDKClosureReason_CounterpartyCoopClosedUnfundedChannel: return 8;
9855                 case LDKClosureReason_FundingBatchClosure: return 9;
9856                 default: abort();
9857         }
9858 }
9859 int64_t CS_LDK_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(int64_t ptr) {
9860         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
9861         CHECK(obj->tag == LDKClosureReason_CounterpartyForceClosed);
9862         LDKUntrustedString peer_msg_var = obj->counterparty_force_closed.peer_msg;
9863                         int64_t peer_msg_ref = 0;
9864                         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_var);
9865                         peer_msg_ref = tag_ptr(peer_msg_var.inner, false);
9866         return peer_msg_ref;
9867 }
9868 jstring CS_LDK_LDKClosureReason_ProcessingError_get_err(int64_t ptr) {
9869         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
9870         CHECK(obj->tag == LDKClosureReason_ProcessingError);
9871         LDKStr err_str = obj->processing_error.err;
9872                         jstring err_conv = str_ref_to_cs(err_str.chars, err_str.len);
9873         return err_conv;
9874 }
9875 uint32_t CS_LDK_LDKCOption_ClosureReasonZ_ty_from_ptr(int64_t ptr) {
9876         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
9877         switch(obj->tag) {
9878                 case LDKCOption_ClosureReasonZ_Some: return 0;
9879                 case LDKCOption_ClosureReasonZ_None: return 1;
9880                 default: abort();
9881         }
9882 }
9883 int64_t CS_LDK_LDKCOption_ClosureReasonZ_Some_get_some(int64_t ptr) {
9884         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
9885         CHECK(obj->tag == LDKCOption_ClosureReasonZ_Some);
9886         int64_t some_ref = tag_ptr(&obj->some, false);
9887         return some_ref;
9888 }
9889 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
9890 CHECK(owner->result_ok);
9891         return COption_ClosureReasonZ_clone(&*owner->contents.result);
9892 }
9893 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(int64_t owner) {
9894         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
9895         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9896         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
9897         int64_t ret_ref = tag_ptr(ret_copy, true);
9898         return ret_ref;
9899 }
9900
9901 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
9902 CHECK(!owner->result_ok);
9903         return DecodeError_clone(&*owner->contents.err);
9904 }
9905 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(int64_t owner) {
9906         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
9907         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9908         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
9909         int64_t ret_ref = tag_ptr(ret_copy, true);
9910         return ret_ref;
9911 }
9912
9913 uint32_t CS_LDK_LDKHTLCDestination_ty_from_ptr(int64_t ptr) {
9914         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9915         switch(obj->tag) {
9916                 case LDKHTLCDestination_NextHopChannel: return 0;
9917                 case LDKHTLCDestination_UnknownNextHop: return 1;
9918                 case LDKHTLCDestination_InvalidForward: return 2;
9919                 case LDKHTLCDestination_FailedPayment: return 3;
9920                 default: abort();
9921         }
9922 }
9923 int8_tArray CS_LDK_LDKHTLCDestination_NextHopChannel_get_node_id(int64_t ptr) {
9924         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9925         CHECK(obj->tag == LDKHTLCDestination_NextHopChannel);
9926         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
9927         memcpy(node_id_arr->elems, obj->next_hop_channel.node_id.compressed_form, 33);
9928         return node_id_arr;
9929 }
9930 int8_tArray CS_LDK_LDKHTLCDestination_NextHopChannel_get_channel_id(int64_t ptr) {
9931         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9932         CHECK(obj->tag == LDKHTLCDestination_NextHopChannel);
9933         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
9934         memcpy(channel_id_arr->elems, obj->next_hop_channel.channel_id.data, 32);
9935         return channel_id_arr;
9936 }
9937 int64_t CS_LDK_LDKHTLCDestination_UnknownNextHop_get_requested_forward_scid(int64_t ptr) {
9938         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9939         CHECK(obj->tag == LDKHTLCDestination_UnknownNextHop);
9940         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
9941         return requested_forward_scid_conv;
9942 }
9943 int64_t CS_LDK_LDKHTLCDestination_InvalidForward_get_requested_forward_scid(int64_t ptr) {
9944         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9945         CHECK(obj->tag == LDKHTLCDestination_InvalidForward);
9946         int64_t requested_forward_scid_conv = obj->invalid_forward.requested_forward_scid;
9947         return requested_forward_scid_conv;
9948 }
9949 int8_tArray CS_LDK_LDKHTLCDestination_FailedPayment_get_payment_hash(int64_t ptr) {
9950         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
9951         CHECK(obj->tag == LDKHTLCDestination_FailedPayment);
9952         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
9953         memcpy(payment_hash_arr->elems, obj->failed_payment.payment_hash.data, 32);
9954         return payment_hash_arr;
9955 }
9956 uint32_t CS_LDK_LDKCOption_HTLCDestinationZ_ty_from_ptr(int64_t ptr) {
9957         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
9958         switch(obj->tag) {
9959                 case LDKCOption_HTLCDestinationZ_Some: return 0;
9960                 case LDKCOption_HTLCDestinationZ_None: return 1;
9961                 default: abort();
9962         }
9963 }
9964 int64_t CS_LDK_LDKCOption_HTLCDestinationZ_Some_get_some(int64_t ptr) {
9965         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
9966         CHECK(obj->tag == LDKCOption_HTLCDestinationZ_Some);
9967         int64_t some_ref = tag_ptr(&obj->some, false);
9968         return some_ref;
9969 }
9970 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
9971 CHECK(owner->result_ok);
9972         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
9973 }
9974 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(int64_t owner) {
9975         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
9976         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
9977         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
9978         int64_t ret_ref = tag_ptr(ret_copy, true);
9979         return ret_ref;
9980 }
9981
9982 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
9983 CHECK(!owner->result_ok);
9984         return DecodeError_clone(&*owner->contents.err);
9985 }
9986 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(int64_t owner) {
9987         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
9988         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9989         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
9990         int64_t ret_ref = tag_ptr(ret_copy, true);
9991         return ret_ref;
9992 }
9993
9994 static inline enum LDKPaymentFailureReason CResult_PaymentFailureReasonDecodeErrorZ_get_ok(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
9995 CHECK(owner->result_ok);
9996         return PaymentFailureReason_clone(&*owner->contents.result);
9997 }
9998 int32_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_get_ok(int64_t owner) {
9999         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
10000         int32_t ret_conv = LDKPaymentFailureReason_to_cs(CResult_PaymentFailureReasonDecodeErrorZ_get_ok(owner_conv));
10001         return ret_conv;
10002 }
10003
10004 static inline struct LDKDecodeError CResult_PaymentFailureReasonDecodeErrorZ_get_err(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR owner){
10005 CHECK(!owner->result_ok);
10006         return DecodeError_clone(&*owner->contents.err);
10007 }
10008 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_get_err(int64_t owner) {
10009         LDKCResult_PaymentFailureReasonDecodeErrorZ* owner_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(owner);
10010         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10011         *ret_copy = CResult_PaymentFailureReasonDecodeErrorZ_get_err(owner_conv);
10012         int64_t ret_ref = tag_ptr(ret_copy, true);
10013         return ret_ref;
10014 }
10015
10016 uint32_t CS_LDK_LDKCOption_U128Z_ty_from_ptr(int64_t ptr) {
10017         LDKCOption_U128Z *obj = (LDKCOption_U128Z*)untag_ptr(ptr);
10018         switch(obj->tag) {
10019                 case LDKCOption_U128Z_Some: return 0;
10020                 case LDKCOption_U128Z_None: return 1;
10021                 default: abort();
10022         }
10023 }
10024 int8_tArray CS_LDK_LDKCOption_U128Z_Some_get_some(int64_t ptr) {
10025         LDKCOption_U128Z *obj = (LDKCOption_U128Z*)untag_ptr(ptr);
10026         CHECK(obj->tag == LDKCOption_U128Z_Some);
10027         int8_tArray some_arr = init_int8_tArray(16, __LINE__);
10028         memcpy(some_arr->elems, obj->some.le_bytes, 16);
10029         return some_arr;
10030 }
10031 static inline LDKCVec_ClaimedHTLCZ CVec_ClaimedHTLCZ_clone(const LDKCVec_ClaimedHTLCZ *orig) {
10032         LDKCVec_ClaimedHTLCZ ret = { .data = MALLOC(sizeof(LDKClaimedHTLC) * orig->datalen, "LDKCVec_ClaimedHTLCZ clone bytes"), .datalen = orig->datalen };
10033         for (size_t i = 0; i < ret.datalen; i++) {
10034                 ret.data[i] = ClaimedHTLC_clone(&orig->data[i]);
10035         }
10036         return ret;
10037 }
10038 uint32_t CS_LDK_LDKCOption_PaymentFailureReasonZ_ty_from_ptr(int64_t ptr) {
10039         LDKCOption_PaymentFailureReasonZ *obj = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(ptr);
10040         switch(obj->tag) {
10041                 case LDKCOption_PaymentFailureReasonZ_Some: return 0;
10042                 case LDKCOption_PaymentFailureReasonZ_None: return 1;
10043                 default: abort();
10044         }
10045 }
10046 int32_t CS_LDK_LDKCOption_PaymentFailureReasonZ_Some_get_some(int64_t ptr) {
10047         LDKCOption_PaymentFailureReasonZ *obj = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(ptr);
10048         CHECK(obj->tag == LDKCOption_PaymentFailureReasonZ_Some);
10049         int32_t some_conv = LDKPaymentFailureReason_to_cs(obj->some);
10050         return some_conv;
10051 }
10052 uint32_t CS_LDK_LDKBumpTransactionEvent_ty_from_ptr(int64_t ptr) {
10053         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10054         switch(obj->tag) {
10055                 case LDKBumpTransactionEvent_ChannelClose: return 0;
10056                 case LDKBumpTransactionEvent_HTLCResolution: return 1;
10057                 default: abort();
10058         }
10059 }
10060 int8_tArray CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_claim_id(int64_t ptr) {
10061         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10062         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10063         int8_tArray claim_id_arr = init_int8_tArray(32, __LINE__);
10064         memcpy(claim_id_arr->elems, obj->channel_close.claim_id.data, 32);
10065         return claim_id_arr;
10066 }
10067 int32_t CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_package_target_feerate_sat_per_1000_weight(int64_t ptr) {
10068         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10069         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10070         int32_t package_target_feerate_sat_per_1000_weight_conv = obj->channel_close.package_target_feerate_sat_per_1000_weight;
10071         return package_target_feerate_sat_per_1000_weight_conv;
10072 }
10073 int8_tArray CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_commitment_tx(int64_t ptr) {
10074         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10075         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10076         LDKTransaction commitment_tx_var = obj->channel_close.commitment_tx;
10077                         int8_tArray commitment_tx_arr = init_int8_tArray(commitment_tx_var.datalen, __LINE__);
10078                         memcpy(commitment_tx_arr->elems, commitment_tx_var.data, commitment_tx_var.datalen);
10079         return commitment_tx_arr;
10080 }
10081 int64_t CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_commitment_tx_fee_satoshis(int64_t ptr) {
10082         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10083         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10084         int64_t commitment_tx_fee_satoshis_conv = obj->channel_close.commitment_tx_fee_satoshis;
10085         return commitment_tx_fee_satoshis_conv;
10086 }
10087 int64_t CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_anchor_descriptor(int64_t ptr) {
10088         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10089         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10090         LDKAnchorDescriptor anchor_descriptor_var = obj->channel_close.anchor_descriptor;
10091                         int64_t anchor_descriptor_ref = 0;
10092                         CHECK_INNER_FIELD_ACCESS_OR_NULL(anchor_descriptor_var);
10093                         anchor_descriptor_ref = tag_ptr(anchor_descriptor_var.inner, false);
10094         return anchor_descriptor_ref;
10095 }
10096 int64_tArray CS_LDK_LDKBumpTransactionEvent_ChannelClose_get_pending_htlcs(int64_t ptr) {
10097         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10098         CHECK(obj->tag == LDKBumpTransactionEvent_ChannelClose);
10099         LDKCVec_HTLCOutputInCommitmentZ pending_htlcs_var = obj->channel_close.pending_htlcs;
10100                         int64_tArray pending_htlcs_arr = NULL;
10101                         pending_htlcs_arr = init_int64_tArray(pending_htlcs_var.datalen, __LINE__);
10102                         int64_t *pending_htlcs_arr_ptr = (int64_t*)(((uint8_t*)pending_htlcs_arr) + 8);
10103                         for (size_t y = 0; y < pending_htlcs_var.datalen; y++) {
10104                                 LDKHTLCOutputInCommitment pending_htlcs_conv_24_var = pending_htlcs_var.data[y];
10105                                 int64_t pending_htlcs_conv_24_ref = 0;
10106                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(pending_htlcs_conv_24_var);
10107                                 pending_htlcs_conv_24_ref = tag_ptr(pending_htlcs_conv_24_var.inner, false);
10108                                 pending_htlcs_arr_ptr[y] = pending_htlcs_conv_24_ref;
10109                         }
10110                         
10111         return pending_htlcs_arr;
10112 }
10113 int8_tArray CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_claim_id(int64_t ptr) {
10114         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10115         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10116         int8_tArray claim_id_arr = init_int8_tArray(32, __LINE__);
10117         memcpy(claim_id_arr->elems, obj->htlc_resolution.claim_id.data, 32);
10118         return claim_id_arr;
10119 }
10120 int32_t CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_target_feerate_sat_per_1000_weight(int64_t ptr) {
10121         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10122         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10123         int32_t target_feerate_sat_per_1000_weight_conv = obj->htlc_resolution.target_feerate_sat_per_1000_weight;
10124         return target_feerate_sat_per_1000_weight_conv;
10125 }
10126 int64_tArray CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_htlc_descriptors(int64_t ptr) {
10127         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10128         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10129         LDKCVec_HTLCDescriptorZ htlc_descriptors_var = obj->htlc_resolution.htlc_descriptors;
10130                         int64_tArray htlc_descriptors_arr = NULL;
10131                         htlc_descriptors_arr = init_int64_tArray(htlc_descriptors_var.datalen, __LINE__);
10132                         int64_t *htlc_descriptors_arr_ptr = (int64_t*)(((uint8_t*)htlc_descriptors_arr) + 8);
10133                         for (size_t q = 0; q < htlc_descriptors_var.datalen; q++) {
10134                                 LDKHTLCDescriptor htlc_descriptors_conv_16_var = htlc_descriptors_var.data[q];
10135                                 int64_t htlc_descriptors_conv_16_ref = 0;
10136                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptors_conv_16_var);
10137                                 htlc_descriptors_conv_16_ref = tag_ptr(htlc_descriptors_conv_16_var.inner, false);
10138                                 htlc_descriptors_arr_ptr[q] = htlc_descriptors_conv_16_ref;
10139                         }
10140                         
10141         return htlc_descriptors_arr;
10142 }
10143 int32_t CS_LDK_LDKBumpTransactionEvent_HTLCResolution_get_tx_lock_time(int64_t ptr) {
10144         LDKBumpTransactionEvent *obj = (LDKBumpTransactionEvent*)untag_ptr(ptr);
10145         CHECK(obj->tag == LDKBumpTransactionEvent_HTLCResolution);
10146         int32_t tx_lock_time_conv = obj->htlc_resolution.tx_lock_time;
10147         return tx_lock_time_conv;
10148 }
10149 uint32_t CS_LDK_LDKEvent_ty_from_ptr(int64_t ptr) {
10150         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10151         switch(obj->tag) {
10152                 case LDKEvent_FundingGenerationReady: return 0;
10153                 case LDKEvent_PaymentClaimable: return 1;
10154                 case LDKEvent_PaymentClaimed: return 2;
10155                 case LDKEvent_InvoiceRequestFailed: return 3;
10156                 case LDKEvent_PaymentSent: return 4;
10157                 case LDKEvent_PaymentFailed: return 5;
10158                 case LDKEvent_PaymentPathSuccessful: return 6;
10159                 case LDKEvent_PaymentPathFailed: return 7;
10160                 case LDKEvent_ProbeSuccessful: return 8;
10161                 case LDKEvent_ProbeFailed: return 9;
10162                 case LDKEvent_PendingHTLCsForwardable: return 10;
10163                 case LDKEvent_HTLCIntercepted: return 11;
10164                 case LDKEvent_SpendableOutputs: return 12;
10165                 case LDKEvent_PaymentForwarded: return 13;
10166                 case LDKEvent_ChannelPending: return 14;
10167                 case LDKEvent_ChannelReady: return 15;
10168                 case LDKEvent_ChannelClosed: return 16;
10169                 case LDKEvent_DiscardFunding: return 17;
10170                 case LDKEvent_OpenChannelRequest: return 18;
10171                 case LDKEvent_HTLCHandlingFailed: return 19;
10172                 case LDKEvent_BumpTransaction: return 20;
10173                 default: abort();
10174         }
10175 }
10176 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_temporary_channel_id(int64_t ptr) {
10177         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10178         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10179         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
10180         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
10181         return temporary_channel_id_arr;
10182 }
10183 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_counterparty_node_id(int64_t ptr) {
10184         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10185         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10186         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10187         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
10188         return counterparty_node_id_arr;
10189 }
10190 int64_t CS_LDK_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(int64_t ptr) {
10191         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10192         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10193         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
10194         return channel_value_satoshis_conv;
10195 }
10196 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_output_script(int64_t ptr) {
10197         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10198         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10199         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
10200                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
10201                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
10202         return output_script_arr;
10203 }
10204 int8_tArray CS_LDK_LDKEvent_FundingGenerationReady_get_user_channel_id(int64_t ptr) {
10205         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10206         CHECK(obj->tag == LDKEvent_FundingGenerationReady);
10207         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10208         memcpy(user_channel_id_arr->elems, obj->funding_generation_ready.user_channel_id.le_bytes, 16);
10209         return user_channel_id_arr;
10210 }
10211 int8_tArray CS_LDK_LDKEvent_PaymentClaimable_get_receiver_node_id(int64_t ptr) {
10212         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10213         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10214         int8_tArray receiver_node_id_arr = init_int8_tArray(33, __LINE__);
10215         memcpy(receiver_node_id_arr->elems, obj->payment_claimable.receiver_node_id.compressed_form, 33);
10216         return receiver_node_id_arr;
10217 }
10218 int8_tArray CS_LDK_LDKEvent_PaymentClaimable_get_payment_hash(int64_t ptr) {
10219         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10220         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10221         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10222         memcpy(payment_hash_arr->elems, obj->payment_claimable.payment_hash.data, 32);
10223         return payment_hash_arr;
10224 }
10225 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_onion_fields(int64_t ptr) {
10226         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10227         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10228         LDKRecipientOnionFields onion_fields_var = obj->payment_claimable.onion_fields;
10229                         int64_t onion_fields_ref = 0;
10230                         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_var);
10231                         onion_fields_ref = tag_ptr(onion_fields_var.inner, false);
10232         return onion_fields_ref;
10233 }
10234 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_amount_msat(int64_t ptr) {
10235         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10236         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10237         int64_t amount_msat_conv = obj->payment_claimable.amount_msat;
10238         return amount_msat_conv;
10239 }
10240 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_counterparty_skimmed_fee_msat(int64_t ptr) {
10241         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10242         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10243         int64_t counterparty_skimmed_fee_msat_conv = obj->payment_claimable.counterparty_skimmed_fee_msat;
10244         return counterparty_skimmed_fee_msat_conv;
10245 }
10246 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_purpose(int64_t ptr) {
10247         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10248         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10249         int64_t purpose_ref = tag_ptr(&obj->payment_claimable.purpose, false);
10250         return purpose_ref;
10251 }
10252 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_via_channel_id(int64_t ptr) {
10253         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10254         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10255         int64_t via_channel_id_ref = tag_ptr(&obj->payment_claimable.via_channel_id, false);
10256         return via_channel_id_ref;
10257 }
10258 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_via_user_channel_id(int64_t ptr) {
10259         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10260         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10261         int64_t via_user_channel_id_ref = tag_ptr(&obj->payment_claimable.via_user_channel_id, false);
10262         return via_user_channel_id_ref;
10263 }
10264 int64_t CS_LDK_LDKEvent_PaymentClaimable_get_claim_deadline(int64_t ptr) {
10265         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10266         CHECK(obj->tag == LDKEvent_PaymentClaimable);
10267         int64_t claim_deadline_ref = tag_ptr(&obj->payment_claimable.claim_deadline, false);
10268         return claim_deadline_ref;
10269 }
10270 int8_tArray CS_LDK_LDKEvent_PaymentClaimed_get_receiver_node_id(int64_t ptr) {
10271         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10272         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10273         int8_tArray receiver_node_id_arr = init_int8_tArray(33, __LINE__);
10274         memcpy(receiver_node_id_arr->elems, obj->payment_claimed.receiver_node_id.compressed_form, 33);
10275         return receiver_node_id_arr;
10276 }
10277 int8_tArray CS_LDK_LDKEvent_PaymentClaimed_get_payment_hash(int64_t ptr) {
10278         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10279         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10280         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10281         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
10282         return payment_hash_arr;
10283 }
10284 int64_t CS_LDK_LDKEvent_PaymentClaimed_get_amount_msat(int64_t ptr) {
10285         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10286         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10287         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
10288         return amount_msat_conv;
10289 }
10290 int64_t CS_LDK_LDKEvent_PaymentClaimed_get_purpose(int64_t ptr) {
10291         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10292         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10293         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
10294         return purpose_ref;
10295 }
10296 int64_tArray CS_LDK_LDKEvent_PaymentClaimed_get_htlcs(int64_t ptr) {
10297         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10298         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10299         LDKCVec_ClaimedHTLCZ htlcs_var = obj->payment_claimed.htlcs;
10300                         int64_tArray htlcs_arr = NULL;
10301                         htlcs_arr = init_int64_tArray(htlcs_var.datalen, __LINE__);
10302                         int64_t *htlcs_arr_ptr = (int64_t*)(((uint8_t*)htlcs_arr) + 8);
10303                         for (size_t n = 0; n < htlcs_var.datalen; n++) {
10304                                 LDKClaimedHTLC htlcs_conv_13_var = htlcs_var.data[n];
10305                                 int64_t htlcs_conv_13_ref = 0;
10306                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlcs_conv_13_var);
10307                                 htlcs_conv_13_ref = tag_ptr(htlcs_conv_13_var.inner, false);
10308                                 htlcs_arr_ptr[n] = htlcs_conv_13_ref;
10309                         }
10310                         
10311         return htlcs_arr;
10312 }
10313 int64_t CS_LDK_LDKEvent_PaymentClaimed_get_sender_intended_total_msat(int64_t ptr) {
10314         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10315         CHECK(obj->tag == LDKEvent_PaymentClaimed);
10316         int64_t sender_intended_total_msat_ref = tag_ptr(&obj->payment_claimed.sender_intended_total_msat, false);
10317         return sender_intended_total_msat_ref;
10318 }
10319 int8_tArray CS_LDK_LDKEvent_InvoiceRequestFailed_get_payment_id(int64_t ptr) {
10320         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10321         CHECK(obj->tag == LDKEvent_InvoiceRequestFailed);
10322         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10323         memcpy(payment_id_arr->elems, obj->invoice_request_failed.payment_id.data, 32);
10324         return payment_id_arr;
10325 }
10326 int64_t CS_LDK_LDKEvent_PaymentSent_get_payment_id(int64_t ptr) {
10327         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10328         CHECK(obj->tag == LDKEvent_PaymentSent);
10329         int64_t payment_id_ref = tag_ptr(&obj->payment_sent.payment_id, false);
10330         return payment_id_ref;
10331 }
10332 int8_tArray CS_LDK_LDKEvent_PaymentSent_get_payment_preimage(int64_t ptr) {
10333         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10334         CHECK(obj->tag == LDKEvent_PaymentSent);
10335         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10336         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
10337         return payment_preimage_arr;
10338 }
10339 int8_tArray CS_LDK_LDKEvent_PaymentSent_get_payment_hash(int64_t ptr) {
10340         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10341         CHECK(obj->tag == LDKEvent_PaymentSent);
10342         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10343         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
10344         return payment_hash_arr;
10345 }
10346 int64_t CS_LDK_LDKEvent_PaymentSent_get_fee_paid_msat(int64_t ptr) {
10347         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10348         CHECK(obj->tag == LDKEvent_PaymentSent);
10349         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
10350         return fee_paid_msat_ref;
10351 }
10352 int8_tArray CS_LDK_LDKEvent_PaymentFailed_get_payment_id(int64_t ptr) {
10353         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10354         CHECK(obj->tag == LDKEvent_PaymentFailed);
10355         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10356         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
10357         return payment_id_arr;
10358 }
10359 int8_tArray CS_LDK_LDKEvent_PaymentFailed_get_payment_hash(int64_t ptr) {
10360         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10361         CHECK(obj->tag == LDKEvent_PaymentFailed);
10362         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10363         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
10364         return payment_hash_arr;
10365 }
10366 int64_t CS_LDK_LDKEvent_PaymentFailed_get_reason(int64_t ptr) {
10367         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10368         CHECK(obj->tag == LDKEvent_PaymentFailed);
10369         int64_t reason_ref = tag_ptr(&obj->payment_failed.reason, false);
10370         return reason_ref;
10371 }
10372 int8_tArray CS_LDK_LDKEvent_PaymentPathSuccessful_get_payment_id(int64_t ptr) {
10373         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10374         CHECK(obj->tag == LDKEvent_PaymentPathSuccessful);
10375         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10376         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
10377         return payment_id_arr;
10378 }
10379 int64_t CS_LDK_LDKEvent_PaymentPathSuccessful_get_payment_hash(int64_t ptr) {
10380         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10381         CHECK(obj->tag == LDKEvent_PaymentPathSuccessful);
10382         int64_t payment_hash_ref = tag_ptr(&obj->payment_path_successful.payment_hash, false);
10383         return payment_hash_ref;
10384 }
10385 int64_t CS_LDK_LDKEvent_PaymentPathSuccessful_get_path(int64_t ptr) {
10386         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10387         CHECK(obj->tag == LDKEvent_PaymentPathSuccessful);
10388         LDKPath path_var = obj->payment_path_successful.path;
10389                         int64_t path_ref = 0;
10390                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10391                         path_ref = tag_ptr(path_var.inner, false);
10392         return path_ref;
10393 }
10394 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_payment_id(int64_t ptr) {
10395         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10396         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10397         int64_t payment_id_ref = tag_ptr(&obj->payment_path_failed.payment_id, false);
10398         return payment_id_ref;
10399 }
10400 int8_tArray CS_LDK_LDKEvent_PaymentPathFailed_get_payment_hash(int64_t ptr) {
10401         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10402         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10403         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10404         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
10405         return payment_hash_arr;
10406 }
10407 jboolean CS_LDK_LDKEvent_PaymentPathFailed_get_payment_failed_permanently(int64_t ptr) {
10408         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10409         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10410         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
10411         return payment_failed_permanently_conv;
10412 }
10413 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_failure(int64_t ptr) {
10414         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10415         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10416         int64_t failure_ref = tag_ptr(&obj->payment_path_failed.failure, false);
10417         return failure_ref;
10418 }
10419 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_path(int64_t ptr) {
10420         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10421         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10422         LDKPath path_var = obj->payment_path_failed.path;
10423                         int64_t path_ref = 0;
10424                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10425                         path_ref = tag_ptr(path_var.inner, false);
10426         return path_ref;
10427 }
10428 int64_t CS_LDK_LDKEvent_PaymentPathFailed_get_short_channel_id(int64_t ptr) {
10429         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10430         CHECK(obj->tag == LDKEvent_PaymentPathFailed);
10431         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
10432         return short_channel_id_ref;
10433 }
10434 int8_tArray CS_LDK_LDKEvent_ProbeSuccessful_get_payment_id(int64_t ptr) {
10435         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10436         CHECK(obj->tag == LDKEvent_ProbeSuccessful);
10437         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10438         memcpy(payment_id_arr->elems, obj->probe_successful.payment_id.data, 32);
10439         return payment_id_arr;
10440 }
10441 int8_tArray CS_LDK_LDKEvent_ProbeSuccessful_get_payment_hash(int64_t ptr) {
10442         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10443         CHECK(obj->tag == LDKEvent_ProbeSuccessful);
10444         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10445         memcpy(payment_hash_arr->elems, obj->probe_successful.payment_hash.data, 32);
10446         return payment_hash_arr;
10447 }
10448 int64_t CS_LDK_LDKEvent_ProbeSuccessful_get_path(int64_t ptr) {
10449         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10450         CHECK(obj->tag == LDKEvent_ProbeSuccessful);
10451         LDKPath path_var = obj->probe_successful.path;
10452                         int64_t path_ref = 0;
10453                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10454                         path_ref = tag_ptr(path_var.inner, false);
10455         return path_ref;
10456 }
10457 int8_tArray CS_LDK_LDKEvent_ProbeFailed_get_payment_id(int64_t ptr) {
10458         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10459         CHECK(obj->tag == LDKEvent_ProbeFailed);
10460         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10461         memcpy(payment_id_arr->elems, obj->probe_failed.payment_id.data, 32);
10462         return payment_id_arr;
10463 }
10464 int8_tArray CS_LDK_LDKEvent_ProbeFailed_get_payment_hash(int64_t ptr) {
10465         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10466         CHECK(obj->tag == LDKEvent_ProbeFailed);
10467         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10468         memcpy(payment_hash_arr->elems, obj->probe_failed.payment_hash.data, 32);
10469         return payment_hash_arr;
10470 }
10471 int64_t CS_LDK_LDKEvent_ProbeFailed_get_path(int64_t ptr) {
10472         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10473         CHECK(obj->tag == LDKEvent_ProbeFailed);
10474         LDKPath path_var = obj->probe_failed.path;
10475                         int64_t path_ref = 0;
10476                         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_var);
10477                         path_ref = tag_ptr(path_var.inner, false);
10478         return path_ref;
10479 }
10480 int64_t CS_LDK_LDKEvent_ProbeFailed_get_short_channel_id(int64_t ptr) {
10481         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10482         CHECK(obj->tag == LDKEvent_ProbeFailed);
10483         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
10484         return short_channel_id_ref;
10485 }
10486 int64_t CS_LDK_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(int64_t ptr) {
10487         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10488         CHECK(obj->tag == LDKEvent_PendingHTLCsForwardable);
10489         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
10490         return time_forwardable_conv;
10491 }
10492 int8_tArray CS_LDK_LDKEvent_HTLCIntercepted_get_intercept_id(int64_t ptr) {
10493         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10494         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10495         int8_tArray intercept_id_arr = init_int8_tArray(32, __LINE__);
10496         memcpy(intercept_id_arr->elems, obj->htlc_intercepted.intercept_id.data, 32);
10497         return intercept_id_arr;
10498 }
10499 int64_t CS_LDK_LDKEvent_HTLCIntercepted_get_requested_next_hop_scid(int64_t ptr) {
10500         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10501         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10502         int64_t requested_next_hop_scid_conv = obj->htlc_intercepted.requested_next_hop_scid;
10503         return requested_next_hop_scid_conv;
10504 }
10505 int8_tArray CS_LDK_LDKEvent_HTLCIntercepted_get_payment_hash(int64_t ptr) {
10506         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10507         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10508         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10509         memcpy(payment_hash_arr->elems, obj->htlc_intercepted.payment_hash.data, 32);
10510         return payment_hash_arr;
10511 }
10512 int64_t CS_LDK_LDKEvent_HTLCIntercepted_get_inbound_amount_msat(int64_t ptr) {
10513         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10514         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10515         int64_t inbound_amount_msat_conv = obj->htlc_intercepted.inbound_amount_msat;
10516         return inbound_amount_msat_conv;
10517 }
10518 int64_t CS_LDK_LDKEvent_HTLCIntercepted_get_expected_outbound_amount_msat(int64_t ptr) {
10519         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10520         CHECK(obj->tag == LDKEvent_HTLCIntercepted);
10521         int64_t expected_outbound_amount_msat_conv = obj->htlc_intercepted.expected_outbound_amount_msat;
10522         return expected_outbound_amount_msat_conv;
10523 }
10524 int64_tArray CS_LDK_LDKEvent_SpendableOutputs_get_outputs(int64_t ptr) {
10525         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10526         CHECK(obj->tag == LDKEvent_SpendableOutputs);
10527         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
10528                         int64_tArray outputs_arr = NULL;
10529                         outputs_arr = init_int64_tArray(outputs_var.datalen, __LINE__);
10530                         int64_t *outputs_arr_ptr = (int64_t*)(((uint8_t*)outputs_arr) + 8);
10531                         for (size_t b = 0; b < outputs_var.datalen; b++) {
10532                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
10533                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
10534                         }
10535                         
10536         return outputs_arr;
10537 }
10538 int64_t CS_LDK_LDKEvent_SpendableOutputs_get_channel_id(int64_t ptr) {
10539         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10540         CHECK(obj->tag == LDKEvent_SpendableOutputs);
10541         int64_t channel_id_ref = tag_ptr(&obj->spendable_outputs.channel_id, false);
10542         return channel_id_ref;
10543 }
10544 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_prev_channel_id(int64_t ptr) {
10545         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10546         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10547         int64_t prev_channel_id_ref = tag_ptr(&obj->payment_forwarded.prev_channel_id, false);
10548         return prev_channel_id_ref;
10549 }
10550 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_next_channel_id(int64_t ptr) {
10551         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10552         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10553         int64_t next_channel_id_ref = tag_ptr(&obj->payment_forwarded.next_channel_id, false);
10554         return next_channel_id_ref;
10555 }
10556 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_fee_earned_msat(int64_t ptr) {
10557         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10558         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10559         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
10560         return fee_earned_msat_ref;
10561 }
10562 jboolean CS_LDK_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(int64_t ptr) {
10563         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10564         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10565         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
10566         return claim_from_onchain_tx_conv;
10567 }
10568 int64_t CS_LDK_LDKEvent_PaymentForwarded_get_outbound_amount_forwarded_msat(int64_t ptr) {
10569         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10570         CHECK(obj->tag == LDKEvent_PaymentForwarded);
10571         int64_t outbound_amount_forwarded_msat_ref = tag_ptr(&obj->payment_forwarded.outbound_amount_forwarded_msat, false);
10572         return outbound_amount_forwarded_msat_ref;
10573 }
10574 int8_tArray CS_LDK_LDKEvent_ChannelPending_get_channel_id(int64_t ptr) {
10575         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10576         CHECK(obj->tag == LDKEvent_ChannelPending);
10577         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10578         memcpy(channel_id_arr->elems, obj->channel_pending.channel_id.data, 32);
10579         return channel_id_arr;
10580 }
10581 int8_tArray CS_LDK_LDKEvent_ChannelPending_get_user_channel_id(int64_t ptr) {
10582         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10583         CHECK(obj->tag == LDKEvent_ChannelPending);
10584         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10585         memcpy(user_channel_id_arr->elems, obj->channel_pending.user_channel_id.le_bytes, 16);
10586         return user_channel_id_arr;
10587 }
10588 int64_t CS_LDK_LDKEvent_ChannelPending_get_former_temporary_channel_id(int64_t ptr) {
10589         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10590         CHECK(obj->tag == LDKEvent_ChannelPending);
10591         int64_t former_temporary_channel_id_ref = tag_ptr(&obj->channel_pending.former_temporary_channel_id, false);
10592         return former_temporary_channel_id_ref;
10593 }
10594 int8_tArray CS_LDK_LDKEvent_ChannelPending_get_counterparty_node_id(int64_t ptr) {
10595         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10596         CHECK(obj->tag == LDKEvent_ChannelPending);
10597         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10598         memcpy(counterparty_node_id_arr->elems, obj->channel_pending.counterparty_node_id.compressed_form, 33);
10599         return counterparty_node_id_arr;
10600 }
10601 int64_t CS_LDK_LDKEvent_ChannelPending_get_funding_txo(int64_t ptr) {
10602         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10603         CHECK(obj->tag == LDKEvent_ChannelPending);
10604         LDKOutPoint funding_txo_var = obj->channel_pending.funding_txo;
10605                         int64_t funding_txo_ref = 0;
10606                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
10607                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
10608         return funding_txo_ref;
10609 }
10610 int8_tArray CS_LDK_LDKEvent_ChannelReady_get_channel_id(int64_t ptr) {
10611         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10612         CHECK(obj->tag == LDKEvent_ChannelReady);
10613         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10614         memcpy(channel_id_arr->elems, obj->channel_ready.channel_id.data, 32);
10615         return channel_id_arr;
10616 }
10617 int8_tArray CS_LDK_LDKEvent_ChannelReady_get_user_channel_id(int64_t ptr) {
10618         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10619         CHECK(obj->tag == LDKEvent_ChannelReady);
10620         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10621         memcpy(user_channel_id_arr->elems, obj->channel_ready.user_channel_id.le_bytes, 16);
10622         return user_channel_id_arr;
10623 }
10624 int8_tArray CS_LDK_LDKEvent_ChannelReady_get_counterparty_node_id(int64_t ptr) {
10625         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10626         CHECK(obj->tag == LDKEvent_ChannelReady);
10627         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10628         memcpy(counterparty_node_id_arr->elems, obj->channel_ready.counterparty_node_id.compressed_form, 33);
10629         return counterparty_node_id_arr;
10630 }
10631 int64_t CS_LDK_LDKEvent_ChannelReady_get_channel_type(int64_t ptr) {
10632         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10633         CHECK(obj->tag == LDKEvent_ChannelReady);
10634         LDKChannelTypeFeatures channel_type_var = obj->channel_ready.channel_type;
10635                         int64_t channel_type_ref = 0;
10636                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
10637                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
10638         return channel_type_ref;
10639 }
10640 int8_tArray CS_LDK_LDKEvent_ChannelClosed_get_channel_id(int64_t ptr) {
10641         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10642         CHECK(obj->tag == LDKEvent_ChannelClosed);
10643         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10644         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
10645         return channel_id_arr;
10646 }
10647 int8_tArray CS_LDK_LDKEvent_ChannelClosed_get_user_channel_id(int64_t ptr) {
10648         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10649         CHECK(obj->tag == LDKEvent_ChannelClosed);
10650         int8_tArray user_channel_id_arr = init_int8_tArray(16, __LINE__);
10651         memcpy(user_channel_id_arr->elems, obj->channel_closed.user_channel_id.le_bytes, 16);
10652         return user_channel_id_arr;
10653 }
10654 int64_t CS_LDK_LDKEvent_ChannelClosed_get_reason(int64_t ptr) {
10655         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10656         CHECK(obj->tag == LDKEvent_ChannelClosed);
10657         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
10658         return reason_ref;
10659 }
10660 int8_tArray CS_LDK_LDKEvent_ChannelClosed_get_counterparty_node_id(int64_t ptr) {
10661         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10662         CHECK(obj->tag == LDKEvent_ChannelClosed);
10663         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10664         memcpy(counterparty_node_id_arr->elems, obj->channel_closed.counterparty_node_id.compressed_form, 33);
10665         return counterparty_node_id_arr;
10666 }
10667 int64_t CS_LDK_LDKEvent_ChannelClosed_get_channel_capacity_sats(int64_t ptr) {
10668         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10669         CHECK(obj->tag == LDKEvent_ChannelClosed);
10670         int64_t channel_capacity_sats_ref = tag_ptr(&obj->channel_closed.channel_capacity_sats, false);
10671         return channel_capacity_sats_ref;
10672 }
10673 int8_tArray CS_LDK_LDKEvent_DiscardFunding_get_channel_id(int64_t ptr) {
10674         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10675         CHECK(obj->tag == LDKEvent_DiscardFunding);
10676         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
10677         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
10678         return channel_id_arr;
10679 }
10680 int8_tArray CS_LDK_LDKEvent_DiscardFunding_get_transaction(int64_t ptr) {
10681         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10682         CHECK(obj->tag == LDKEvent_DiscardFunding);
10683         LDKTransaction transaction_var = obj->discard_funding.transaction;
10684                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
10685                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
10686         return transaction_arr;
10687 }
10688 int8_tArray CS_LDK_LDKEvent_OpenChannelRequest_get_temporary_channel_id(int64_t ptr) {
10689         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10690         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10691         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
10692         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
10693         return temporary_channel_id_arr;
10694 }
10695 int8_tArray CS_LDK_LDKEvent_OpenChannelRequest_get_counterparty_node_id(int64_t ptr) {
10696         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10697         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10698         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
10699         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
10700         return counterparty_node_id_arr;
10701 }
10702 int64_t CS_LDK_LDKEvent_OpenChannelRequest_get_funding_satoshis(int64_t ptr) {
10703         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10704         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10705         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
10706         return funding_satoshis_conv;
10707 }
10708 int64_t CS_LDK_LDKEvent_OpenChannelRequest_get_push_msat(int64_t ptr) {
10709         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10710         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10711         int64_t push_msat_conv = obj->open_channel_request.push_msat;
10712         return push_msat_conv;
10713 }
10714 int64_t CS_LDK_LDKEvent_OpenChannelRequest_get_channel_type(int64_t ptr) {
10715         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10716         CHECK(obj->tag == LDKEvent_OpenChannelRequest);
10717         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
10718                         int64_t channel_type_ref = 0;
10719                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
10720                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
10721         return channel_type_ref;
10722 }
10723 int8_tArray CS_LDK_LDKEvent_HTLCHandlingFailed_get_prev_channel_id(int64_t ptr) {
10724         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10725         CHECK(obj->tag == LDKEvent_HTLCHandlingFailed);
10726         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
10727         memcpy(prev_channel_id_arr->elems, obj->htlc_handling_failed.prev_channel_id.data, 32);
10728         return prev_channel_id_arr;
10729 }
10730 int64_t CS_LDK_LDKEvent_HTLCHandlingFailed_get_failed_next_destination(int64_t ptr) {
10731         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10732         CHECK(obj->tag == LDKEvent_HTLCHandlingFailed);
10733         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
10734         return failed_next_destination_ref;
10735 }
10736 int64_t CS_LDK_LDKEvent_BumpTransaction_get_bump_transaction(int64_t ptr) {
10737         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
10738         CHECK(obj->tag == LDKEvent_BumpTransaction);
10739         int64_t bump_transaction_ref = tag_ptr(&obj->bump_transaction, false);
10740         return bump_transaction_ref;
10741 }
10742 uint32_t CS_LDK_LDKCOption_EventZ_ty_from_ptr(int64_t ptr) {
10743         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
10744         switch(obj->tag) {
10745                 case LDKCOption_EventZ_Some: return 0;
10746                 case LDKCOption_EventZ_None: return 1;
10747                 default: abort();
10748         }
10749 }
10750 int64_t CS_LDK_LDKCOption_EventZ_Some_get_some(int64_t ptr) {
10751         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
10752         CHECK(obj->tag == LDKCOption_EventZ_Some);
10753         int64_t some_ref = tag_ptr(&obj->some, false);
10754         return some_ref;
10755 }
10756 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
10757 CHECK(owner->result_ok);
10758         return COption_EventZ_clone(&*owner->contents.result);
10759 }
10760 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_get_ok(int64_t owner) {
10761         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
10762         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
10763         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
10764         int64_t ret_ref = tag_ptr(ret_copy, true);
10765         return ret_ref;
10766 }
10767
10768 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
10769 CHECK(!owner->result_ok);
10770         return DecodeError_clone(&*owner->contents.err);
10771 }
10772 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_get_err(int64_t owner) {
10773         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
10774         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10775         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
10776         int64_t ret_ref = tag_ptr(ret_copy, true);
10777         return ret_ref;
10778 }
10779
10780 uint32_t CS_LDK_LDKBolt11ParseError_ty_from_ptr(int64_t ptr) {
10781         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10782         switch(obj->tag) {
10783                 case LDKBolt11ParseError_Bech32Error: return 0;
10784                 case LDKBolt11ParseError_ParseAmountError: return 1;
10785                 case LDKBolt11ParseError_MalformedSignature: return 2;
10786                 case LDKBolt11ParseError_BadPrefix: return 3;
10787                 case LDKBolt11ParseError_UnknownCurrency: return 4;
10788                 case LDKBolt11ParseError_UnknownSiPrefix: return 5;
10789                 case LDKBolt11ParseError_MalformedHRP: return 6;
10790                 case LDKBolt11ParseError_TooShortDataPart: return 7;
10791                 case LDKBolt11ParseError_UnexpectedEndOfTaggedFields: return 8;
10792                 case LDKBolt11ParseError_DescriptionDecodeError: return 9;
10793                 case LDKBolt11ParseError_PaddingError: return 10;
10794                 case LDKBolt11ParseError_IntegerOverflowError: return 11;
10795                 case LDKBolt11ParseError_InvalidSegWitProgramLength: return 12;
10796                 case LDKBolt11ParseError_InvalidPubKeyHashLength: return 13;
10797                 case LDKBolt11ParseError_InvalidScriptHashLength: return 14;
10798                 case LDKBolt11ParseError_InvalidRecoveryId: return 15;
10799                 case LDKBolt11ParseError_InvalidSliceLength: return 16;
10800                 case LDKBolt11ParseError_Skip: return 17;
10801                 default: abort();
10802         }
10803 }
10804 int64_t CS_LDK_LDKBolt11ParseError_Bech32Error_get_bech32_error(int64_t ptr) {
10805         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10806         CHECK(obj->tag == LDKBolt11ParseError_Bech32Error);
10807         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
10808         return bech32_error_ref;
10809 }
10810 int32_t CS_LDK_LDKBolt11ParseError_ParseAmountError_get_parse_amount_error(int64_t ptr) {
10811         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10812         CHECK(obj->tag == LDKBolt11ParseError_ParseAmountError);
10813         /*obj->parse_amount_error*/
10814         return 0;
10815 }
10816 int32_t CS_LDK_LDKBolt11ParseError_MalformedSignature_get_malformed_signature(int64_t ptr) {
10817         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10818         CHECK(obj->tag == LDKBolt11ParseError_MalformedSignature);
10819         int32_t malformed_signature_conv = LDKSecp256k1Error_to_cs(obj->malformed_signature);
10820         return malformed_signature_conv;
10821 }
10822 int32_t CS_LDK_LDKBolt11ParseError_DescriptionDecodeError_get_description_decode_error(int64_t ptr) {
10823         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10824         CHECK(obj->tag == LDKBolt11ParseError_DescriptionDecodeError);
10825         /*obj->description_decode_error*/
10826         return 0;
10827 }
10828 jstring CS_LDK_LDKBolt11ParseError_InvalidSliceLength_get_invalid_slice_length(int64_t ptr) {
10829         LDKBolt11ParseError *obj = (LDKBolt11ParseError*)untag_ptr(ptr);
10830         CHECK(obj->tag == LDKBolt11ParseError_InvalidSliceLength);
10831         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
10832                         jstring invalid_slice_length_conv = str_ref_to_cs(invalid_slice_length_str.chars, invalid_slice_length_str.len);
10833         return invalid_slice_length_conv;
10834 }
10835 static inline enum LDKSiPrefix CResult_SiPrefixBolt11ParseErrorZ_get_ok(LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR owner){
10836 CHECK(owner->result_ok);
10837         return SiPrefix_clone(&*owner->contents.result);
10838 }
10839 int32_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_get_ok(int64_t owner) {
10840         LDKCResult_SiPrefixBolt11ParseErrorZ* owner_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(owner);
10841         int32_t ret_conv = LDKSiPrefix_to_cs(CResult_SiPrefixBolt11ParseErrorZ_get_ok(owner_conv));
10842         return ret_conv;
10843 }
10844
10845 static inline struct LDKBolt11ParseError CResult_SiPrefixBolt11ParseErrorZ_get_err(LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR owner){
10846 CHECK(!owner->result_ok);
10847         return Bolt11ParseError_clone(&*owner->contents.err);
10848 }
10849 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_get_err(int64_t owner) {
10850         LDKCResult_SiPrefixBolt11ParseErrorZ* owner_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(owner);
10851         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
10852         *ret_copy = CResult_SiPrefixBolt11ParseErrorZ_get_err(owner_conv);
10853         int64_t ret_ref = tag_ptr(ret_copy, true);
10854         return ret_ref;
10855 }
10856
10857 uint32_t CS_LDK_LDKParseOrSemanticError_ty_from_ptr(int64_t ptr) {
10858         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10859         switch(obj->tag) {
10860                 case LDKParseOrSemanticError_ParseError: return 0;
10861                 case LDKParseOrSemanticError_SemanticError: return 1;
10862                 default: abort();
10863         }
10864 }
10865 int64_t CS_LDK_LDKParseOrSemanticError_ParseError_get_parse_error(int64_t ptr) {
10866         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10867         CHECK(obj->tag == LDKParseOrSemanticError_ParseError);
10868         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
10869         return parse_error_ref;
10870 }
10871 int32_t CS_LDK_LDKParseOrSemanticError_SemanticError_get_semantic_error(int64_t ptr) {
10872         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
10873         CHECK(obj->tag == LDKParseOrSemanticError_SemanticError);
10874         int32_t semantic_error_conv = LDKBolt11SemanticError_to_cs(obj->semantic_error);
10875         return semantic_error_conv;
10876 }
10877 static inline struct LDKBolt11Invoice CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10878         LDKBolt11Invoice ret = *owner->contents.result;
10879         ret.is_owned = false;
10880         return ret;
10881 }
10882 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_ok(int64_t owner) {
10883         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10884         LDKBolt11Invoice ret_var = CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
10885         int64_t ret_ref = 0;
10886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10888         return ret_ref;
10889 }
10890
10891 static inline struct LDKParseOrSemanticError CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
10892 CHECK(!owner->result_ok);
10893         return ParseOrSemanticError_clone(&*owner->contents.err);
10894 }
10895 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_err(int64_t owner) {
10896         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
10897         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
10898         *ret_copy = CResult_Bolt11InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
10899         int64_t ret_ref = tag_ptr(ret_copy, true);
10900         return ret_ref;
10901 }
10902
10903 static inline struct LDKSignedRawBolt11Invoice CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_ok(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR owner){
10904         LDKSignedRawBolt11Invoice ret = *owner->contents.result;
10905         ret.is_owned = false;
10906         return ret;
10907 }
10908 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_ok(int64_t owner) {
10909         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* owner_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(owner);
10910         LDKSignedRawBolt11Invoice ret_var = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_ok(owner_conv);
10911         int64_t ret_ref = 0;
10912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10914         return ret_ref;
10915 }
10916
10917 static inline struct LDKBolt11ParseError CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_err(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR owner){
10918 CHECK(!owner->result_ok);
10919         return Bolt11ParseError_clone(&*owner->contents.err);
10920 }
10921 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_err(int64_t owner) {
10922         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* owner_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(owner);
10923         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
10924         *ret_copy = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_get_err(owner_conv);
10925         int64_t ret_ref = tag_ptr(ret_copy, true);
10926         return ret_ref;
10927 }
10928
10929 static inline struct LDKRawBolt11Invoice C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_a(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR owner){
10930         LDKRawBolt11Invoice ret = owner->a;
10931         ret.is_owned = false;
10932         return ret;
10933 }
10934 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_a(int64_t owner) {
10935         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(owner);
10936         LDKRawBolt11Invoice ret_var = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_a(owner_conv);
10937         int64_t ret_ref = 0;
10938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10940         return ret_ref;
10941 }
10942
10943 static inline struct LDKThirtyTwoBytes C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_b(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR owner){
10944         return ThirtyTwoBytes_clone(&owner->b);
10945 }
10946 int8_tArray  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_b(int64_t owner) {
10947         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(owner);
10948         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
10949         memcpy(ret_arr->elems, C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_b(owner_conv).data, 32);
10950         return ret_arr;
10951 }
10952
10953 static inline struct LDKBolt11InvoiceSignature C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_c(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR owner){
10954         LDKBolt11InvoiceSignature ret = owner->c;
10955         ret.is_owned = false;
10956         return ret;
10957 }
10958 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_c(int64_t owner) {
10959         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(owner);
10960         LDKBolt11InvoiceSignature ret_var = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_get_c(owner_conv);
10961         int64_t ret_ref = 0;
10962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10964         return ret_ref;
10965 }
10966
10967 static inline struct LDKPayeePubKey CResult_PayeePubKeySecp256k1ErrorZ_get_ok(LDKCResult_PayeePubKeySecp256k1ErrorZ *NONNULL_PTR owner){
10968         LDKPayeePubKey ret = *owner->contents.result;
10969         ret.is_owned = false;
10970         return ret;
10971 }
10972 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_get_ok(int64_t owner) {
10973         LDKCResult_PayeePubKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(owner);
10974         LDKPayeePubKey ret_var = CResult_PayeePubKeySecp256k1ErrorZ_get_ok(owner_conv);
10975         int64_t ret_ref = 0;
10976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10977         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10978         return ret_ref;
10979 }
10980
10981 static inline enum LDKSecp256k1Error CResult_PayeePubKeySecp256k1ErrorZ_get_err(LDKCResult_PayeePubKeySecp256k1ErrorZ *NONNULL_PTR owner){
10982 CHECK(!owner->result_ok);
10983         return *owner->contents.err;
10984 }
10985 int32_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_get_err(int64_t owner) {
10986         LDKCResult_PayeePubKeySecp256k1ErrorZ* owner_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(owner);
10987         int32_t ret_conv = LDKSecp256k1Error_to_cs(CResult_PayeePubKeySecp256k1ErrorZ_get_err(owner_conv));
10988         return ret_conv;
10989 }
10990
10991 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
10992         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
10993         for (size_t i = 0; i < ret.datalen; i++) {
10994                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
10995         }
10996         return ret;
10997 }
10998 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
10999         LDKPositiveTimestamp ret = *owner->contents.result;
11000         ret.is_owned = false;
11001         return ret;
11002 }
11003 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_get_ok(int64_t owner) {
11004         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
11005         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
11006         int64_t ret_ref = 0;
11007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11008         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11009         return ret_ref;
11010 }
11011
11012 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
11013 CHECK(!owner->result_ok);
11014         return CreationError_clone(&*owner->contents.err);
11015 }
11016 int32_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_get_err(int64_t owner) {
11017         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
11018         int32_t ret_conv = LDKCreationError_to_cs(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
11019         return ret_conv;
11020 }
11021
11022 static inline void CResult_NoneBolt11SemanticErrorZ_get_ok(LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR owner){
11023 CHECK(owner->result_ok);
11024         return *owner->contents.result;
11025 }
11026 void  CS_LDK_CResult_NoneBolt11SemanticErrorZ_get_ok(int64_t owner) {
11027         LDKCResult_NoneBolt11SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(owner);
11028         CResult_NoneBolt11SemanticErrorZ_get_ok(owner_conv);
11029 }
11030
11031 static inline enum LDKBolt11SemanticError CResult_NoneBolt11SemanticErrorZ_get_err(LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR owner){
11032 CHECK(!owner->result_ok);
11033         return Bolt11SemanticError_clone(&*owner->contents.err);
11034 }
11035 int32_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_get_err(int64_t owner) {
11036         LDKCResult_NoneBolt11SemanticErrorZ* owner_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(owner);
11037         int32_t ret_conv = LDKBolt11SemanticError_to_cs(CResult_NoneBolt11SemanticErrorZ_get_err(owner_conv));
11038         return ret_conv;
11039 }
11040
11041 static inline struct LDKBolt11Invoice CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_ok(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR owner){
11042         LDKBolt11Invoice ret = *owner->contents.result;
11043         ret.is_owned = false;
11044         return ret;
11045 }
11046 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_ok(int64_t owner) {
11047         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(owner);
11048         LDKBolt11Invoice ret_var = CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_ok(owner_conv);
11049         int64_t ret_ref = 0;
11050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11051         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11052         return ret_ref;
11053 }
11054
11055 static inline enum LDKBolt11SemanticError CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_err(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR owner){
11056 CHECK(!owner->result_ok);
11057         return Bolt11SemanticError_clone(&*owner->contents.err);
11058 }
11059 int32_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_err(int64_t owner) {
11060         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* owner_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(owner);
11061         int32_t ret_conv = LDKBolt11SemanticError_to_cs(CResult_Bolt11InvoiceBolt11SemanticErrorZ_get_err(owner_conv));
11062         return ret_conv;
11063 }
11064
11065 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
11066         LDKDescription ret = *owner->contents.result;
11067         ret.is_owned = false;
11068         return ret;
11069 }
11070 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_get_ok(int64_t owner) {
11071         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
11072         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
11073         int64_t ret_ref = 0;
11074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11076         return ret_ref;
11077 }
11078
11079 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
11080 CHECK(!owner->result_ok);
11081         return CreationError_clone(&*owner->contents.err);
11082 }
11083 int32_t  CS_LDK_CResult_DescriptionCreationErrorZ_get_err(int64_t owner) {
11084         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
11085         int32_t ret_conv = LDKCreationError_to_cs(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
11086         return ret_conv;
11087 }
11088
11089 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
11090         LDKPrivateRoute ret = *owner->contents.result;
11091         ret.is_owned = false;
11092         return ret;
11093 }
11094 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_get_ok(int64_t owner) {
11095         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
11096         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
11097         int64_t ret_ref = 0;
11098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11100         return ret_ref;
11101 }
11102
11103 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
11104 CHECK(!owner->result_ok);
11105         return CreationError_clone(&*owner->contents.err);
11106 }
11107 int32_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_get_err(int64_t owner) {
11108         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
11109         int32_t ret_conv = LDKCreationError_to_cs(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
11110         return ret_conv;
11111 }
11112
11113 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
11114         LDKOutPoint ret = *owner->contents.result;
11115         ret.is_owned = false;
11116         return ret;
11117 }
11118 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_get_ok(int64_t owner) {
11119         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
11120         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
11121         int64_t ret_ref = 0;
11122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11124         return ret_ref;
11125 }
11126
11127 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
11128 CHECK(!owner->result_ok);
11129         return DecodeError_clone(&*owner->contents.err);
11130 }
11131 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_get_err(int64_t owner) {
11132         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
11133         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11134         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
11135         int64_t ret_ref = tag_ptr(ret_copy, true);
11136         return ret_ref;
11137 }
11138
11139 static inline struct LDKBigSize CResult_BigSizeDecodeErrorZ_get_ok(LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR owner){
11140         LDKBigSize ret = *owner->contents.result;
11141         ret.is_owned = false;
11142         return ret;
11143 }
11144 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_get_ok(int64_t owner) {
11145         LDKCResult_BigSizeDecodeErrorZ* owner_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(owner);
11146         LDKBigSize ret_var = CResult_BigSizeDecodeErrorZ_get_ok(owner_conv);
11147         int64_t ret_ref = 0;
11148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11150         return ret_ref;
11151 }
11152
11153 static inline struct LDKDecodeError CResult_BigSizeDecodeErrorZ_get_err(LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR owner){
11154 CHECK(!owner->result_ok);
11155         return DecodeError_clone(&*owner->contents.err);
11156 }
11157 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_get_err(int64_t owner) {
11158         LDKCResult_BigSizeDecodeErrorZ* owner_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(owner);
11159         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11160         *ret_copy = CResult_BigSizeDecodeErrorZ_get_err(owner_conv);
11161         int64_t ret_ref = tag_ptr(ret_copy, true);
11162         return ret_ref;
11163 }
11164
11165 static inline struct LDKHostname CResult_HostnameDecodeErrorZ_get_ok(LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR owner){
11166         LDKHostname ret = *owner->contents.result;
11167         ret.is_owned = false;
11168         return ret;
11169 }
11170 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_get_ok(int64_t owner) {
11171         LDKCResult_HostnameDecodeErrorZ* owner_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(owner);
11172         LDKHostname ret_var = CResult_HostnameDecodeErrorZ_get_ok(owner_conv);
11173         int64_t ret_ref = 0;
11174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11176         return ret_ref;
11177 }
11178
11179 static inline struct LDKDecodeError CResult_HostnameDecodeErrorZ_get_err(LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR owner){
11180 CHECK(!owner->result_ok);
11181         return DecodeError_clone(&*owner->contents.err);
11182 }
11183 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_get_err(int64_t owner) {
11184         LDKCResult_HostnameDecodeErrorZ* owner_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(owner);
11185         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11186         *ret_copy = CResult_HostnameDecodeErrorZ_get_err(owner_conv);
11187         int64_t ret_ref = tag_ptr(ret_copy, true);
11188         return ret_ref;
11189 }
11190
11191 static inline struct LDKTransactionU16LenLimited CResult_TransactionU16LenLimitedNoneZ_get_ok(LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR owner){
11192         LDKTransactionU16LenLimited ret = *owner->contents.result;
11193         ret.is_owned = false;
11194         return ret;
11195 }
11196 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_get_ok(int64_t owner) {
11197         LDKCResult_TransactionU16LenLimitedNoneZ* owner_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(owner);
11198         LDKTransactionU16LenLimited ret_var = CResult_TransactionU16LenLimitedNoneZ_get_ok(owner_conv);
11199         int64_t ret_ref = 0;
11200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11202         return ret_ref;
11203 }
11204
11205 static inline void CResult_TransactionU16LenLimitedNoneZ_get_err(LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR owner){
11206 CHECK(!owner->result_ok);
11207         return *owner->contents.err;
11208 }
11209 void  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_get_err(int64_t owner) {
11210         LDKCResult_TransactionU16LenLimitedNoneZ* owner_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(owner);
11211         CResult_TransactionU16LenLimitedNoneZ_get_err(owner_conv);
11212 }
11213
11214 static inline struct LDKTransactionU16LenLimited CResult_TransactionU16LenLimitedDecodeErrorZ_get_ok(LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR owner){
11215         LDKTransactionU16LenLimited ret = *owner->contents.result;
11216         ret.is_owned = false;
11217         return ret;
11218 }
11219 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_get_ok(int64_t owner) {
11220         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* owner_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(owner);
11221         LDKTransactionU16LenLimited ret_var = CResult_TransactionU16LenLimitedDecodeErrorZ_get_ok(owner_conv);
11222         int64_t ret_ref = 0;
11223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11225         return ret_ref;
11226 }
11227
11228 static inline struct LDKDecodeError CResult_TransactionU16LenLimitedDecodeErrorZ_get_err(LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR owner){
11229 CHECK(!owner->result_ok);
11230         return DecodeError_clone(&*owner->contents.err);
11231 }
11232 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_get_err(int64_t owner) {
11233         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* owner_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(owner);
11234         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11235         *ret_copy = CResult_TransactionU16LenLimitedDecodeErrorZ_get_err(owner_conv);
11236         int64_t ret_ref = tag_ptr(ret_copy, true);
11237         return ret_ref;
11238 }
11239
11240 static inline struct LDKUntrustedString CResult_UntrustedStringDecodeErrorZ_get_ok(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
11241         LDKUntrustedString ret = *owner->contents.result;
11242         ret.is_owned = false;
11243         return ret;
11244 }
11245 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_get_ok(int64_t owner) {
11246         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
11247         LDKUntrustedString ret_var = CResult_UntrustedStringDecodeErrorZ_get_ok(owner_conv);
11248         int64_t ret_ref = 0;
11249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11251         return ret_ref;
11252 }
11253
11254 static inline struct LDKDecodeError CResult_UntrustedStringDecodeErrorZ_get_err(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR owner){
11255 CHECK(!owner->result_ok);
11256         return DecodeError_clone(&*owner->contents.err);
11257 }
11258 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_get_err(int64_t owner) {
11259         LDKCResult_UntrustedStringDecodeErrorZ* owner_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(owner);
11260         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11261         *ret_copy = CResult_UntrustedStringDecodeErrorZ_get_err(owner_conv);
11262         int64_t ret_ref = tag_ptr(ret_copy, true);
11263         return ret_ref;
11264 }
11265
11266 static inline struct LDKReceiveTlvs CResult_ReceiveTlvsDecodeErrorZ_get_ok(LDKCResult_ReceiveTlvsDecodeErrorZ *NONNULL_PTR owner){
11267         LDKReceiveTlvs ret = *owner->contents.result;
11268         ret.is_owned = false;
11269         return ret;
11270 }
11271 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_get_ok(int64_t owner) {
11272         LDKCResult_ReceiveTlvsDecodeErrorZ* owner_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(owner);
11273         LDKReceiveTlvs ret_var = CResult_ReceiveTlvsDecodeErrorZ_get_ok(owner_conv);
11274         int64_t ret_ref = 0;
11275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11277         return ret_ref;
11278 }
11279
11280 static inline struct LDKDecodeError CResult_ReceiveTlvsDecodeErrorZ_get_err(LDKCResult_ReceiveTlvsDecodeErrorZ *NONNULL_PTR owner){
11281 CHECK(!owner->result_ok);
11282         return DecodeError_clone(&*owner->contents.err);
11283 }
11284 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_get_err(int64_t owner) {
11285         LDKCResult_ReceiveTlvsDecodeErrorZ* owner_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(owner);
11286         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11287         *ret_copy = CResult_ReceiveTlvsDecodeErrorZ_get_err(owner_conv);
11288         int64_t ret_ref = tag_ptr(ret_copy, true);
11289         return ret_ref;
11290 }
11291
11292 static inline struct LDKPaymentRelay CResult_PaymentRelayDecodeErrorZ_get_ok(LDKCResult_PaymentRelayDecodeErrorZ *NONNULL_PTR owner){
11293         LDKPaymentRelay ret = *owner->contents.result;
11294         ret.is_owned = false;
11295         return ret;
11296 }
11297 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_get_ok(int64_t owner) {
11298         LDKCResult_PaymentRelayDecodeErrorZ* owner_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(owner);
11299         LDKPaymentRelay ret_var = CResult_PaymentRelayDecodeErrorZ_get_ok(owner_conv);
11300         int64_t ret_ref = 0;
11301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11303         return ret_ref;
11304 }
11305
11306 static inline struct LDKDecodeError CResult_PaymentRelayDecodeErrorZ_get_err(LDKCResult_PaymentRelayDecodeErrorZ *NONNULL_PTR owner){
11307 CHECK(!owner->result_ok);
11308         return DecodeError_clone(&*owner->contents.err);
11309 }
11310 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_get_err(int64_t owner) {
11311         LDKCResult_PaymentRelayDecodeErrorZ* owner_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(owner);
11312         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11313         *ret_copy = CResult_PaymentRelayDecodeErrorZ_get_err(owner_conv);
11314         int64_t ret_ref = tag_ptr(ret_copy, true);
11315         return ret_ref;
11316 }
11317
11318 static inline struct LDKPaymentConstraints CResult_PaymentConstraintsDecodeErrorZ_get_ok(LDKCResult_PaymentConstraintsDecodeErrorZ *NONNULL_PTR owner){
11319         LDKPaymentConstraints ret = *owner->contents.result;
11320         ret.is_owned = false;
11321         return ret;
11322 }
11323 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_get_ok(int64_t owner) {
11324         LDKCResult_PaymentConstraintsDecodeErrorZ* owner_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(owner);
11325         LDKPaymentConstraints ret_var = CResult_PaymentConstraintsDecodeErrorZ_get_ok(owner_conv);
11326         int64_t ret_ref = 0;
11327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11329         return ret_ref;
11330 }
11331
11332 static inline struct LDKDecodeError CResult_PaymentConstraintsDecodeErrorZ_get_err(LDKCResult_PaymentConstraintsDecodeErrorZ *NONNULL_PTR owner){
11333 CHECK(!owner->result_ok);
11334         return DecodeError_clone(&*owner->contents.err);
11335 }
11336 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_get_err(int64_t owner) {
11337         LDKCResult_PaymentConstraintsDecodeErrorZ* owner_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(owner);
11338         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11339         *ret_copy = CResult_PaymentConstraintsDecodeErrorZ_get_err(owner_conv);
11340         int64_t ret_ref = tag_ptr(ret_copy, true);
11341         return ret_ref;
11342 }
11343
11344 uint32_t CS_LDK_LDKPaymentError_ty_from_ptr(int64_t ptr) {
11345         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
11346         switch(obj->tag) {
11347                 case LDKPaymentError_Invoice: return 0;
11348                 case LDKPaymentError_Sending: return 1;
11349                 default: abort();
11350         }
11351 }
11352 jstring CS_LDK_LDKPaymentError_Invoice_get_invoice(int64_t ptr) {
11353         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
11354         CHECK(obj->tag == LDKPaymentError_Invoice);
11355         LDKStr invoice_str = obj->invoice;
11356                         jstring invoice_conv = str_ref_to_cs(invoice_str.chars, invoice_str.len);
11357         return invoice_conv;
11358 }
11359 int32_t CS_LDK_LDKPaymentError_Sending_get_sending(int64_t ptr) {
11360         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
11361         CHECK(obj->tag == LDKPaymentError_Sending);
11362         int32_t sending_conv = LDKRetryableSendFailure_to_cs(obj->sending);
11363         return sending_conv;
11364 }
11365 static inline struct LDKThirtyTwoBytes CResult_ThirtyTwoBytesPaymentErrorZ_get_ok(LDKCResult_ThirtyTwoBytesPaymentErrorZ *NONNULL_PTR owner){
11366 CHECK(owner->result_ok);
11367         return ThirtyTwoBytes_clone(&*owner->contents.result);
11368 }
11369 int8_tArray  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_get_ok(int64_t owner) {
11370         LDKCResult_ThirtyTwoBytesPaymentErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(owner);
11371         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
11372         memcpy(ret_arr->elems, CResult_ThirtyTwoBytesPaymentErrorZ_get_ok(owner_conv).data, 32);
11373         return ret_arr;
11374 }
11375
11376 static inline struct LDKPaymentError CResult_ThirtyTwoBytesPaymentErrorZ_get_err(LDKCResult_ThirtyTwoBytesPaymentErrorZ *NONNULL_PTR owner){
11377 CHECK(!owner->result_ok);
11378         return PaymentError_clone(&*owner->contents.err);
11379 }
11380 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_get_err(int64_t owner) {
11381         LDKCResult_ThirtyTwoBytesPaymentErrorZ* owner_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(owner);
11382         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
11383         *ret_copy = CResult_ThirtyTwoBytesPaymentErrorZ_get_err(owner_conv);
11384         int64_t ret_ref = tag_ptr(ret_copy, true);
11385         return ret_ref;
11386 }
11387
11388 static inline void CResult_NonePaymentErrorZ_get_ok(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
11389 CHECK(owner->result_ok);
11390         return *owner->contents.result;
11391 }
11392 void  CS_LDK_CResult_NonePaymentErrorZ_get_ok(int64_t owner) {
11393         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
11394         CResult_NonePaymentErrorZ_get_ok(owner_conv);
11395 }
11396
11397 static inline struct LDKPaymentError CResult_NonePaymentErrorZ_get_err(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
11398 CHECK(!owner->result_ok);
11399         return PaymentError_clone(&*owner->contents.err);
11400 }
11401 int64_t  CS_LDK_CResult_NonePaymentErrorZ_get_err(int64_t owner) {
11402         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
11403         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
11404         *ret_copy = CResult_NonePaymentErrorZ_get_err(owner_conv);
11405         int64_t ret_ref = tag_ptr(ret_copy, true);
11406         return ret_ref;
11407 }
11408
11409 uint32_t CS_LDK_LDKProbingError_ty_from_ptr(int64_t ptr) {
11410         LDKProbingError *obj = (LDKProbingError*)untag_ptr(ptr);
11411         switch(obj->tag) {
11412                 case LDKProbingError_Invoice: return 0;
11413                 case LDKProbingError_Sending: return 1;
11414                 default: abort();
11415         }
11416 }
11417 jstring CS_LDK_LDKProbingError_Invoice_get_invoice(int64_t ptr) {
11418         LDKProbingError *obj = (LDKProbingError*)untag_ptr(ptr);
11419         CHECK(obj->tag == LDKProbingError_Invoice);
11420         LDKStr invoice_str = obj->invoice;
11421                         jstring invoice_conv = str_ref_to_cs(invoice_str.chars, invoice_str.len);
11422         return invoice_conv;
11423 }
11424 int64_t CS_LDK_LDKProbingError_Sending_get_sending(int64_t ptr) {
11425         LDKProbingError *obj = (LDKProbingError*)untag_ptr(ptr);
11426         CHECK(obj->tag == LDKProbingError_Sending);
11427         int64_t sending_ref = tag_ptr(&obj->sending, false);
11428         return sending_ref;
11429 }
11430 static inline struct LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_ok(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ *NONNULL_PTR owner){
11431 CHECK(owner->result_ok);
11432         return CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_clone(&*owner->contents.result);
11433 }
11434 int64_tArray  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_ok(int64_t owner) {
11435         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(owner);
11436         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ ret_var = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_ok(owner_conv);
11437         int64_tArray ret_arr = NULL;
11438         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
11439         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
11440         for (size_t o = 0; o < ret_var.datalen; o++) {
11441                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
11442                 *ret_conv_40_conv = ret_var.data[o];
11443                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
11444         }
11445         
11446         FREE(ret_var.data);
11447         return ret_arr;
11448 }
11449
11450 static inline struct LDKProbingError CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_err(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ *NONNULL_PTR owner){
11451 CHECK(!owner->result_ok);
11452         return ProbingError_clone(&*owner->contents.err);
11453 }
11454 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_err(int64_t owner) {
11455         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(owner);
11456         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
11457         *ret_copy = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_get_err(owner_conv);
11458         int64_t ret_ref = tag_ptr(ret_copy, true);
11459         return ret_ref;
11460 }
11461
11462 static inline struct LDKStr CResult_StrSecp256k1ErrorZ_get_ok(LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR owner){
11463 CHECK(owner->result_ok);
11464         return *owner->contents.result;
11465 }
11466 jstring  CS_LDK_CResult_StrSecp256k1ErrorZ_get_ok(int64_t owner) {
11467         LDKCResult_StrSecp256k1ErrorZ* owner_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(owner);
11468         LDKStr ret_str = CResult_StrSecp256k1ErrorZ_get_ok(owner_conv);
11469         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
11470         return ret_conv;
11471 }
11472
11473 static inline enum LDKSecp256k1Error CResult_StrSecp256k1ErrorZ_get_err(LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR owner){
11474 CHECK(!owner->result_ok);
11475         return *owner->contents.err;
11476 }
11477 int32_t  CS_LDK_CResult_StrSecp256k1ErrorZ_get_err(int64_t owner) {
11478         LDKCResult_StrSecp256k1ErrorZ* owner_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(owner);
11479         int32_t ret_conv = LDKSecp256k1Error_to_cs(CResult_StrSecp256k1ErrorZ_get_err(owner_conv));
11480         return ret_conv;
11481 }
11482
11483 static inline struct LDKOnionMessagePath CResult_OnionMessagePathNoneZ_get_ok(LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR owner){
11484         LDKOnionMessagePath ret = *owner->contents.result;
11485         ret.is_owned = false;
11486         return ret;
11487 }
11488 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_get_ok(int64_t owner) {
11489         LDKCResult_OnionMessagePathNoneZ* owner_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(owner);
11490         LDKOnionMessagePath ret_var = CResult_OnionMessagePathNoneZ_get_ok(owner_conv);
11491         int64_t ret_ref = 0;
11492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11494         return ret_ref;
11495 }
11496
11497 static inline void CResult_OnionMessagePathNoneZ_get_err(LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR owner){
11498 CHECK(!owner->result_ok);
11499         return *owner->contents.err;
11500 }
11501 void  CS_LDK_CResult_OnionMessagePathNoneZ_get_err(int64_t owner) {
11502         LDKCResult_OnionMessagePathNoneZ* owner_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(owner);
11503         CResult_OnionMessagePathNoneZ_get_err(owner_conv);
11504 }
11505
11506 static inline struct LDKPublicKey C2Tuple_PublicKeyOnionMessageZ_get_a(LDKC2Tuple_PublicKeyOnionMessageZ *NONNULL_PTR owner){
11507         return owner->a;
11508 }
11509 int8_tArray  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_get_a(int64_t owner) {
11510         LDKC2Tuple_PublicKeyOnionMessageZ* owner_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(owner);
11511         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
11512         memcpy(ret_arr->elems, C2Tuple_PublicKeyOnionMessageZ_get_a(owner_conv).compressed_form, 33);
11513         return ret_arr;
11514 }
11515
11516 static inline struct LDKOnionMessage C2Tuple_PublicKeyOnionMessageZ_get_b(LDKC2Tuple_PublicKeyOnionMessageZ *NONNULL_PTR owner){
11517         LDKOnionMessage ret = owner->b;
11518         ret.is_owned = false;
11519         return ret;
11520 }
11521 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_get_b(int64_t owner) {
11522         LDKC2Tuple_PublicKeyOnionMessageZ* owner_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(owner);
11523         LDKOnionMessage ret_var = C2Tuple_PublicKeyOnionMessageZ_get_b(owner_conv);
11524         int64_t ret_ref = 0;
11525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11527         return ret_ref;
11528 }
11529
11530 uint32_t CS_LDK_LDKSendError_ty_from_ptr(int64_t ptr) {
11531         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
11532         switch(obj->tag) {
11533                 case LDKSendError_Secp256k1: return 0;
11534                 case LDKSendError_TooBigPacket: return 1;
11535                 case LDKSendError_TooFewBlindedHops: return 2;
11536                 case LDKSendError_InvalidFirstHop: return 3;
11537                 case LDKSendError_InvalidMessage: return 4;
11538                 case LDKSendError_BufferFull: return 5;
11539                 case LDKSendError_GetNodeIdFailed: return 6;
11540                 case LDKSendError_BlindedPathAdvanceFailed: return 7;
11541                 default: abort();
11542         }
11543 }
11544 int32_t CS_LDK_LDKSendError_Secp256k1_get_secp256k1(int64_t ptr) {
11545         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
11546         CHECK(obj->tag == LDKSendError_Secp256k1);
11547         int32_t secp256k1_conv = LDKSecp256k1Error_to_cs(obj->secp256k1);
11548         return secp256k1_conv;
11549 }
11550 static inline struct LDKC2Tuple_PublicKeyOnionMessageZ CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_ok(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ *NONNULL_PTR owner){
11551 CHECK(owner->result_ok);
11552         return C2Tuple_PublicKeyOnionMessageZ_clone(&*owner->contents.result);
11553 }
11554 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_ok(int64_t owner) {
11555         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* owner_conv = (LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)untag_ptr(owner);
11556         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
11557         *ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_ok(owner_conv);
11558         return tag_ptr(ret_conv, true);
11559 }
11560
11561 static inline struct LDKSendError CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_err(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ *NONNULL_PTR owner){
11562 CHECK(!owner->result_ok);
11563         return SendError_clone(&*owner->contents.err);
11564 }
11565 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_err(int64_t owner) {
11566         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* owner_conv = (LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)untag_ptr(owner);
11567         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
11568         *ret_copy = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_get_err(owner_conv);
11569         int64_t ret_ref = tag_ptr(ret_copy, true);
11570         return ret_ref;
11571 }
11572
11573 uint32_t CS_LDK_LDKParsedOnionMessageContents_ty_from_ptr(int64_t ptr) {
11574         LDKParsedOnionMessageContents *obj = (LDKParsedOnionMessageContents*)untag_ptr(ptr);
11575         switch(obj->tag) {
11576                 case LDKParsedOnionMessageContents_Offers: return 0;
11577                 case LDKParsedOnionMessageContents_Custom: return 1;
11578                 default: abort();
11579         }
11580 }
11581 int64_t CS_LDK_LDKParsedOnionMessageContents_Offers_get_offers(int64_t ptr) {
11582         LDKParsedOnionMessageContents *obj = (LDKParsedOnionMessageContents*)untag_ptr(ptr);
11583         CHECK(obj->tag == LDKParsedOnionMessageContents_Offers);
11584         int64_t offers_ref = tag_ptr(&obj->offers, false);
11585         return offers_ref;
11586 }
11587 int64_t CS_LDK_LDKParsedOnionMessageContents_Custom_get_custom(int64_t ptr) {
11588         LDKParsedOnionMessageContents *obj = (LDKParsedOnionMessageContents*)untag_ptr(ptr);
11589         CHECK(obj->tag == LDKParsedOnionMessageContents_Custom);
11590         LDKOnionMessageContents* custom_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
11591         *custom_ret = OnionMessageContents_clone(&obj->custom);
11592         return tag_ptr(custom_ret, true);
11593 }
11594 uint32_t CS_LDK_LDKPeeledOnion_ty_from_ptr(int64_t ptr) {
11595         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11596         switch(obj->tag) {
11597                 case LDKPeeledOnion_Forward: return 0;
11598                 case LDKPeeledOnion_Receive: return 1;
11599                 default: abort();
11600         }
11601 }
11602 int8_tArray CS_LDK_LDKPeeledOnion_Forward_get__0(int64_t ptr) {
11603         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11604         CHECK(obj->tag == LDKPeeledOnion_Forward);
11605         int8_tArray _0_arr = init_int8_tArray(33, __LINE__);
11606         memcpy(_0_arr->elems, obj->forward._0.compressed_form, 33);
11607         return _0_arr;
11608 }
11609 int64_t CS_LDK_LDKPeeledOnion_Forward_get__1(int64_t ptr) {
11610         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11611         CHECK(obj->tag == LDKPeeledOnion_Forward);
11612         LDKOnionMessage _1_var = obj->forward._1;
11613                         int64_t _1_ref = 0;
11614                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_1_var);
11615                         _1_ref = tag_ptr(_1_var.inner, false);
11616         return _1_ref;
11617 }
11618 int64_t CS_LDK_LDKPeeledOnion_Receive_get__0(int64_t ptr) {
11619         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11620         CHECK(obj->tag == LDKPeeledOnion_Receive);
11621         int64_t _0_ref = tag_ptr(&obj->receive._0, false);
11622         return _0_ref;
11623 }
11624 int8_tArray CS_LDK_LDKPeeledOnion_Receive_get__1(int64_t ptr) {
11625         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11626         CHECK(obj->tag == LDKPeeledOnion_Receive);
11627         int8_tArray _1_arr = init_int8_tArray(32, __LINE__);
11628         memcpy(_1_arr->elems, obj->receive._1.data, 32);
11629         return _1_arr;
11630 }
11631 int64_t CS_LDK_LDKPeeledOnion_Receive_get__2(int64_t ptr) {
11632         LDKPeeledOnion *obj = (LDKPeeledOnion*)untag_ptr(ptr);
11633         CHECK(obj->tag == LDKPeeledOnion_Receive);
11634         LDKBlindedPath _2_var = obj->receive._2;
11635                         int64_t _2_ref = 0;
11636                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_2_var);
11637                         _2_ref = tag_ptr(_2_var.inner, false);
11638         return _2_ref;
11639 }
11640 static inline struct LDKPeeledOnion CResult_PeeledOnionNoneZ_get_ok(LDKCResult_PeeledOnionNoneZ *NONNULL_PTR owner){
11641 CHECK(owner->result_ok);
11642         return PeeledOnion_clone(&*owner->contents.result);
11643 }
11644 int64_t  CS_LDK_CResult_PeeledOnionNoneZ_get_ok(int64_t owner) {
11645         LDKCResult_PeeledOnionNoneZ* owner_conv = (LDKCResult_PeeledOnionNoneZ*)untag_ptr(owner);
11646         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
11647         *ret_copy = CResult_PeeledOnionNoneZ_get_ok(owner_conv);
11648         int64_t ret_ref = tag_ptr(ret_copy, true);
11649         return ret_ref;
11650 }
11651
11652 static inline void CResult_PeeledOnionNoneZ_get_err(LDKCResult_PeeledOnionNoneZ *NONNULL_PTR owner){
11653 CHECK(!owner->result_ok);
11654         return *owner->contents.err;
11655 }
11656 void  CS_LDK_CResult_PeeledOnionNoneZ_get_err(int64_t owner) {
11657         LDKCResult_PeeledOnionNoneZ* owner_conv = (LDKCResult_PeeledOnionNoneZ*)untag_ptr(owner);
11658         CResult_PeeledOnionNoneZ_get_err(owner_conv);
11659 }
11660
11661 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
11662 CHECK(owner->result_ok);
11663         return *owner->contents.result;
11664 }
11665 void  CS_LDK_CResult_NoneSendErrorZ_get_ok(int64_t owner) {
11666         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
11667         CResult_NoneSendErrorZ_get_ok(owner_conv);
11668 }
11669
11670 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
11671 CHECK(!owner->result_ok);
11672         return SendError_clone(&*owner->contents.err);
11673 }
11674 int64_t  CS_LDK_CResult_NoneSendErrorZ_get_err(int64_t owner) {
11675         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
11676         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
11677         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
11678         int64_t ret_ref = tag_ptr(ret_copy, true);
11679         return ret_ref;
11680 }
11681
11682 static inline struct LDKBlindedPath CResult_BlindedPathNoneZ_get_ok(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
11683         LDKBlindedPath ret = *owner->contents.result;
11684         ret.is_owned = false;
11685         return ret;
11686 }
11687 int64_t  CS_LDK_CResult_BlindedPathNoneZ_get_ok(int64_t owner) {
11688         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
11689         LDKBlindedPath ret_var = CResult_BlindedPathNoneZ_get_ok(owner_conv);
11690         int64_t ret_ref = 0;
11691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11693         return ret_ref;
11694 }
11695
11696 static inline void CResult_BlindedPathNoneZ_get_err(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
11697 CHECK(!owner->result_ok);
11698         return *owner->contents.err;
11699 }
11700 void  CS_LDK_CResult_BlindedPathNoneZ_get_err(int64_t owner) {
11701         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
11702         CResult_BlindedPathNoneZ_get_err(owner_conv);
11703 }
11704
11705 static inline struct LDKC2Tuple_BlindedPayInfoBlindedPathZ CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_ok(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR owner){
11706 CHECK(owner->result_ok);
11707         return C2Tuple_BlindedPayInfoBlindedPathZ_clone(&*owner->contents.result);
11708 }
11709 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_ok(int64_t owner) {
11710         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* owner_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(owner);
11711         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
11712         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_ok(owner_conv);
11713         return tag_ptr(ret_conv, true);
11714 }
11715
11716 static inline void CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_err(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR owner){
11717 CHECK(!owner->result_ok);
11718         return *owner->contents.err;
11719 }
11720 void  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_err(int64_t owner) {
11721         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* owner_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(owner);
11722         CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_get_err(owner_conv);
11723 }
11724
11725 static inline struct LDKBlindedPath CResult_BlindedPathDecodeErrorZ_get_ok(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
11726         LDKBlindedPath ret = *owner->contents.result;
11727         ret.is_owned = false;
11728         return ret;
11729 }
11730 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_get_ok(int64_t owner) {
11731         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
11732         LDKBlindedPath ret_var = CResult_BlindedPathDecodeErrorZ_get_ok(owner_conv);
11733         int64_t ret_ref = 0;
11734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11736         return ret_ref;
11737 }
11738
11739 static inline struct LDKDecodeError CResult_BlindedPathDecodeErrorZ_get_err(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
11740 CHECK(!owner->result_ok);
11741         return DecodeError_clone(&*owner->contents.err);
11742 }
11743 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_get_err(int64_t owner) {
11744         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
11745         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11746         *ret_copy = CResult_BlindedPathDecodeErrorZ_get_err(owner_conv);
11747         int64_t ret_ref = tag_ptr(ret_copy, true);
11748         return ret_ref;
11749 }
11750
11751 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
11752         LDKBlindedHop ret = *owner->contents.result;
11753         ret.is_owned = false;
11754         return ret;
11755 }
11756 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_get_ok(int64_t owner) {
11757         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
11758         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
11759         int64_t ret_ref = 0;
11760         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11761         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11762         return ret_ref;
11763 }
11764
11765 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
11766 CHECK(!owner->result_ok);
11767         return DecodeError_clone(&*owner->contents.err);
11768 }
11769 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_get_err(int64_t owner) {
11770         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
11771         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11772         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
11773         int64_t ret_ref = tag_ptr(ret_copy, true);
11774         return ret_ref;
11775 }
11776
11777 static inline struct LDKInvoiceError CResult_InvoiceErrorDecodeErrorZ_get_ok(LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR owner){
11778         LDKInvoiceError ret = *owner->contents.result;
11779         ret.is_owned = false;
11780         return ret;
11781 }
11782 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_get_ok(int64_t owner) {
11783         LDKCResult_InvoiceErrorDecodeErrorZ* owner_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(owner);
11784         LDKInvoiceError ret_var = CResult_InvoiceErrorDecodeErrorZ_get_ok(owner_conv);
11785         int64_t ret_ref = 0;
11786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11788         return ret_ref;
11789 }
11790
11791 static inline struct LDKDecodeError CResult_InvoiceErrorDecodeErrorZ_get_err(LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR owner){
11792 CHECK(!owner->result_ok);
11793         return DecodeError_clone(&*owner->contents.err);
11794 }
11795 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_get_err(int64_t owner) {
11796         LDKCResult_InvoiceErrorDecodeErrorZ* owner_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(owner);
11797         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
11798         *ret_copy = CResult_InvoiceErrorDecodeErrorZ_get_err(owner_conv);
11799         int64_t ret_ref = tag_ptr(ret_copy, true);
11800         return ret_ref;
11801 }
11802
11803 typedef struct LDKFilter_JCalls {
11804         atomic_size_t refcnt;
11805         uint32_t instance_ptr;
11806 } LDKFilter_JCalls;
11807 static void LDKFilter_JCalls_free(void* this_arg) {
11808         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11809         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11810                 FREE(j_calls);
11811         }
11812 }
11813 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
11814         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11815         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
11816         memcpy(txid_arr->elems, *txid, 32);
11817         LDKu8slice script_pubkey_var = script_pubkey;
11818         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
11819         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
11820         js_invoke_function_void_ll(j_calls->instance_ptr, 51, (int64_t)txid_arr, (int64_t)script_pubkey_arr);
11821 }
11822 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
11823         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
11824         LDKWatchedOutput output_var = output;
11825         int64_t output_ref = 0;
11826         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
11827         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
11828         js_invoke_function_void_l(j_calls->instance_ptr, 52, output_ref);
11829 }
11830 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
11831         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
11832         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11833 }
11834 static inline LDKFilter LDKFilter_init (int64_t o) {
11835         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
11836         atomic_init(&calls->refcnt, 1);
11837         calls->instance_ptr = o;
11838
11839         LDKFilter ret = {
11840                 .this_arg = (void*) calls,
11841                 .register_tx = register_tx_LDKFilter_jcall,
11842                 .register_output = register_output_LDKFilter_jcall,
11843                 .free = LDKFilter_JCalls_free,
11844         };
11845         return ret;
11846 }
11847 uint64_t  CS_LDK_LDKFilter_new(int32_t o) {
11848         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
11849         *res_ptr = LDKFilter_init(o);
11850         return tag_ptr(res_ptr, true);
11851 }
11852 void  CS_LDK_Filter_register_tx(int64_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
11853         void* this_arg_ptr = untag_ptr(this_arg);
11854         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11855         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11856         uint8_t txid_arr[32];
11857         CHECK(txid->arr_len == 32);
11858         memcpy(txid_arr, txid->elems, 32); FREE(txid);
11859         uint8_t (*txid_ref)[32] = &txid_arr;
11860         LDKu8slice script_pubkey_ref;
11861         script_pubkey_ref.datalen = script_pubkey->arr_len;
11862         script_pubkey_ref.data = script_pubkey->elems;
11863         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
11864         FREE(script_pubkey);
11865 }
11866
11867 void  CS_LDK_Filter_register_output(int64_t this_arg, int64_t output) {
11868         void* this_arg_ptr = untag_ptr(this_arg);
11869         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11870         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
11871         LDKWatchedOutput output_conv;
11872         output_conv.inner = untag_ptr(output);
11873         output_conv.is_owned = ptr_is_owned(output);
11874         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
11875         output_conv = WatchedOutput_clone(&output_conv);
11876         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
11877 }
11878
11879 uint32_t CS_LDK_LDKCOption_FilterZ_ty_from_ptr(int64_t ptr) {
11880         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
11881         switch(obj->tag) {
11882                 case LDKCOption_FilterZ_Some: return 0;
11883                 case LDKCOption_FilterZ_None: return 1;
11884                 default: abort();
11885         }
11886 }
11887 int64_t CS_LDK_LDKCOption_FilterZ_Some_get_some(int64_t ptr) {
11888         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
11889         CHECK(obj->tag == LDKCOption_FilterZ_Some);
11890         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
11891         *some_ret = obj->some;
11892                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
11893                         if ((*some_ret).free == LDKFilter_JCalls_free) {
11894                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11895                                 LDKFilter_JCalls_cloned(&(*some_ret));
11896                         }
11897         return tag_ptr(some_ret, true);
11898 }
11899 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11900         LDKLockedChannelMonitor ret = *owner->contents.result;
11901         ret.is_owned = false;
11902         return ret;
11903 }
11904 int64_t  CS_LDK_CResult_LockedChannelMonitorNoneZ_get_ok(int64_t owner) {
11905         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11906         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
11907         int64_t ret_ref = 0;
11908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11910         return ret_ref;
11911 }
11912
11913 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
11914 CHECK(!owner->result_ok);
11915         return *owner->contents.err;
11916 }
11917 void  CS_LDK_CResult_LockedChannelMonitorNoneZ_get_err(int64_t owner) {
11918         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
11919         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
11920 }
11921
11922 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
11923         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
11924         for (size_t i = 0; i < ret.datalen; i++) {
11925                 ret.data[i] = OutPoint_clone(&orig->data[i]);
11926         }
11927         return ret;
11928 }
11929 static inline LDKCVec_MonitorUpdateIdZ CVec_MonitorUpdateIdZ_clone(const LDKCVec_MonitorUpdateIdZ *orig) {
11930         LDKCVec_MonitorUpdateIdZ ret = { .data = MALLOC(sizeof(LDKMonitorUpdateId) * orig->datalen, "LDKCVec_MonitorUpdateIdZ clone bytes"), .datalen = orig->datalen };
11931         for (size_t i = 0; i < ret.datalen; i++) {
11932                 ret.data[i] = MonitorUpdateId_clone(&orig->data[i]);
11933         }
11934         return ret;
11935 }
11936 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11937         LDKOutPoint ret = owner->a;
11938         ret.is_owned = false;
11939         return ret;
11940 }
11941 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(int64_t owner) {
11942         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11943         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(owner_conv);
11944         int64_t ret_ref = 0;
11945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11947         return ret_ref;
11948 }
11949
11950 static inline struct LDKCVec_MonitorUpdateIdZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
11951         return CVec_MonitorUpdateIdZ_clone(&owner->b);
11952 }
11953 int64_tArray  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(int64_t owner) {
11954         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
11955         LDKCVec_MonitorUpdateIdZ ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(owner_conv);
11956         int64_tArray ret_arr = NULL;
11957         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
11958         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
11959         for (size_t r = 0; r < ret_var.datalen; r++) {
11960                 LDKMonitorUpdateId ret_conv_17_var = ret_var.data[r];
11961                 int64_t ret_conv_17_ref = 0;
11962                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_17_var);
11963                 ret_conv_17_ref = tag_ptr(ret_conv_17_var.inner, ret_conv_17_var.is_owned);
11964                 ret_arr_ptr[r] = ret_conv_17_ref;
11965         }
11966         
11967         FREE(ret_var.data);
11968         return ret_arr;
11969 }
11970
11971 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ *orig) {
11972         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ clone bytes"), .datalen = orig->datalen };
11973         for (size_t i = 0; i < ret.datalen; i++) {
11974                 ret.data[i] = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(&orig->data[i]);
11975         }
11976         return ret;
11977 }
11978 typedef struct LDKKVStore_JCalls {
11979         atomic_size_t refcnt;
11980         uint32_t instance_ptr;
11981 } LDKKVStore_JCalls;
11982 static void LDKKVStore_JCalls_free(void* this_arg) {
11983         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
11984         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11985                 FREE(j_calls);
11986         }
11987 }
11988 LDKCResult_CVec_u8ZIOErrorZ read_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace, LDKStr key) {
11989         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
11990         LDKStr primary_namespace_str = primary_namespace;
11991         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
11992         Str_free(primary_namespace_str);
11993         LDKStr secondary_namespace_str = secondary_namespace;
11994         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
11995         Str_free(secondary_namespace_str);
11996         LDKStr key_str = key;
11997         jstring key_conv = str_ref_to_cs(key_str.chars, key_str.len);
11998         Str_free(key_str);
11999         uint64_t ret = js_invoke_function_l_lll(j_calls->instance_ptr, 53, primary_namespace_conv, secondary_namespace_conv, key_conv);
12000         void* ret_ptr = untag_ptr(ret);
12001         CHECK_ACCESS(ret_ptr);
12002         LDKCResult_CVec_u8ZIOErrorZ ret_conv = *(LDKCResult_CVec_u8ZIOErrorZ*)(ret_ptr);
12003         FREE(untag_ptr(ret));
12004         return ret_conv;
12005 }
12006 LDKCResult_NoneIOErrorZ write_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace, LDKStr key, LDKu8slice buf) {
12007         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
12008         LDKStr primary_namespace_str = primary_namespace;
12009         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
12010         Str_free(primary_namespace_str);
12011         LDKStr secondary_namespace_str = secondary_namespace;
12012         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
12013         Str_free(secondary_namespace_str);
12014         LDKStr key_str = key;
12015         jstring key_conv = str_ref_to_cs(key_str.chars, key_str.len);
12016         Str_free(key_str);
12017         LDKu8slice buf_var = buf;
12018         int8_tArray buf_arr = init_int8_tArray(buf_var.datalen, __LINE__);
12019         memcpy(buf_arr->elems, buf_var.data, buf_var.datalen);
12020         uint64_t ret = js_invoke_function_l_llll(j_calls->instance_ptr, 54, primary_namespace_conv, secondary_namespace_conv, key_conv, (int64_t)buf_arr);
12021         void* ret_ptr = untag_ptr(ret);
12022         CHECK_ACCESS(ret_ptr);
12023         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12024         FREE(untag_ptr(ret));
12025         return ret_conv;
12026 }
12027 LDKCResult_NoneIOErrorZ remove_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace, LDKStr key, bool lazy) {
12028         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
12029         LDKStr primary_namespace_str = primary_namespace;
12030         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
12031         Str_free(primary_namespace_str);
12032         LDKStr secondary_namespace_str = secondary_namespace;
12033         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
12034         Str_free(secondary_namespace_str);
12035         LDKStr key_str = key;
12036         jstring key_conv = str_ref_to_cs(key_str.chars, key_str.len);
12037         Str_free(key_str);
12038         jboolean lazy_conv = lazy;
12039         uint64_t ret = js_invoke_function_l_lllb(j_calls->instance_ptr, 55, primary_namespace_conv, secondary_namespace_conv, key_conv, lazy_conv);
12040         void* ret_ptr = untag_ptr(ret);
12041         CHECK_ACCESS(ret_ptr);
12042         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12043         FREE(untag_ptr(ret));
12044         return ret_conv;
12045 }
12046 LDKCResult_CVec_StrZIOErrorZ list_LDKKVStore_jcall(const void* this_arg, LDKStr primary_namespace, LDKStr secondary_namespace) {
12047         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) this_arg;
12048         LDKStr primary_namespace_str = primary_namespace;
12049         jstring primary_namespace_conv = str_ref_to_cs(primary_namespace_str.chars, primary_namespace_str.len);
12050         Str_free(primary_namespace_str);
12051         LDKStr secondary_namespace_str = secondary_namespace;
12052         jstring secondary_namespace_conv = str_ref_to_cs(secondary_namespace_str.chars, secondary_namespace_str.len);
12053         Str_free(secondary_namespace_str);
12054         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 56, primary_namespace_conv, secondary_namespace_conv);
12055         void* ret_ptr = untag_ptr(ret);
12056         CHECK_ACCESS(ret_ptr);
12057         LDKCResult_CVec_StrZIOErrorZ ret_conv = *(LDKCResult_CVec_StrZIOErrorZ*)(ret_ptr);
12058         FREE(untag_ptr(ret));
12059         return ret_conv;
12060 }
12061 static void LDKKVStore_JCalls_cloned(LDKKVStore* new_obj) {
12062         LDKKVStore_JCalls *j_calls = (LDKKVStore_JCalls*) new_obj->this_arg;
12063         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12064 }
12065 static inline LDKKVStore LDKKVStore_init (int64_t o) {
12066         LDKKVStore_JCalls *calls = MALLOC(sizeof(LDKKVStore_JCalls), "LDKKVStore_JCalls");
12067         atomic_init(&calls->refcnt, 1);
12068         calls->instance_ptr = o;
12069
12070         LDKKVStore ret = {
12071                 .this_arg = (void*) calls,
12072                 .read = read_LDKKVStore_jcall,
12073                 .write = write_LDKKVStore_jcall,
12074                 .remove = remove_LDKKVStore_jcall,
12075                 .list = list_LDKKVStore_jcall,
12076                 .free = LDKKVStore_JCalls_free,
12077         };
12078         return ret;
12079 }
12080 uint64_t  CS_LDK_LDKKVStore_new(int32_t o) {
12081         LDKKVStore *res_ptr = MALLOC(sizeof(LDKKVStore), "LDKKVStore");
12082         *res_ptr = LDKKVStore_init(o);
12083         return tag_ptr(res_ptr, true);
12084 }
12085 int64_t  CS_LDK_KVStore_read(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace, jstring key) {
12086         void* this_arg_ptr = untag_ptr(this_arg);
12087         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12088         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12089         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12090         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12091         LDKStr key_conv = str_ref_to_owned_c(key);
12092         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
12093         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv, key_conv);
12094         return tag_ptr(ret_conv, true);
12095 }
12096
12097 int64_t  CS_LDK_KVStore_write(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace, jstring key, int8_tArray buf) {
12098         void* this_arg_ptr = untag_ptr(this_arg);
12099         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12100         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12101         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12102         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12103         LDKStr key_conv = str_ref_to_owned_c(key);
12104         LDKu8slice buf_ref;
12105         buf_ref.datalen = buf->arr_len;
12106         buf_ref.data = buf->elems;
12107         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12108         *ret_conv = (this_arg_conv->write)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv, key_conv, buf_ref);
12109         FREE(buf);
12110         return tag_ptr(ret_conv, true);
12111 }
12112
12113 int64_t  CS_LDK_KVStore_remove(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace, jstring key, jboolean lazy) {
12114         void* this_arg_ptr = untag_ptr(this_arg);
12115         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12116         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12117         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12118         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12119         LDKStr key_conv = str_ref_to_owned_c(key);
12120         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12121         *ret_conv = (this_arg_conv->remove)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv, key_conv, lazy);
12122         return tag_ptr(ret_conv, true);
12123 }
12124
12125 int64_t  CS_LDK_KVStore_list(int64_t this_arg, jstring primary_namespace, jstring secondary_namespace) {
12126         void* this_arg_ptr = untag_ptr(this_arg);
12127         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12128         LDKKVStore* this_arg_conv = (LDKKVStore*)this_arg_ptr;
12129         LDKStr primary_namespace_conv = str_ref_to_owned_c(primary_namespace);
12130         LDKStr secondary_namespace_conv = str_ref_to_owned_c(secondary_namespace);
12131         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
12132         *ret_conv = (this_arg_conv->list)(this_arg_conv->this_arg, primary_namespace_conv, secondary_namespace_conv);
12133         return tag_ptr(ret_conv, true);
12134 }
12135
12136 typedef struct LDKPersister_JCalls {
12137         atomic_size_t refcnt;
12138         uint32_t instance_ptr;
12139 } LDKPersister_JCalls;
12140 static void LDKPersister_JCalls_free(void* this_arg) {
12141         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12142         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12143                 FREE(j_calls);
12144         }
12145 }
12146 LDKCResult_NoneIOErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
12147         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12148         LDKChannelManager channel_manager_var = *channel_manager;
12149         int64_t channel_manager_ref = 0;
12150         // WARNING: we may need a move here but no clone is available for LDKChannelManager
12151         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
12152         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
12153         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 57, channel_manager_ref);
12154         void* ret_ptr = untag_ptr(ret);
12155         CHECK_ACCESS(ret_ptr);
12156         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12157         FREE(untag_ptr(ret));
12158         return ret_conv;
12159 }
12160 LDKCResult_NoneIOErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
12161         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12162         LDKNetworkGraph network_graph_var = *network_graph;
12163         int64_t network_graph_ref = 0;
12164         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
12165         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
12166         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
12167         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 58, network_graph_ref);
12168         void* ret_ptr = untag_ptr(ret);
12169         CHECK_ACCESS(ret_ptr);
12170         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12171         FREE(untag_ptr(ret));
12172         return ret_conv;
12173 }
12174 LDKCResult_NoneIOErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
12175         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
12176         // WARNING: This object doesn't live past this scope, needs clone!
12177         int64_t ret_scorer = tag_ptr(scorer, false);
12178         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 59, ret_scorer);
12179         void* ret_ptr = untag_ptr(ret);
12180         CHECK_ACCESS(ret_ptr);
12181         LDKCResult_NoneIOErrorZ ret_conv = *(LDKCResult_NoneIOErrorZ*)(ret_ptr);
12182         FREE(untag_ptr(ret));
12183         return ret_conv;
12184 }
12185 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
12186         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
12187         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12188 }
12189 static inline LDKPersister LDKPersister_init (int64_t o) {
12190         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
12191         atomic_init(&calls->refcnt, 1);
12192         calls->instance_ptr = o;
12193
12194         LDKPersister ret = {
12195                 .this_arg = (void*) calls,
12196                 .persist_manager = persist_manager_LDKPersister_jcall,
12197                 .persist_graph = persist_graph_LDKPersister_jcall,
12198                 .persist_scorer = persist_scorer_LDKPersister_jcall,
12199                 .free = LDKPersister_JCalls_free,
12200         };
12201         return ret;
12202 }
12203 uint64_t  CS_LDK_LDKPersister_new(int32_t o) {
12204         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
12205         *res_ptr = LDKPersister_init(o);
12206         return tag_ptr(res_ptr, true);
12207 }
12208 int64_t  CS_LDK_Persister_persist_manager(int64_t this_arg, int64_t channel_manager) {
12209         void* this_arg_ptr = untag_ptr(this_arg);
12210         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12211         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12212         LDKChannelManager channel_manager_conv;
12213         channel_manager_conv.inner = untag_ptr(channel_manager);
12214         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
12215         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
12216         channel_manager_conv.is_owned = false;
12217         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12218         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
12219         return tag_ptr(ret_conv, true);
12220 }
12221
12222 int64_t  CS_LDK_Persister_persist_graph(int64_t this_arg, int64_t network_graph) {
12223         void* this_arg_ptr = untag_ptr(this_arg);
12224         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12225         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12226         LDKNetworkGraph network_graph_conv;
12227         network_graph_conv.inner = untag_ptr(network_graph);
12228         network_graph_conv.is_owned = ptr_is_owned(network_graph);
12229         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
12230         network_graph_conv.is_owned = false;
12231         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12232         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
12233         return tag_ptr(ret_conv, true);
12234 }
12235
12236 int64_t  CS_LDK_Persister_persist_scorer(int64_t this_arg, int64_t scorer) {
12237         void* this_arg_ptr = untag_ptr(this_arg);
12238         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12239         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
12240         void* scorer_ptr = untag_ptr(scorer);
12241         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
12242         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
12243         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
12244         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
12245         return tag_ptr(ret_conv, true);
12246 }
12247
12248 typedef struct LDKPersist_JCalls {
12249         atomic_size_t refcnt;
12250         uint32_t instance_ptr;
12251 } LDKPersist_JCalls;
12252 static void LDKPersist_JCalls_free(void* this_arg) {
12253         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12254         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12255                 FREE(j_calls);
12256         }
12257 }
12258 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12259         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12260         LDKOutPoint channel_id_var = channel_id;
12261         int64_t channel_id_ref = 0;
12262         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12263         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12264         LDKChannelMonitor data_var = *data;
12265         int64_t data_ref = 0;
12266         data_var = ChannelMonitor_clone(&data_var);
12267         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12268         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12269         LDKMonitorUpdateId update_id_var = update_id;
12270         int64_t update_id_ref = 0;
12271         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12272         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12273         uint64_t ret = js_invoke_function_ChannelMonitorUpdateStatus_lll(j_calls->instance_ptr, 60, channel_id_ref, data_ref, update_id_ref);
12274         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_cs(ret);
12275         return ret_conv;
12276 }
12277 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, LDKChannelMonitorUpdate update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
12278         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
12279         LDKOutPoint channel_id_var = channel_id;
12280         int64_t channel_id_ref = 0;
12281         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
12282         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
12283         LDKChannelMonitorUpdate update_var = update;
12284         int64_t update_ref = 0;
12285         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
12286         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
12287         LDKChannelMonitor data_var = *data;
12288         int64_t data_ref = 0;
12289         data_var = ChannelMonitor_clone(&data_var);
12290         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12291         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12292         LDKMonitorUpdateId update_id_var = update_id;
12293         int64_t update_id_ref = 0;
12294         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12295         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12296         uint64_t ret = js_invoke_function_ChannelMonitorUpdateStatus_llll(j_calls->instance_ptr, 61, channel_id_ref, update_ref, data_ref, update_id_ref);
12297         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_cs(ret);
12298         return ret_conv;
12299 }
12300 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
12301         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
12302         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12303 }
12304 static inline LDKPersist LDKPersist_init (int64_t o) {
12305         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
12306         atomic_init(&calls->refcnt, 1);
12307         calls->instance_ptr = o;
12308
12309         LDKPersist ret = {
12310                 .this_arg = (void*) calls,
12311                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
12312                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
12313                 .free = LDKPersist_JCalls_free,
12314         };
12315         return ret;
12316 }
12317 uint64_t  CS_LDK_LDKPersist_new(int32_t o) {
12318         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
12319         *res_ptr = LDKPersist_init(o);
12320         return tag_ptr(res_ptr, true);
12321 }
12322 int32_t  CS_LDK_Persist_persist_new_channel(int64_t this_arg, int64_t channel_id, int64_t data, int64_t update_id) {
12323         void* this_arg_ptr = untag_ptr(this_arg);
12324         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12325         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12326         LDKOutPoint channel_id_conv;
12327         channel_id_conv.inner = untag_ptr(channel_id);
12328         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12329         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12330         channel_id_conv = OutPoint_clone(&channel_id_conv);
12331         LDKChannelMonitor data_conv;
12332         data_conv.inner = untag_ptr(data);
12333         data_conv.is_owned = ptr_is_owned(data);
12334         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12335         data_conv.is_owned = false;
12336         LDKMonitorUpdateId update_id_conv;
12337         update_id_conv.inner = untag_ptr(update_id);
12338         update_id_conv.is_owned = ptr_is_owned(update_id);
12339         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12340         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12341         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs((this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv));
12342         return ret_conv;
12343 }
12344
12345 int32_t  CS_LDK_Persist_update_persisted_channel(int64_t this_arg, int64_t channel_id, int64_t update, int64_t data, int64_t update_id) {
12346         void* this_arg_ptr = untag_ptr(this_arg);
12347         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12348         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12349         LDKOutPoint channel_id_conv;
12350         channel_id_conv.inner = untag_ptr(channel_id);
12351         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12352         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12353         channel_id_conv = OutPoint_clone(&channel_id_conv);
12354         LDKChannelMonitorUpdate update_conv;
12355         update_conv.inner = untag_ptr(update);
12356         update_conv.is_owned = ptr_is_owned(update);
12357         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
12358         update_conv = ChannelMonitorUpdate_clone(&update_conv);
12359         LDKChannelMonitor data_conv;
12360         data_conv.inner = untag_ptr(data);
12361         data_conv.is_owned = ptr_is_owned(data);
12362         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12363         data_conv.is_owned = false;
12364         LDKMonitorUpdateId update_id_conv;
12365         update_id_conv.inner = untag_ptr(update_id);
12366         update_id_conv.is_owned = ptr_is_owned(update_id);
12367         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12368         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12369         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs((this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, update_conv, &data_conv, update_id_conv));
12370         return ret_conv;
12371 }
12372
12373 typedef struct LDKFutureCallback_JCalls {
12374         atomic_size_t refcnt;
12375         uint32_t instance_ptr;
12376 } LDKFutureCallback_JCalls;
12377 static void LDKFutureCallback_JCalls_free(void* this_arg) {
12378         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12379         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12380                 FREE(j_calls);
12381         }
12382 }
12383 void call_LDKFutureCallback_jcall(const void* this_arg) {
12384         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
12385         js_invoke_function_void_(j_calls->instance_ptr, 62);
12386 }
12387 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
12388         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
12389         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12390 }
12391 static inline LDKFutureCallback LDKFutureCallback_init (int64_t o) {
12392         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
12393         atomic_init(&calls->refcnt, 1);
12394         calls->instance_ptr = o;
12395
12396         LDKFutureCallback ret = {
12397                 .this_arg = (void*) calls,
12398                 .call = call_LDKFutureCallback_jcall,
12399                 .free = LDKFutureCallback_JCalls_free,
12400         };
12401         return ret;
12402 }
12403 uint64_t  CS_LDK_LDKFutureCallback_new(int32_t o) {
12404         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
12405         *res_ptr = LDKFutureCallback_init(o);
12406         return tag_ptr(res_ptr, true);
12407 }
12408 void  CS_LDK_FutureCallback_call(int64_t this_arg) {
12409         void* this_arg_ptr = untag_ptr(this_arg);
12410         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12411         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
12412         (this_arg_conv->call)(this_arg_conv->this_arg);
12413 }
12414
12415 typedef struct LDKListen_JCalls {
12416         atomic_size_t refcnt;
12417         uint32_t instance_ptr;
12418 } LDKListen_JCalls;
12419 static void LDKListen_JCalls_free(void* this_arg) {
12420         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12421         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12422                 FREE(j_calls);
12423         }
12424 }
12425 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12426         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12427         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12428         memcpy(header_arr->elems, *header, 80);
12429         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12430         int64_tArray txdata_arr = NULL;
12431         txdata_arr = init_int64_tArray(txdata_var.datalen, __LINE__);
12432         int64_t *txdata_arr_ptr = (int64_t*)(((uint8_t*)txdata_arr) + 8);
12433         for (size_t c = 0; c < txdata_var.datalen; c++) {
12434                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12435                 *txdata_conv_28_conv = txdata_var.data[c];
12436                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12437         }
12438         
12439         FREE(txdata_var.data);
12440         int32_t height_conv = height;
12441         js_invoke_function_void_lli(j_calls->instance_ptr, 63, (int64_t)header_arr, (int64_t)txdata_arr, height_conv);
12442 }
12443 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
12444         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12445         LDKu8slice block_var = block;
12446         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
12447         memcpy(block_arr->elems, block_var.data, block_var.datalen);
12448         int32_t height_conv = height;
12449         js_invoke_function_void_li(j_calls->instance_ptr, 64, (int64_t)block_arr, height_conv);
12450 }
12451 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12452         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
12453         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12454         memcpy(header_arr->elems, *header, 80);
12455         int32_t height_conv = height;
12456         js_invoke_function_void_li(j_calls->instance_ptr, 65, (int64_t)header_arr, height_conv);
12457 }
12458 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
12459         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
12460         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12461 }
12462 static inline LDKListen LDKListen_init (int64_t o) {
12463         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
12464         atomic_init(&calls->refcnt, 1);
12465         calls->instance_ptr = o;
12466
12467         LDKListen ret = {
12468                 .this_arg = (void*) calls,
12469                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
12470                 .block_connected = block_connected_LDKListen_jcall,
12471                 .block_disconnected = block_disconnected_LDKListen_jcall,
12472                 .free = LDKListen_JCalls_free,
12473         };
12474         return ret;
12475 }
12476 uint64_t  CS_LDK_LDKListen_new(int32_t o) {
12477         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
12478         *res_ptr = LDKListen_init(o);
12479         return tag_ptr(res_ptr, true);
12480 }
12481 void  CS_LDK_Listen_filtered_block_connected(int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
12482         void* this_arg_ptr = untag_ptr(this_arg);
12483         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12484         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12485         uint8_t header_arr[80];
12486         CHECK(header->arr_len == 80);
12487         memcpy(header_arr, header->elems, 80); FREE(header);
12488         uint8_t (*header_ref)[80] = &header_arr;
12489         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12490         txdata_constr.datalen = txdata->arr_len;
12491         if (txdata_constr.datalen > 0)
12492                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12493         else
12494                 txdata_constr.data = NULL;
12495         int64_t* txdata_vals = txdata->elems;
12496         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12497                 int64_t txdata_conv_28 = txdata_vals[c];
12498                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12499                 CHECK_ACCESS(txdata_conv_28_ptr);
12500                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12501                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12502                 txdata_constr.data[c] = txdata_conv_28_conv;
12503         }
12504         FREE(txdata);
12505         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12506 }
12507
12508 void  CS_LDK_Listen_block_connected(int64_t this_arg, int8_tArray block, int32_t height) {
12509         void* this_arg_ptr = untag_ptr(this_arg);
12510         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12511         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12512         LDKu8slice block_ref;
12513         block_ref.datalen = block->arr_len;
12514         block_ref.data = block->elems;
12515         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
12516         FREE(block);
12517 }
12518
12519 void  CS_LDK_Listen_block_disconnected(int64_t this_arg, int8_tArray header, int32_t height) {
12520         void* this_arg_ptr = untag_ptr(this_arg);
12521         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12522         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
12523         uint8_t header_arr[80];
12524         CHECK(header->arr_len == 80);
12525         memcpy(header_arr, header->elems, 80); FREE(header);
12526         uint8_t (*header_ref)[80] = &header_arr;
12527         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
12528 }
12529
12530 typedef struct LDKConfirm_JCalls {
12531         atomic_size_t refcnt;
12532         uint32_t instance_ptr;
12533 } LDKConfirm_JCalls;
12534 static void LDKConfirm_JCalls_free(void* this_arg) {
12535         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12536         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12537                 FREE(j_calls);
12538         }
12539 }
12540 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
12541         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12542         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12543         memcpy(header_arr->elems, *header, 80);
12544         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
12545         int64_tArray txdata_arr = NULL;
12546         txdata_arr = init_int64_tArray(txdata_var.datalen, __LINE__);
12547         int64_t *txdata_arr_ptr = (int64_t*)(((uint8_t*)txdata_arr) + 8);
12548         for (size_t c = 0; c < txdata_var.datalen; c++) {
12549                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12550                 *txdata_conv_28_conv = txdata_var.data[c];
12551                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
12552         }
12553         
12554         FREE(txdata_var.data);
12555         int32_t height_conv = height;
12556         js_invoke_function_void_lli(j_calls->instance_ptr, 66, (int64_t)header_arr, (int64_t)txdata_arr, height_conv);
12557 }
12558 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
12559         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12560         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
12561         memcpy(txid_arr->elems, *txid, 32);
12562         js_invoke_function_void_l(j_calls->instance_ptr, 67, (int64_t)txid_arr);
12563 }
12564 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
12565         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12566         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
12567         memcpy(header_arr->elems, *header, 80);
12568         int32_t height_conv = height;
12569         js_invoke_function_void_li(j_calls->instance_ptr, 68, (int64_t)header_arr, height_conv);
12570 }
12571 LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
12572         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
12573         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 69);
12574         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret_constr;
12575         ret_constr.datalen = ret->arr_len;
12576         if (ret_constr.datalen > 0)
12577                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ Elements");
12578         else
12579                 ret_constr.data = NULL;
12580         int64_t* ret_vals = ret->elems;
12581         for (size_t x = 0; x < ret_constr.datalen; x++) {
12582                 int64_t ret_conv_49 = ret_vals[x];
12583                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
12584                 CHECK_ACCESS(ret_conv_49_ptr);
12585                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ ret_conv_49_conv = *(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)(ret_conv_49_ptr);
12586                 FREE(untag_ptr(ret_conv_49));
12587                 ret_constr.data[x] = ret_conv_49_conv;
12588         }
12589         FREE(ret);
12590         return ret_constr;
12591 }
12592 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
12593         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
12594         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12595 }
12596 static inline LDKConfirm LDKConfirm_init (int64_t o) {
12597         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
12598         atomic_init(&calls->refcnt, 1);
12599         calls->instance_ptr = o;
12600
12601         LDKConfirm ret = {
12602                 .this_arg = (void*) calls,
12603                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
12604                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
12605                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
12606                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
12607                 .free = LDKConfirm_JCalls_free,
12608         };
12609         return ret;
12610 }
12611 uint64_t  CS_LDK_LDKConfirm_new(int32_t o) {
12612         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
12613         *res_ptr = LDKConfirm_init(o);
12614         return tag_ptr(res_ptr, true);
12615 }
12616 void  CS_LDK_Confirm_transactions_confirmed(int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
12617         void* this_arg_ptr = untag_ptr(this_arg);
12618         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12619         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12620         uint8_t header_arr[80];
12621         CHECK(header->arr_len == 80);
12622         memcpy(header_arr, header->elems, 80); FREE(header);
12623         uint8_t (*header_ref)[80] = &header_arr;
12624         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
12625         txdata_constr.datalen = txdata->arr_len;
12626         if (txdata_constr.datalen > 0)
12627                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12628         else
12629                 txdata_constr.data = NULL;
12630         int64_t* txdata_vals = txdata->elems;
12631         for (size_t c = 0; c < txdata_constr.datalen; c++) {
12632                 int64_t txdata_conv_28 = txdata_vals[c];
12633                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
12634                 CHECK_ACCESS(txdata_conv_28_ptr);
12635                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
12636                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
12637                 txdata_constr.data[c] = txdata_conv_28_conv;
12638         }
12639         FREE(txdata);
12640         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
12641 }
12642
12643 void  CS_LDK_Confirm_transaction_unconfirmed(int64_t this_arg, int8_tArray txid) {
12644         void* this_arg_ptr = untag_ptr(this_arg);
12645         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12646         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12647         uint8_t txid_arr[32];
12648         CHECK(txid->arr_len == 32);
12649         memcpy(txid_arr, txid->elems, 32); FREE(txid);
12650         uint8_t (*txid_ref)[32] = &txid_arr;
12651         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
12652 }
12653
12654 void  CS_LDK_Confirm_best_block_updated(int64_t this_arg, int8_tArray header, int32_t height) {
12655         void* this_arg_ptr = untag_ptr(this_arg);
12656         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12657         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12658         uint8_t header_arr[80];
12659         CHECK(header->arr_len == 80);
12660         memcpy(header_arr, header->elems, 80); FREE(header);
12661         uint8_t (*header_ref)[80] = &header_arr;
12662         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
12663 }
12664
12665 int64_tArray  CS_LDK_Confirm_get_relevant_txids(int64_t this_arg) {
12666         void* this_arg_ptr = untag_ptr(this_arg);
12667         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12668         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
12669         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
12670         int64_tArray ret_arr = NULL;
12671         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
12672         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
12673         for (size_t x = 0; x < ret_var.datalen; x++) {
12674                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
12675                 *ret_conv_49_conv = ret_var.data[x];
12676                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
12677         }
12678         
12679         FREE(ret_var.data);
12680         return ret_arr;
12681 }
12682
12683 typedef struct LDKEventHandler_JCalls {
12684         atomic_size_t refcnt;
12685         uint32_t instance_ptr;
12686 } LDKEventHandler_JCalls;
12687 static void LDKEventHandler_JCalls_free(void* this_arg) {
12688         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12689         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12690                 FREE(j_calls);
12691         }
12692 }
12693 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
12694         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
12695         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
12696         *event_copy = event;
12697         int64_t event_ref = tag_ptr(event_copy, true);
12698         js_invoke_function_void_l(j_calls->instance_ptr, 70, event_ref);
12699 }
12700 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
12701         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
12702         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12703 }
12704 static inline LDKEventHandler LDKEventHandler_init (int64_t o) {
12705         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
12706         atomic_init(&calls->refcnt, 1);
12707         calls->instance_ptr = o;
12708
12709         LDKEventHandler ret = {
12710                 .this_arg = (void*) calls,
12711                 .handle_event = handle_event_LDKEventHandler_jcall,
12712                 .free = LDKEventHandler_JCalls_free,
12713         };
12714         return ret;
12715 }
12716 uint64_t  CS_LDK_LDKEventHandler_new(int32_t o) {
12717         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12718         *res_ptr = LDKEventHandler_init(o);
12719         return tag_ptr(res_ptr, true);
12720 }
12721 void  CS_LDK_EventHandler_handle_event(int64_t this_arg, int64_t event) {
12722         void* this_arg_ptr = untag_ptr(this_arg);
12723         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12724         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
12725         void* event_ptr = untag_ptr(event);
12726         CHECK_ACCESS(event_ptr);
12727         LDKEvent event_conv = *(LDKEvent*)(event_ptr);
12728         event_conv = Event_clone((LDKEvent*)untag_ptr(event));
12729         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
12730 }
12731
12732 typedef struct LDKEventsProvider_JCalls {
12733         atomic_size_t refcnt;
12734         uint32_t instance_ptr;
12735 } LDKEventsProvider_JCalls;
12736 static void LDKEventsProvider_JCalls_free(void* this_arg) {
12737         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12738         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12739                 FREE(j_calls);
12740         }
12741 }
12742 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
12743         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
12744         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
12745         *handler_ret = handler;
12746         js_invoke_function_void_l(j_calls->instance_ptr, 71, tag_ptr(handler_ret, true));
12747 }
12748 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
12749         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
12750         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12751 }
12752 static inline LDKEventsProvider LDKEventsProvider_init (int64_t o) {
12753         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
12754         atomic_init(&calls->refcnt, 1);
12755         calls->instance_ptr = o;
12756
12757         LDKEventsProvider ret = {
12758                 .this_arg = (void*) calls,
12759                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
12760                 .free = LDKEventsProvider_JCalls_free,
12761         };
12762         return ret;
12763 }
12764 uint64_t  CS_LDK_LDKEventsProvider_new(int32_t o) {
12765         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
12766         *res_ptr = LDKEventsProvider_init(o);
12767         return tag_ptr(res_ptr, true);
12768 }
12769 void  CS_LDK_EventsProvider_process_pending_events(int64_t this_arg, int64_t handler) {
12770         void* this_arg_ptr = untag_ptr(this_arg);
12771         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12772         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
12773         void* handler_ptr = untag_ptr(handler);
12774         CHECK_ACCESS(handler_ptr);
12775         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
12776         if (handler_conv.free == LDKEventHandler_JCalls_free) {
12777                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12778                 LDKEventHandler_JCalls_cloned(&handler_conv);
12779         }
12780         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
12781 }
12782
12783 uint32_t CS_LDK_LDKFailureCode_ty_from_ptr(int64_t ptr) {
12784         LDKFailureCode *obj = (LDKFailureCode*)untag_ptr(ptr);
12785         switch(obj->tag) {
12786                 case LDKFailureCode_TemporaryNodeFailure: return 0;
12787                 case LDKFailureCode_RequiredNodeFeatureMissing: return 1;
12788                 case LDKFailureCode_IncorrectOrUnknownPaymentDetails: return 2;
12789                 case LDKFailureCode_InvalidOnionPayload: return 3;
12790                 default: abort();
12791         }
12792 }
12793 int64_t CS_LDK_LDKFailureCode_InvalidOnionPayload_get_invalid_onion_payload(int64_t ptr) {
12794         LDKFailureCode *obj = (LDKFailureCode*)untag_ptr(ptr);
12795         CHECK(obj->tag == LDKFailureCode_InvalidOnionPayload);
12796         int64_t invalid_onion_payload_ref = tag_ptr(&obj->invalid_onion_payload, false);
12797         return invalid_onion_payload_ref;
12798 }
12799 typedef struct LDKMessageSendEventsProvider_JCalls {
12800         atomic_size_t refcnt;
12801         uint32_t instance_ptr;
12802 } LDKMessageSendEventsProvider_JCalls;
12803 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
12804         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
12805         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12806                 FREE(j_calls);
12807         }
12808 }
12809 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
12810         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
12811         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 72);
12812         LDKCVec_MessageSendEventZ ret_constr;
12813         ret_constr.datalen = ret->arr_len;
12814         if (ret_constr.datalen > 0)
12815                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12816         else
12817                 ret_constr.data = NULL;
12818         int64_t* ret_vals = ret->elems;
12819         for (size_t s = 0; s < ret_constr.datalen; s++) {
12820                 int64_t ret_conv_18 = ret_vals[s];
12821                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
12822                 CHECK_ACCESS(ret_conv_18_ptr);
12823                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
12824                 FREE(untag_ptr(ret_conv_18));
12825                 ret_constr.data[s] = ret_conv_18_conv;
12826         }
12827         FREE(ret);
12828         return ret_constr;
12829 }
12830 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
12831         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
12832         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12833 }
12834 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (int64_t o) {
12835         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
12836         atomic_init(&calls->refcnt, 1);
12837         calls->instance_ptr = o;
12838
12839         LDKMessageSendEventsProvider ret = {
12840                 .this_arg = (void*) calls,
12841                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
12842                 .free = LDKMessageSendEventsProvider_JCalls_free,
12843         };
12844         return ret;
12845 }
12846 uint64_t  CS_LDK_LDKMessageSendEventsProvider_new(int32_t o) {
12847         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
12848         *res_ptr = LDKMessageSendEventsProvider_init(o);
12849         return tag_ptr(res_ptr, true);
12850 }
12851 int64_tArray  CS_LDK_MessageSendEventsProvider_get_and_clear_pending_msg_events(int64_t this_arg) {
12852         void* this_arg_ptr = untag_ptr(this_arg);
12853         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12854         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
12855         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
12856         int64_tArray ret_arr = NULL;
12857         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
12858         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
12859         for (size_t s = 0; s < ret_var.datalen; s++) {
12860                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
12861                 *ret_conv_18_copy = ret_var.data[s];
12862                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
12863                 ret_arr_ptr[s] = ret_conv_18_ref;
12864         }
12865         
12866         FREE(ret_var.data);
12867         return ret_arr;
12868 }
12869
12870 typedef struct LDKChannelMessageHandler_JCalls {
12871         atomic_size_t refcnt;
12872         uint32_t instance_ptr;
12873         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12874 } LDKChannelMessageHandler_JCalls;
12875 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
12876         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12877         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12878                 FREE(j_calls);
12879         }
12880 }
12881 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKOpenChannel * msg) {
12882         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12883         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12884         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12885         LDKOpenChannel msg_var = *msg;
12886         int64_t msg_ref = 0;
12887         msg_var = OpenChannel_clone(&msg_var);
12888         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12889         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12890         js_invoke_function_void_ll(j_calls->instance_ptr, 73, (int64_t)their_node_id_arr, msg_ref);
12891 }
12892 void handle_open_channel_v2_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKOpenChannelV2 * msg) {
12893         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12894         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12895         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12896         LDKOpenChannelV2 msg_var = *msg;
12897         int64_t msg_ref = 0;
12898         msg_var = OpenChannelV2_clone(&msg_var);
12899         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12900         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12901         js_invoke_function_void_ll(j_calls->instance_ptr, 74, (int64_t)their_node_id_arr, msg_ref);
12902 }
12903 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAcceptChannel * msg) {
12904         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12905         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12906         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12907         LDKAcceptChannel msg_var = *msg;
12908         int64_t msg_ref = 0;
12909         msg_var = AcceptChannel_clone(&msg_var);
12910         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12911         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12912         js_invoke_function_void_ll(j_calls->instance_ptr, 75, (int64_t)their_node_id_arr, msg_ref);
12913 }
12914 void handle_accept_channel_v2_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAcceptChannelV2 * msg) {
12915         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12916         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12917         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12918         LDKAcceptChannelV2 msg_var = *msg;
12919         int64_t msg_ref = 0;
12920         msg_var = AcceptChannelV2_clone(&msg_var);
12921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12922         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12923         js_invoke_function_void_ll(j_calls->instance_ptr, 76, (int64_t)their_node_id_arr, msg_ref);
12924 }
12925 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
12926         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12927         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12928         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12929         LDKFundingCreated msg_var = *msg;
12930         int64_t msg_ref = 0;
12931         msg_var = FundingCreated_clone(&msg_var);
12932         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12933         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12934         js_invoke_function_void_ll(j_calls->instance_ptr, 77, (int64_t)their_node_id_arr, msg_ref);
12935 }
12936 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
12937         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12938         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12939         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12940         LDKFundingSigned msg_var = *msg;
12941         int64_t msg_ref = 0;
12942         msg_var = FundingSigned_clone(&msg_var);
12943         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12944         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12945         js_invoke_function_void_ll(j_calls->instance_ptr, 78, (int64_t)their_node_id_arr, msg_ref);
12946 }
12947 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
12948         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12949         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12950         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12951         LDKChannelReady msg_var = *msg;
12952         int64_t msg_ref = 0;
12953         msg_var = ChannelReady_clone(&msg_var);
12954         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12955         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12956         js_invoke_function_void_ll(j_calls->instance_ptr, 79, (int64_t)their_node_id_arr, msg_ref);
12957 }
12958 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
12959         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12960         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12961         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12962         LDKShutdown msg_var = *msg;
12963         int64_t msg_ref = 0;
12964         msg_var = Shutdown_clone(&msg_var);
12965         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12966         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12967         js_invoke_function_void_ll(j_calls->instance_ptr, 80, (int64_t)their_node_id_arr, msg_ref);
12968 }
12969 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12970         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12971         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12972         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12973         LDKClosingSigned msg_var = *msg;
12974         int64_t msg_ref = 0;
12975         msg_var = ClosingSigned_clone(&msg_var);
12976         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12977         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12978         js_invoke_function_void_ll(j_calls->instance_ptr, 81, (int64_t)their_node_id_arr, msg_ref);
12979 }
12980 void handle_tx_add_input_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAddInput * msg) {
12981         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12982         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12983         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12984         LDKTxAddInput msg_var = *msg;
12985         int64_t msg_ref = 0;
12986         msg_var = TxAddInput_clone(&msg_var);
12987         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12988         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12989         js_invoke_function_void_ll(j_calls->instance_ptr, 82, (int64_t)their_node_id_arr, msg_ref);
12990 }
12991 void handle_tx_add_output_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAddOutput * msg) {
12992         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12993         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
12994         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
12995         LDKTxAddOutput msg_var = *msg;
12996         int64_t msg_ref = 0;
12997         msg_var = TxAddOutput_clone(&msg_var);
12998         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12999         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13000         js_invoke_function_void_ll(j_calls->instance_ptr, 83, (int64_t)their_node_id_arr, msg_ref);
13001 }
13002 void handle_tx_remove_input_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxRemoveInput * msg) {
13003         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13004         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13005         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13006         LDKTxRemoveInput msg_var = *msg;
13007         int64_t msg_ref = 0;
13008         msg_var = TxRemoveInput_clone(&msg_var);
13009         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13010         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13011         js_invoke_function_void_ll(j_calls->instance_ptr, 84, (int64_t)their_node_id_arr, msg_ref);
13012 }
13013 void handle_tx_remove_output_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxRemoveOutput * msg) {
13014         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13015         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13016         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13017         LDKTxRemoveOutput msg_var = *msg;
13018         int64_t msg_ref = 0;
13019         msg_var = TxRemoveOutput_clone(&msg_var);
13020         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13021         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13022         js_invoke_function_void_ll(j_calls->instance_ptr, 85, (int64_t)their_node_id_arr, msg_ref);
13023 }
13024 void handle_tx_complete_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxComplete * msg) {
13025         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13026         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13027         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13028         LDKTxComplete msg_var = *msg;
13029         int64_t msg_ref = 0;
13030         msg_var = TxComplete_clone(&msg_var);
13031         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13032         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13033         js_invoke_function_void_ll(j_calls->instance_ptr, 86, (int64_t)their_node_id_arr, msg_ref);
13034 }
13035 void handle_tx_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxSignatures * msg) {
13036         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13037         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13038         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13039         LDKTxSignatures msg_var = *msg;
13040         int64_t msg_ref = 0;
13041         msg_var = TxSignatures_clone(&msg_var);
13042         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13043         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13044         js_invoke_function_void_ll(j_calls->instance_ptr, 87, (int64_t)their_node_id_arr, msg_ref);
13045 }
13046 void handle_tx_init_rbf_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxInitRbf * msg) {
13047         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13048         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13049         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13050         LDKTxInitRbf msg_var = *msg;
13051         int64_t msg_ref = 0;
13052         msg_var = TxInitRbf_clone(&msg_var);
13053         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13054         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13055         js_invoke_function_void_ll(j_calls->instance_ptr, 88, (int64_t)their_node_id_arr, msg_ref);
13056 }
13057 void handle_tx_ack_rbf_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAckRbf * msg) {
13058         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13059         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13060         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13061         LDKTxAckRbf msg_var = *msg;
13062         int64_t msg_ref = 0;
13063         msg_var = TxAckRbf_clone(&msg_var);
13064         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13065         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13066         js_invoke_function_void_ll(j_calls->instance_ptr, 89, (int64_t)their_node_id_arr, msg_ref);
13067 }
13068 void handle_tx_abort_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKTxAbort * msg) {
13069         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13070         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13071         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13072         LDKTxAbort msg_var = *msg;
13073         int64_t msg_ref = 0;
13074         msg_var = TxAbort_clone(&msg_var);
13075         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13076         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13077         js_invoke_function_void_ll(j_calls->instance_ptr, 90, (int64_t)their_node_id_arr, msg_ref);
13078 }
13079 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
13080         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13081         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13082         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13083         LDKUpdateAddHTLC msg_var = *msg;
13084         int64_t msg_ref = 0;
13085         msg_var = UpdateAddHTLC_clone(&msg_var);
13086         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13087         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13088         js_invoke_function_void_ll(j_calls->instance_ptr, 91, (int64_t)their_node_id_arr, msg_ref);
13089 }
13090 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
13091         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13092         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13093         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13094         LDKUpdateFulfillHTLC msg_var = *msg;
13095         int64_t msg_ref = 0;
13096         msg_var = UpdateFulfillHTLC_clone(&msg_var);
13097         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13098         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13099         js_invoke_function_void_ll(j_calls->instance_ptr, 92, (int64_t)their_node_id_arr, msg_ref);
13100 }
13101 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
13102         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13103         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13104         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13105         LDKUpdateFailHTLC msg_var = *msg;
13106         int64_t msg_ref = 0;
13107         msg_var = UpdateFailHTLC_clone(&msg_var);
13108         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13109         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13110         js_invoke_function_void_ll(j_calls->instance_ptr, 93, (int64_t)their_node_id_arr, msg_ref);
13111 }
13112 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
13113         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13114         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13115         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13116         LDKUpdateFailMalformedHTLC msg_var = *msg;
13117         int64_t msg_ref = 0;
13118         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
13119         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13120         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13121         js_invoke_function_void_ll(j_calls->instance_ptr, 94, (int64_t)their_node_id_arr, msg_ref);
13122 }
13123 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
13124         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13125         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13126         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13127         LDKCommitmentSigned msg_var = *msg;
13128         int64_t msg_ref = 0;
13129         msg_var = CommitmentSigned_clone(&msg_var);
13130         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13131         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13132         js_invoke_function_void_ll(j_calls->instance_ptr, 95, (int64_t)their_node_id_arr, msg_ref);
13133 }
13134 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
13135         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13136         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13137         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13138         LDKRevokeAndACK msg_var = *msg;
13139         int64_t msg_ref = 0;
13140         msg_var = RevokeAndACK_clone(&msg_var);
13141         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13142         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13143         js_invoke_function_void_ll(j_calls->instance_ptr, 96, (int64_t)their_node_id_arr, msg_ref);
13144 }
13145 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
13146         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13147         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13148         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13149         LDKUpdateFee msg_var = *msg;
13150         int64_t msg_ref = 0;
13151         msg_var = UpdateFee_clone(&msg_var);
13152         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13153         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13154         js_invoke_function_void_ll(j_calls->instance_ptr, 97, (int64_t)their_node_id_arr, msg_ref);
13155 }
13156 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
13157         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13158         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13159         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13160         LDKAnnouncementSignatures msg_var = *msg;
13161         int64_t msg_ref = 0;
13162         msg_var = AnnouncementSignatures_clone(&msg_var);
13163         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13164         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13165         js_invoke_function_void_ll(j_calls->instance_ptr, 98, (int64_t)their_node_id_arr, msg_ref);
13166 }
13167 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13168         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13169         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13170         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13171         js_invoke_function_void_l(j_calls->instance_ptr, 99, (int64_t)their_node_id_arr);
13172 }
13173 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg, bool inbound) {
13174         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13175         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13176         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13177         LDKInit msg_var = *msg;
13178         int64_t msg_ref = 0;
13179         msg_var = Init_clone(&msg_var);
13180         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13181         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13182         jboolean inbound_conv = inbound;
13183         uint64_t ret = js_invoke_function_l_llb(j_calls->instance_ptr, 100, (int64_t)their_node_id_arr, msg_ref, inbound_conv);
13184         void* ret_ptr = untag_ptr(ret);
13185         CHECK_ACCESS(ret_ptr);
13186         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13187         FREE(untag_ptr(ret));
13188         return ret_conv;
13189 }
13190 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
13191         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13192         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13193         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13194         LDKChannelReestablish msg_var = *msg;
13195         int64_t msg_ref = 0;
13196         msg_var = ChannelReestablish_clone(&msg_var);
13197         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13198         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13199         js_invoke_function_void_ll(j_calls->instance_ptr, 101, (int64_t)their_node_id_arr, msg_ref);
13200 }
13201 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
13202         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13203         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13204         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13205         LDKChannelUpdate msg_var = *msg;
13206         int64_t msg_ref = 0;
13207         msg_var = ChannelUpdate_clone(&msg_var);
13208         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13209         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13210         js_invoke_function_void_ll(j_calls->instance_ptr, 102, (int64_t)their_node_id_arr, msg_ref);
13211 }
13212 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
13213         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13214         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13215         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13216         LDKErrorMessage msg_var = *msg;
13217         int64_t msg_ref = 0;
13218         msg_var = ErrorMessage_clone(&msg_var);
13219         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13220         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13221         js_invoke_function_void_ll(j_calls->instance_ptr, 103, (int64_t)their_node_id_arr, msg_ref);
13222 }
13223 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
13224         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13225         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 104);
13226         LDKNodeFeatures ret_conv;
13227         ret_conv.inner = untag_ptr(ret);
13228         ret_conv.is_owned = ptr_is_owned(ret);
13229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13230         return ret_conv;
13231 }
13232 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13233         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13234         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13235         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13236         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 105, (int64_t)their_node_id_arr);
13237         LDKInitFeatures ret_conv;
13238         ret_conv.inner = untag_ptr(ret);
13239         ret_conv.is_owned = ptr_is_owned(ret);
13240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13241         return ret_conv;
13242 }
13243 LDKCOption_CVec_ThirtyTwoBytesZZ get_chain_hashes_LDKChannelMessageHandler_jcall(const void* this_arg) {
13244         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
13245         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 106);
13246         void* ret_ptr = untag_ptr(ret);
13247         CHECK_ACCESS(ret_ptr);
13248         LDKCOption_CVec_ThirtyTwoBytesZZ ret_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(ret_ptr);
13249         FREE(untag_ptr(ret));
13250         return ret_conv;
13251 }
13252 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
13253         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
13254         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13255         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13256 }
13257 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (int64_t o, int64_t MessageSendEventsProvider) {
13258         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
13259         atomic_init(&calls->refcnt, 1);
13260         calls->instance_ptr = o;
13261
13262         LDKChannelMessageHandler ret = {
13263                 .this_arg = (void*) calls,
13264                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
13265                 .handle_open_channel_v2 = handle_open_channel_v2_LDKChannelMessageHandler_jcall,
13266                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
13267                 .handle_accept_channel_v2 = handle_accept_channel_v2_LDKChannelMessageHandler_jcall,
13268                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
13269                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
13270                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
13271                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
13272                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
13273                 .handle_tx_add_input = handle_tx_add_input_LDKChannelMessageHandler_jcall,
13274                 .handle_tx_add_output = handle_tx_add_output_LDKChannelMessageHandler_jcall,
13275                 .handle_tx_remove_input = handle_tx_remove_input_LDKChannelMessageHandler_jcall,
13276                 .handle_tx_remove_output = handle_tx_remove_output_LDKChannelMessageHandler_jcall,
13277                 .handle_tx_complete = handle_tx_complete_LDKChannelMessageHandler_jcall,
13278                 .handle_tx_signatures = handle_tx_signatures_LDKChannelMessageHandler_jcall,
13279                 .handle_tx_init_rbf = handle_tx_init_rbf_LDKChannelMessageHandler_jcall,
13280                 .handle_tx_ack_rbf = handle_tx_ack_rbf_LDKChannelMessageHandler_jcall,
13281                 .handle_tx_abort = handle_tx_abort_LDKChannelMessageHandler_jcall,
13282                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
13283                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
13284                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
13285                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
13286                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
13287                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
13288                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
13289                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
13290                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
13291                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
13292                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
13293                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
13294                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
13295                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
13296                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
13297                 .get_chain_hashes = get_chain_hashes_LDKChannelMessageHandler_jcall,
13298                 .free = LDKChannelMessageHandler_JCalls_free,
13299                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
13300         };
13301         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13302         return ret;
13303 }
13304 uint64_t  CS_LDK_LDKChannelMessageHandler_new(int32_t o, int32_t MessageSendEventsProvider) {
13305         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
13306         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
13307         return tag_ptr(res_ptr, true);
13308 }
13309 void  CS_LDK_ChannelMessageHandler_handle_open_channel(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13310         void* this_arg_ptr = untag_ptr(this_arg);
13311         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13312         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13313         LDKPublicKey their_node_id_ref;
13314         CHECK(their_node_id->arr_len == 33);
13315         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13316         LDKOpenChannel msg_conv;
13317         msg_conv.inner = untag_ptr(msg);
13318         msg_conv.is_owned = ptr_is_owned(msg);
13319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13320         msg_conv.is_owned = false;
13321         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13322 }
13323
13324 void  CS_LDK_ChannelMessageHandler_handle_open_channel_v2(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13325         void* this_arg_ptr = untag_ptr(this_arg);
13326         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13327         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13328         LDKPublicKey their_node_id_ref;
13329         CHECK(their_node_id->arr_len == 33);
13330         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13331         LDKOpenChannelV2 msg_conv;
13332         msg_conv.inner = untag_ptr(msg);
13333         msg_conv.is_owned = ptr_is_owned(msg);
13334         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13335         msg_conv.is_owned = false;
13336         (this_arg_conv->handle_open_channel_v2)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13337 }
13338
13339 void  CS_LDK_ChannelMessageHandler_handle_accept_channel(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13340         void* this_arg_ptr = untag_ptr(this_arg);
13341         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13342         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13343         LDKPublicKey their_node_id_ref;
13344         CHECK(their_node_id->arr_len == 33);
13345         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13346         LDKAcceptChannel msg_conv;
13347         msg_conv.inner = untag_ptr(msg);
13348         msg_conv.is_owned = ptr_is_owned(msg);
13349         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13350         msg_conv.is_owned = false;
13351         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13352 }
13353
13354 void  CS_LDK_ChannelMessageHandler_handle_accept_channel_v2(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13355         void* this_arg_ptr = untag_ptr(this_arg);
13356         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13357         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13358         LDKPublicKey their_node_id_ref;
13359         CHECK(their_node_id->arr_len == 33);
13360         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13361         LDKAcceptChannelV2 msg_conv;
13362         msg_conv.inner = untag_ptr(msg);
13363         msg_conv.is_owned = ptr_is_owned(msg);
13364         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13365         msg_conv.is_owned = false;
13366         (this_arg_conv->handle_accept_channel_v2)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13367 }
13368
13369 void  CS_LDK_ChannelMessageHandler_handle_funding_created(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13370         void* this_arg_ptr = untag_ptr(this_arg);
13371         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13372         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13373         LDKPublicKey their_node_id_ref;
13374         CHECK(their_node_id->arr_len == 33);
13375         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13376         LDKFundingCreated msg_conv;
13377         msg_conv.inner = untag_ptr(msg);
13378         msg_conv.is_owned = ptr_is_owned(msg);
13379         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13380         msg_conv.is_owned = false;
13381         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13382 }
13383
13384 void  CS_LDK_ChannelMessageHandler_handle_funding_signed(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13385         void* this_arg_ptr = untag_ptr(this_arg);
13386         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13387         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13388         LDKPublicKey their_node_id_ref;
13389         CHECK(their_node_id->arr_len == 33);
13390         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13391         LDKFundingSigned msg_conv;
13392         msg_conv.inner = untag_ptr(msg);
13393         msg_conv.is_owned = ptr_is_owned(msg);
13394         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13395         msg_conv.is_owned = false;
13396         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13397 }
13398
13399 void  CS_LDK_ChannelMessageHandler_handle_channel_ready(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13400         void* this_arg_ptr = untag_ptr(this_arg);
13401         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13402         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13403         LDKPublicKey their_node_id_ref;
13404         CHECK(their_node_id->arr_len == 33);
13405         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13406         LDKChannelReady msg_conv;
13407         msg_conv.inner = untag_ptr(msg);
13408         msg_conv.is_owned = ptr_is_owned(msg);
13409         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13410         msg_conv.is_owned = false;
13411         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13412 }
13413
13414 void  CS_LDK_ChannelMessageHandler_handle_shutdown(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13415         void* this_arg_ptr = untag_ptr(this_arg);
13416         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13417         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13418         LDKPublicKey their_node_id_ref;
13419         CHECK(their_node_id->arr_len == 33);
13420         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13421         LDKShutdown msg_conv;
13422         msg_conv.inner = untag_ptr(msg);
13423         msg_conv.is_owned = ptr_is_owned(msg);
13424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13425         msg_conv.is_owned = false;
13426         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13427 }
13428
13429 void  CS_LDK_ChannelMessageHandler_handle_closing_signed(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13430         void* this_arg_ptr = untag_ptr(this_arg);
13431         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13432         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13433         LDKPublicKey their_node_id_ref;
13434         CHECK(their_node_id->arr_len == 33);
13435         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13436         LDKClosingSigned msg_conv;
13437         msg_conv.inner = untag_ptr(msg);
13438         msg_conv.is_owned = ptr_is_owned(msg);
13439         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13440         msg_conv.is_owned = false;
13441         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13442 }
13443
13444 void  CS_LDK_ChannelMessageHandler_handle_tx_add_input(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13445         void* this_arg_ptr = untag_ptr(this_arg);
13446         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13447         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13448         LDKPublicKey their_node_id_ref;
13449         CHECK(their_node_id->arr_len == 33);
13450         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13451         LDKTxAddInput msg_conv;
13452         msg_conv.inner = untag_ptr(msg);
13453         msg_conv.is_owned = ptr_is_owned(msg);
13454         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13455         msg_conv.is_owned = false;
13456         (this_arg_conv->handle_tx_add_input)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13457 }
13458
13459 void  CS_LDK_ChannelMessageHandler_handle_tx_add_output(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13460         void* this_arg_ptr = untag_ptr(this_arg);
13461         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13462         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13463         LDKPublicKey their_node_id_ref;
13464         CHECK(their_node_id->arr_len == 33);
13465         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13466         LDKTxAddOutput msg_conv;
13467         msg_conv.inner = untag_ptr(msg);
13468         msg_conv.is_owned = ptr_is_owned(msg);
13469         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13470         msg_conv.is_owned = false;
13471         (this_arg_conv->handle_tx_add_output)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13472 }
13473
13474 void  CS_LDK_ChannelMessageHandler_handle_tx_remove_input(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13475         void* this_arg_ptr = untag_ptr(this_arg);
13476         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13477         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13478         LDKPublicKey their_node_id_ref;
13479         CHECK(their_node_id->arr_len == 33);
13480         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13481         LDKTxRemoveInput msg_conv;
13482         msg_conv.inner = untag_ptr(msg);
13483         msg_conv.is_owned = ptr_is_owned(msg);
13484         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13485         msg_conv.is_owned = false;
13486         (this_arg_conv->handle_tx_remove_input)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13487 }
13488
13489 void  CS_LDK_ChannelMessageHandler_handle_tx_remove_output(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13490         void* this_arg_ptr = untag_ptr(this_arg);
13491         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13492         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13493         LDKPublicKey their_node_id_ref;
13494         CHECK(their_node_id->arr_len == 33);
13495         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13496         LDKTxRemoveOutput msg_conv;
13497         msg_conv.inner = untag_ptr(msg);
13498         msg_conv.is_owned = ptr_is_owned(msg);
13499         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13500         msg_conv.is_owned = false;
13501         (this_arg_conv->handle_tx_remove_output)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13502 }
13503
13504 void  CS_LDK_ChannelMessageHandler_handle_tx_complete(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13505         void* this_arg_ptr = untag_ptr(this_arg);
13506         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13507         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13508         LDKPublicKey their_node_id_ref;
13509         CHECK(their_node_id->arr_len == 33);
13510         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13511         LDKTxComplete msg_conv;
13512         msg_conv.inner = untag_ptr(msg);
13513         msg_conv.is_owned = ptr_is_owned(msg);
13514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13515         msg_conv.is_owned = false;
13516         (this_arg_conv->handle_tx_complete)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13517 }
13518
13519 void  CS_LDK_ChannelMessageHandler_handle_tx_signatures(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13520         void* this_arg_ptr = untag_ptr(this_arg);
13521         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13522         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13523         LDKPublicKey their_node_id_ref;
13524         CHECK(their_node_id->arr_len == 33);
13525         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13526         LDKTxSignatures msg_conv;
13527         msg_conv.inner = untag_ptr(msg);
13528         msg_conv.is_owned = ptr_is_owned(msg);
13529         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13530         msg_conv.is_owned = false;
13531         (this_arg_conv->handle_tx_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13532 }
13533
13534 void  CS_LDK_ChannelMessageHandler_handle_tx_init_rbf(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13535         void* this_arg_ptr = untag_ptr(this_arg);
13536         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13537         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13538         LDKPublicKey their_node_id_ref;
13539         CHECK(their_node_id->arr_len == 33);
13540         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13541         LDKTxInitRbf msg_conv;
13542         msg_conv.inner = untag_ptr(msg);
13543         msg_conv.is_owned = ptr_is_owned(msg);
13544         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13545         msg_conv.is_owned = false;
13546         (this_arg_conv->handle_tx_init_rbf)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13547 }
13548
13549 void  CS_LDK_ChannelMessageHandler_handle_tx_ack_rbf(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13550         void* this_arg_ptr = untag_ptr(this_arg);
13551         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13552         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13553         LDKPublicKey their_node_id_ref;
13554         CHECK(their_node_id->arr_len == 33);
13555         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13556         LDKTxAckRbf msg_conv;
13557         msg_conv.inner = untag_ptr(msg);
13558         msg_conv.is_owned = ptr_is_owned(msg);
13559         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13560         msg_conv.is_owned = false;
13561         (this_arg_conv->handle_tx_ack_rbf)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13562 }
13563
13564 void  CS_LDK_ChannelMessageHandler_handle_tx_abort(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13565         void* this_arg_ptr = untag_ptr(this_arg);
13566         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13567         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13568         LDKPublicKey their_node_id_ref;
13569         CHECK(their_node_id->arr_len == 33);
13570         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13571         LDKTxAbort msg_conv;
13572         msg_conv.inner = untag_ptr(msg);
13573         msg_conv.is_owned = ptr_is_owned(msg);
13574         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13575         msg_conv.is_owned = false;
13576         (this_arg_conv->handle_tx_abort)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13577 }
13578
13579 void  CS_LDK_ChannelMessageHandler_handle_update_add_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13580         void* this_arg_ptr = untag_ptr(this_arg);
13581         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13582         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13583         LDKPublicKey their_node_id_ref;
13584         CHECK(their_node_id->arr_len == 33);
13585         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13586         LDKUpdateAddHTLC msg_conv;
13587         msg_conv.inner = untag_ptr(msg);
13588         msg_conv.is_owned = ptr_is_owned(msg);
13589         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13590         msg_conv.is_owned = false;
13591         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13592 }
13593
13594 void  CS_LDK_ChannelMessageHandler_handle_update_fulfill_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13595         void* this_arg_ptr = untag_ptr(this_arg);
13596         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13597         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13598         LDKPublicKey their_node_id_ref;
13599         CHECK(their_node_id->arr_len == 33);
13600         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13601         LDKUpdateFulfillHTLC msg_conv;
13602         msg_conv.inner = untag_ptr(msg);
13603         msg_conv.is_owned = ptr_is_owned(msg);
13604         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13605         msg_conv.is_owned = false;
13606         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13607 }
13608
13609 void  CS_LDK_ChannelMessageHandler_handle_update_fail_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13610         void* this_arg_ptr = untag_ptr(this_arg);
13611         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13612         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13613         LDKPublicKey their_node_id_ref;
13614         CHECK(their_node_id->arr_len == 33);
13615         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13616         LDKUpdateFailHTLC msg_conv;
13617         msg_conv.inner = untag_ptr(msg);
13618         msg_conv.is_owned = ptr_is_owned(msg);
13619         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13620         msg_conv.is_owned = false;
13621         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13622 }
13623
13624 void  CS_LDK_ChannelMessageHandler_handle_update_fail_malformed_htlc(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13625         void* this_arg_ptr = untag_ptr(this_arg);
13626         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13627         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13628         LDKPublicKey their_node_id_ref;
13629         CHECK(their_node_id->arr_len == 33);
13630         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13631         LDKUpdateFailMalformedHTLC msg_conv;
13632         msg_conv.inner = untag_ptr(msg);
13633         msg_conv.is_owned = ptr_is_owned(msg);
13634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13635         msg_conv.is_owned = false;
13636         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13637 }
13638
13639 void  CS_LDK_ChannelMessageHandler_handle_commitment_signed(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13640         void* this_arg_ptr = untag_ptr(this_arg);
13641         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13642         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13643         LDKPublicKey their_node_id_ref;
13644         CHECK(their_node_id->arr_len == 33);
13645         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13646         LDKCommitmentSigned msg_conv;
13647         msg_conv.inner = untag_ptr(msg);
13648         msg_conv.is_owned = ptr_is_owned(msg);
13649         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13650         msg_conv.is_owned = false;
13651         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13652 }
13653
13654 void  CS_LDK_ChannelMessageHandler_handle_revoke_and_ack(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13655         void* this_arg_ptr = untag_ptr(this_arg);
13656         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13657         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13658         LDKPublicKey their_node_id_ref;
13659         CHECK(their_node_id->arr_len == 33);
13660         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13661         LDKRevokeAndACK msg_conv;
13662         msg_conv.inner = untag_ptr(msg);
13663         msg_conv.is_owned = ptr_is_owned(msg);
13664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13665         msg_conv.is_owned = false;
13666         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13667 }
13668
13669 void  CS_LDK_ChannelMessageHandler_handle_update_fee(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13670         void* this_arg_ptr = untag_ptr(this_arg);
13671         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13672         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13673         LDKPublicKey their_node_id_ref;
13674         CHECK(their_node_id->arr_len == 33);
13675         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13676         LDKUpdateFee msg_conv;
13677         msg_conv.inner = untag_ptr(msg);
13678         msg_conv.is_owned = ptr_is_owned(msg);
13679         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13680         msg_conv.is_owned = false;
13681         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13682 }
13683
13684 void  CS_LDK_ChannelMessageHandler_handle_announcement_signatures(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13685         void* this_arg_ptr = untag_ptr(this_arg);
13686         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13687         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13688         LDKPublicKey their_node_id_ref;
13689         CHECK(their_node_id->arr_len == 33);
13690         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13691         LDKAnnouncementSignatures msg_conv;
13692         msg_conv.inner = untag_ptr(msg);
13693         msg_conv.is_owned = ptr_is_owned(msg);
13694         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13695         msg_conv.is_owned = false;
13696         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13697 }
13698
13699 void  CS_LDK_ChannelMessageHandler_peer_disconnected(int64_t this_arg, int8_tArray their_node_id) {
13700         void* this_arg_ptr = untag_ptr(this_arg);
13701         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13702         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13703         LDKPublicKey their_node_id_ref;
13704         CHECK(their_node_id->arr_len == 33);
13705         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13706         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
13707 }
13708
13709 int64_t  CS_LDK_ChannelMessageHandler_peer_connected(int64_t this_arg, int8_tArray their_node_id, int64_t msg, jboolean inbound) {
13710         void* this_arg_ptr = untag_ptr(this_arg);
13711         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13712         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13713         LDKPublicKey their_node_id_ref;
13714         CHECK(their_node_id->arr_len == 33);
13715         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13716         LDKInit msg_conv;
13717         msg_conv.inner = untag_ptr(msg);
13718         msg_conv.is_owned = ptr_is_owned(msg);
13719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13720         msg_conv.is_owned = false;
13721         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13722         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv, inbound);
13723         return tag_ptr(ret_conv, true);
13724 }
13725
13726 void  CS_LDK_ChannelMessageHandler_handle_channel_reestablish(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13727         void* this_arg_ptr = untag_ptr(this_arg);
13728         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13729         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13730         LDKPublicKey their_node_id_ref;
13731         CHECK(their_node_id->arr_len == 33);
13732         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13733         LDKChannelReestablish msg_conv;
13734         msg_conv.inner = untag_ptr(msg);
13735         msg_conv.is_owned = ptr_is_owned(msg);
13736         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13737         msg_conv.is_owned = false;
13738         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13739 }
13740
13741 void  CS_LDK_ChannelMessageHandler_handle_channel_update(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13742         void* this_arg_ptr = untag_ptr(this_arg);
13743         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13744         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13745         LDKPublicKey their_node_id_ref;
13746         CHECK(their_node_id->arr_len == 33);
13747         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13748         LDKChannelUpdate msg_conv;
13749         msg_conv.inner = untag_ptr(msg);
13750         msg_conv.is_owned = ptr_is_owned(msg);
13751         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13752         msg_conv.is_owned = false;
13753         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13754 }
13755
13756 void  CS_LDK_ChannelMessageHandler_handle_error(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
13757         void* this_arg_ptr = untag_ptr(this_arg);
13758         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13759         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13760         LDKPublicKey their_node_id_ref;
13761         CHECK(their_node_id->arr_len == 33);
13762         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13763         LDKErrorMessage msg_conv;
13764         msg_conv.inner = untag_ptr(msg);
13765         msg_conv.is_owned = ptr_is_owned(msg);
13766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13767         msg_conv.is_owned = false;
13768         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13769 }
13770
13771 int64_t  CS_LDK_ChannelMessageHandler_provided_node_features(int64_t this_arg) {
13772         void* this_arg_ptr = untag_ptr(this_arg);
13773         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13774         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13775         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13776         int64_t ret_ref = 0;
13777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13779         return ret_ref;
13780 }
13781
13782 int64_t  CS_LDK_ChannelMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
13783         void* this_arg_ptr = untag_ptr(this_arg);
13784         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13785         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13786         LDKPublicKey their_node_id_ref;
13787         CHECK(their_node_id->arr_len == 33);
13788         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
13789         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13790         int64_t ret_ref = 0;
13791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13793         return ret_ref;
13794 }
13795
13796 int64_t  CS_LDK_ChannelMessageHandler_get_chain_hashes(int64_t this_arg) {
13797         void* this_arg_ptr = untag_ptr(this_arg);
13798         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13799         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13800         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
13801         *ret_copy = (this_arg_conv->get_chain_hashes)(this_arg_conv->this_arg);
13802         int64_t ret_ref = tag_ptr(ret_copy, true);
13803         return ret_ref;
13804 }
13805
13806 typedef struct LDKOffersMessageHandler_JCalls {
13807         atomic_size_t refcnt;
13808         uint32_t instance_ptr;
13809 } LDKOffersMessageHandler_JCalls;
13810 static void LDKOffersMessageHandler_JCalls_free(void* this_arg) {
13811         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) this_arg;
13812         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13813                 FREE(j_calls);
13814         }
13815 }
13816 LDKCOption_OffersMessageZ handle_message_LDKOffersMessageHandler_jcall(const void* this_arg, LDKOffersMessage message) {
13817         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) this_arg;
13818         LDKOffersMessage *message_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
13819         *message_copy = message;
13820         int64_t message_ref = tag_ptr(message_copy, true);
13821         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 107, message_ref);
13822         void* ret_ptr = untag_ptr(ret);
13823         CHECK_ACCESS(ret_ptr);
13824         LDKCOption_OffersMessageZ ret_conv = *(LDKCOption_OffersMessageZ*)(ret_ptr);
13825         FREE(untag_ptr(ret));
13826         return ret_conv;
13827 }
13828 LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ release_pending_messages_LDKOffersMessageHandler_jcall(const void* this_arg) {
13829         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) this_arg;
13830         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 108);
13831         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret_constr;
13832         ret_constr.datalen = ret->arr_len;
13833         if (ret_constr.datalen > 0)
13834                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ Elements");
13835         else
13836                 ret_constr.data = NULL;
13837         int64_t* ret_vals = ret->elems;
13838         for (size_t x = 0; x < ret_constr.datalen; x++) {
13839                 int64_t ret_conv_49 = ret_vals[x];
13840                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
13841                 CHECK_ACCESS(ret_conv_49_ptr);
13842                 LDKC3Tuple_OffersMessageDestinationBlindedPathZ ret_conv_49_conv = *(LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)(ret_conv_49_ptr);
13843                 FREE(untag_ptr(ret_conv_49));
13844                 ret_constr.data[x] = ret_conv_49_conv;
13845         }
13846         FREE(ret);
13847         return ret_constr;
13848 }
13849 static void LDKOffersMessageHandler_JCalls_cloned(LDKOffersMessageHandler* new_obj) {
13850         LDKOffersMessageHandler_JCalls *j_calls = (LDKOffersMessageHandler_JCalls*) new_obj->this_arg;
13851         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13852 }
13853 static inline LDKOffersMessageHandler LDKOffersMessageHandler_init (int64_t o) {
13854         LDKOffersMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOffersMessageHandler_JCalls), "LDKOffersMessageHandler_JCalls");
13855         atomic_init(&calls->refcnt, 1);
13856         calls->instance_ptr = o;
13857
13858         LDKOffersMessageHandler ret = {
13859                 .this_arg = (void*) calls,
13860                 .handle_message = handle_message_LDKOffersMessageHandler_jcall,
13861                 .release_pending_messages = release_pending_messages_LDKOffersMessageHandler_jcall,
13862                 .free = LDKOffersMessageHandler_JCalls_free,
13863         };
13864         return ret;
13865 }
13866 uint64_t  CS_LDK_LDKOffersMessageHandler_new(int32_t o) {
13867         LDKOffersMessageHandler *res_ptr = MALLOC(sizeof(LDKOffersMessageHandler), "LDKOffersMessageHandler");
13868         *res_ptr = LDKOffersMessageHandler_init(o);
13869         return tag_ptr(res_ptr, true);
13870 }
13871 int64_t  CS_LDK_OffersMessageHandler_handle_message(int64_t this_arg, int64_t message) {
13872         void* this_arg_ptr = untag_ptr(this_arg);
13873         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13874         LDKOffersMessageHandler* this_arg_conv = (LDKOffersMessageHandler*)this_arg_ptr;
13875         void* message_ptr = untag_ptr(message);
13876         CHECK_ACCESS(message_ptr);
13877         LDKOffersMessage message_conv = *(LDKOffersMessage*)(message_ptr);
13878         message_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(message));
13879         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
13880         *ret_copy = (this_arg_conv->handle_message)(this_arg_conv->this_arg, message_conv);
13881         int64_t ret_ref = tag_ptr(ret_copy, true);
13882         return ret_ref;
13883 }
13884
13885 int64_tArray  CS_LDK_OffersMessageHandler_release_pending_messages(int64_t this_arg) {
13886         void* this_arg_ptr = untag_ptr(this_arg);
13887         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13888         LDKOffersMessageHandler* this_arg_conv = (LDKOffersMessageHandler*)this_arg_ptr;
13889         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ ret_var = (this_arg_conv->release_pending_messages)(this_arg_conv->this_arg);
13890         int64_tArray ret_arr = NULL;
13891         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
13892         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
13893         for (size_t x = 0; x < ret_var.datalen; x++) {
13894                 LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
13895                 *ret_conv_49_conv = ret_var.data[x];
13896                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
13897         }
13898         
13899         FREE(ret_var.data);
13900         return ret_arr;
13901 }
13902
13903 typedef struct LDKRoutingMessageHandler_JCalls {
13904         atomic_size_t refcnt;
13905         uint32_t instance_ptr;
13906         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
13907 } LDKRoutingMessageHandler_JCalls;
13908 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
13909         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13910         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13911                 FREE(j_calls);
13912         }
13913 }
13914 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
13915         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13916         LDKNodeAnnouncement msg_var = *msg;
13917         int64_t msg_ref = 0;
13918         msg_var = NodeAnnouncement_clone(&msg_var);
13919         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13920         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13921         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 109, msg_ref);
13922         void* ret_ptr = untag_ptr(ret);
13923         CHECK_ACCESS(ret_ptr);
13924         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13925         FREE(untag_ptr(ret));
13926         return ret_conv;
13927 }
13928 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
13929         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13930         LDKChannelAnnouncement msg_var = *msg;
13931         int64_t msg_ref = 0;
13932         msg_var = ChannelAnnouncement_clone(&msg_var);
13933         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13934         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13935         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 110, msg_ref);
13936         void* ret_ptr = untag_ptr(ret);
13937         CHECK_ACCESS(ret_ptr);
13938         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13939         FREE(untag_ptr(ret));
13940         return ret_conv;
13941 }
13942 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13943         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13944         LDKChannelUpdate msg_var = *msg;
13945         int64_t msg_ref = 0;
13946         msg_var = ChannelUpdate_clone(&msg_var);
13947         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13948         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13949         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 111, msg_ref);
13950         void* ret_ptr = untag_ptr(ret);
13951         CHECK_ACCESS(ret_ptr);
13952         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13953         FREE(untag_ptr(ret));
13954         return ret_conv;
13955 }
13956 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
13957         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13958         int64_t starting_point_conv = starting_point;
13959         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 112, starting_point_conv);
13960         void* ret_ptr = untag_ptr(ret);
13961         CHECK_ACCESS(ret_ptr);
13962         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
13963         FREE(untag_ptr(ret));
13964         return ret_conv;
13965 }
13966 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKNodeId starting_point) {
13967         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13968         LDKNodeId starting_point_var = starting_point;
13969         int64_t starting_point_ref = 0;
13970         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_var);
13971         starting_point_ref = tag_ptr(starting_point_var.inner, starting_point_var.is_owned);
13972         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 113, starting_point_ref);
13973         LDKNodeAnnouncement ret_conv;
13974         ret_conv.inner = untag_ptr(ret);
13975         ret_conv.is_owned = ptr_is_owned(ret);
13976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13977         return ret_conv;
13978 }
13979 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
13980         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13981         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13982         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
13983         LDKInit init_var = *init;
13984         int64_t init_ref = 0;
13985         init_var = Init_clone(&init_var);
13986         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13987         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13988         jboolean inbound_conv = inbound;
13989         uint64_t ret = js_invoke_function_l_llb(j_calls->instance_ptr, 114, (int64_t)their_node_id_arr, init_ref, inbound_conv);
13990         void* ret_ptr = untag_ptr(ret);
13991         CHECK_ACCESS(ret_ptr);
13992         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13993         FREE(untag_ptr(ret));
13994         return ret_conv;
13995 }
13996 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13997         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13998         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
13999         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14000         LDKReplyChannelRange msg_var = msg;
14001         int64_t msg_ref = 0;
14002         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14003         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14004         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 115, (int64_t)their_node_id_arr, msg_ref);
14005         void* ret_ptr = untag_ptr(ret);
14006         CHECK_ACCESS(ret_ptr);
14007         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14008         FREE(untag_ptr(ret));
14009         return ret_conv;
14010 }
14011 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
14012         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14013         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14014         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14015         LDKReplyShortChannelIdsEnd msg_var = msg;
14016         int64_t msg_ref = 0;
14017         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14018         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14019         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 116, (int64_t)their_node_id_arr, msg_ref);
14020         void* ret_ptr = untag_ptr(ret);
14021         CHECK_ACCESS(ret_ptr);
14022         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14023         FREE(untag_ptr(ret));
14024         return ret_conv;
14025 }
14026 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
14027         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14028         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14029         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14030         LDKQueryChannelRange msg_var = msg;
14031         int64_t msg_ref = 0;
14032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14033         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14034         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 117, (int64_t)their_node_id_arr, msg_ref);
14035         void* ret_ptr = untag_ptr(ret);
14036         CHECK_ACCESS(ret_ptr);
14037         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14038         FREE(untag_ptr(ret));
14039         return ret_conv;
14040 }
14041 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
14042         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14043         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14044         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14045         LDKQueryShortChannelIds msg_var = msg;
14046         int64_t msg_ref = 0;
14047         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14048         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14049         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 118, (int64_t)their_node_id_arr, msg_ref);
14050         void* ret_ptr = untag_ptr(ret);
14051         CHECK_ACCESS(ret_ptr);
14052         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14053         FREE(untag_ptr(ret));
14054         return ret_conv;
14055 }
14056 bool processing_queue_high_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14057         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14058         return js_invoke_function_b_(j_calls->instance_ptr, 119);
14059 }
14060 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
14061         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14062         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 120);
14063         LDKNodeFeatures ret_conv;
14064         ret_conv.inner = untag_ptr(ret);
14065         ret_conv.is_owned = ptr_is_owned(ret);
14066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14067         return ret_conv;
14068 }
14069 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14070         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
14071         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14072         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14073         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 121, (int64_t)their_node_id_arr);
14074         LDKInitFeatures ret_conv;
14075         ret_conv.inner = untag_ptr(ret);
14076         ret_conv.is_owned = ptr_is_owned(ret);
14077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14078         return ret_conv;
14079 }
14080 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
14081         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
14082         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14083         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
14084 }
14085 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (int64_t o, int64_t MessageSendEventsProvider) {
14086         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
14087         atomic_init(&calls->refcnt, 1);
14088         calls->instance_ptr = o;
14089
14090         LDKRoutingMessageHandler ret = {
14091                 .this_arg = (void*) calls,
14092                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
14093                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
14094                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
14095                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
14096                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
14097                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
14098                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
14099                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
14100                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
14101                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
14102                 .processing_queue_high = processing_queue_high_LDKRoutingMessageHandler_jcall,
14103                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
14104                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
14105                 .free = LDKRoutingMessageHandler_JCalls_free,
14106                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
14107         };
14108         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
14109         return ret;
14110 }
14111 uint64_t  CS_LDK_LDKRoutingMessageHandler_new(int32_t o, int32_t MessageSendEventsProvider) {
14112         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14113         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
14114         return tag_ptr(res_ptr, true);
14115 }
14116 int64_t  CS_LDK_RoutingMessageHandler_handle_node_announcement(int64_t this_arg, int64_t msg) {
14117         void* this_arg_ptr = untag_ptr(this_arg);
14118         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14119         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14120         LDKNodeAnnouncement msg_conv;
14121         msg_conv.inner = untag_ptr(msg);
14122         msg_conv.is_owned = ptr_is_owned(msg);
14123         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14124         msg_conv.is_owned = false;
14125         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14126         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
14127         return tag_ptr(ret_conv, true);
14128 }
14129
14130 int64_t  CS_LDK_RoutingMessageHandler_handle_channel_announcement(int64_t this_arg, int64_t msg) {
14131         void* this_arg_ptr = untag_ptr(this_arg);
14132         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14133         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14134         LDKChannelAnnouncement msg_conv;
14135         msg_conv.inner = untag_ptr(msg);
14136         msg_conv.is_owned = ptr_is_owned(msg);
14137         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14138         msg_conv.is_owned = false;
14139         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14140         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
14141         return tag_ptr(ret_conv, true);
14142 }
14143
14144 int64_t  CS_LDK_RoutingMessageHandler_handle_channel_update(int64_t this_arg, int64_t msg) {
14145         void* this_arg_ptr = untag_ptr(this_arg);
14146         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14147         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14148         LDKChannelUpdate msg_conv;
14149         msg_conv.inner = untag_ptr(msg);
14150         msg_conv.is_owned = ptr_is_owned(msg);
14151         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14152         msg_conv.is_owned = false;
14153         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
14154         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
14155         return tag_ptr(ret_conv, true);
14156 }
14157
14158 int64_t  CS_LDK_RoutingMessageHandler_get_next_channel_announcement(int64_t this_arg, int64_t starting_point) {
14159         void* this_arg_ptr = untag_ptr(this_arg);
14160         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14161         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14162         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
14163         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
14164         int64_t ret_ref = tag_ptr(ret_copy, true);
14165         return ret_ref;
14166 }
14167
14168 int64_t  CS_LDK_RoutingMessageHandler_get_next_node_announcement(int64_t this_arg, int64_t starting_point) {
14169         void* this_arg_ptr = untag_ptr(this_arg);
14170         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14171         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14172         LDKNodeId starting_point_conv;
14173         starting_point_conv.inner = untag_ptr(starting_point);
14174         starting_point_conv.is_owned = ptr_is_owned(starting_point);
14175         CHECK_INNER_FIELD_ACCESS_OR_NULL(starting_point_conv);
14176         starting_point_conv = NodeId_clone(&starting_point_conv);
14177         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_conv);
14178         int64_t ret_ref = 0;
14179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14181         return ret_ref;
14182 }
14183
14184 int64_t  CS_LDK_RoutingMessageHandler_peer_connected(int64_t this_arg, int8_tArray their_node_id, int64_t init, jboolean inbound) {
14185         void* this_arg_ptr = untag_ptr(this_arg);
14186         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14187         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14188         LDKPublicKey their_node_id_ref;
14189         CHECK(their_node_id->arr_len == 33);
14190         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14191         LDKInit init_conv;
14192         init_conv.inner = untag_ptr(init);
14193         init_conv.is_owned = ptr_is_owned(init);
14194         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14195         init_conv.is_owned = false;
14196         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14197         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14198         return tag_ptr(ret_conv, true);
14199 }
14200
14201 int64_t  CS_LDK_RoutingMessageHandler_handle_reply_channel_range(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14202         void* this_arg_ptr = untag_ptr(this_arg);
14203         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14204         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14205         LDKPublicKey their_node_id_ref;
14206         CHECK(their_node_id->arr_len == 33);
14207         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14208         LDKReplyChannelRange msg_conv;
14209         msg_conv.inner = untag_ptr(msg);
14210         msg_conv.is_owned = ptr_is_owned(msg);
14211         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14212         msg_conv = ReplyChannelRange_clone(&msg_conv);
14213         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14214         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14215         return tag_ptr(ret_conv, true);
14216 }
14217
14218 int64_t  CS_LDK_RoutingMessageHandler_handle_reply_short_channel_ids_end(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14219         void* this_arg_ptr = untag_ptr(this_arg);
14220         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14221         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14222         LDKPublicKey their_node_id_ref;
14223         CHECK(their_node_id->arr_len == 33);
14224         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14225         LDKReplyShortChannelIdsEnd msg_conv;
14226         msg_conv.inner = untag_ptr(msg);
14227         msg_conv.is_owned = ptr_is_owned(msg);
14228         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14229         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
14230         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14231         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14232         return tag_ptr(ret_conv, true);
14233 }
14234
14235 int64_t  CS_LDK_RoutingMessageHandler_handle_query_channel_range(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14236         void* this_arg_ptr = untag_ptr(this_arg);
14237         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14238         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14239         LDKPublicKey their_node_id_ref;
14240         CHECK(their_node_id->arr_len == 33);
14241         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14242         LDKQueryChannelRange msg_conv;
14243         msg_conv.inner = untag_ptr(msg);
14244         msg_conv.is_owned = ptr_is_owned(msg);
14245         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14246         msg_conv = QueryChannelRange_clone(&msg_conv);
14247         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14248         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14249         return tag_ptr(ret_conv, true);
14250 }
14251
14252 int64_t  CS_LDK_RoutingMessageHandler_handle_query_short_channel_ids(int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
14253         void* this_arg_ptr = untag_ptr(this_arg);
14254         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14255         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14256         LDKPublicKey their_node_id_ref;
14257         CHECK(their_node_id->arr_len == 33);
14258         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14259         LDKQueryShortChannelIds msg_conv;
14260         msg_conv.inner = untag_ptr(msg);
14261         msg_conv.is_owned = ptr_is_owned(msg);
14262         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14263         msg_conv = QueryShortChannelIds_clone(&msg_conv);
14264         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14265         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
14266         return tag_ptr(ret_conv, true);
14267 }
14268
14269 jboolean  CS_LDK_RoutingMessageHandler_processing_queue_high(int64_t this_arg) {
14270         void* this_arg_ptr = untag_ptr(this_arg);
14271         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14272         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14273         jboolean ret_conv = (this_arg_conv->processing_queue_high)(this_arg_conv->this_arg);
14274         return ret_conv;
14275 }
14276
14277 int64_t  CS_LDK_RoutingMessageHandler_provided_node_features(int64_t this_arg) {
14278         void* this_arg_ptr = untag_ptr(this_arg);
14279         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14280         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14281         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14282         int64_t ret_ref = 0;
14283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14285         return ret_ref;
14286 }
14287
14288 int64_t  CS_LDK_RoutingMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
14289         void* this_arg_ptr = untag_ptr(this_arg);
14290         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14291         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
14292         LDKPublicKey their_node_id_ref;
14293         CHECK(their_node_id->arr_len == 33);
14294         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14295         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14296         int64_t ret_ref = 0;
14297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14299         return ret_ref;
14300 }
14301
14302 typedef struct LDKOnionMessageHandler_JCalls {
14303         atomic_size_t refcnt;
14304         uint32_t instance_ptr;
14305 } LDKOnionMessageHandler_JCalls;
14306 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
14307         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14308         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14309                 FREE(j_calls);
14310         }
14311 }
14312 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
14313         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14314         int8_tArray peer_node_id_arr = init_int8_tArray(33, __LINE__);
14315         memcpy(peer_node_id_arr->elems, peer_node_id.compressed_form, 33);
14316         LDKOnionMessage msg_var = *msg;
14317         int64_t msg_ref = 0;
14318         msg_var = OnionMessage_clone(&msg_var);
14319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
14320         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
14321         js_invoke_function_void_ll(j_calls->instance_ptr, 122, (int64_t)peer_node_id_arr, msg_ref);
14322 }
14323 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
14324         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14325         int8_tArray peer_node_id_arr = init_int8_tArray(33, __LINE__);
14326         memcpy(peer_node_id_arr->elems, peer_node_id.compressed_form, 33);
14327         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 123, (int64_t)peer_node_id_arr);
14328         LDKOnionMessage ret_conv;
14329         ret_conv.inner = untag_ptr(ret);
14330         ret_conv.is_owned = ptr_is_owned(ret);
14331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14332         return ret_conv;
14333 }
14334 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init, bool inbound) {
14335         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14336         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14337         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14338         LDKInit init_var = *init;
14339         int64_t init_ref = 0;
14340         init_var = Init_clone(&init_var);
14341         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
14342         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
14343         jboolean inbound_conv = inbound;
14344         uint64_t ret = js_invoke_function_l_llb(j_calls->instance_ptr, 124, (int64_t)their_node_id_arr, init_ref, inbound_conv);
14345         void* ret_ptr = untag_ptr(ret);
14346         CHECK_ACCESS(ret_ptr);
14347         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
14348         FREE(untag_ptr(ret));
14349         return ret_conv;
14350 }
14351 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14352         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14353         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14354         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14355         js_invoke_function_void_l(j_calls->instance_ptr, 125, (int64_t)their_node_id_arr);
14356 }
14357 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
14358         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14359         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 126);
14360         LDKNodeFeatures ret_conv;
14361         ret_conv.inner = untag_ptr(ret);
14362         ret_conv.is_owned = ptr_is_owned(ret);
14363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14364         return ret_conv;
14365 }
14366 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14367         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
14368         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14369         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14370         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 127, (int64_t)their_node_id_arr);
14371         LDKInitFeatures ret_conv;
14372         ret_conv.inner = untag_ptr(ret);
14373         ret_conv.is_owned = ptr_is_owned(ret);
14374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14375         return ret_conv;
14376 }
14377 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
14378         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
14379         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14380 }
14381 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (int64_t o) {
14382         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
14383         atomic_init(&calls->refcnt, 1);
14384         calls->instance_ptr = o;
14385
14386         LDKOnionMessageHandler ret = {
14387                 .this_arg = (void*) calls,
14388                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
14389                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageHandler_jcall,
14390                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
14391                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
14392                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
14393                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
14394                 .free = LDKOnionMessageHandler_JCalls_free,
14395         };
14396         return ret;
14397 }
14398 uint64_t  CS_LDK_LDKOnionMessageHandler_new(int32_t o) {
14399         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
14400         *res_ptr = LDKOnionMessageHandler_init(o);
14401         return tag_ptr(res_ptr, true);
14402 }
14403 void  CS_LDK_OnionMessageHandler_handle_onion_message(int64_t this_arg, int8_tArray peer_node_id, int64_t msg) {
14404         void* this_arg_ptr = untag_ptr(this_arg);
14405         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14406         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14407         LDKPublicKey peer_node_id_ref;
14408         CHECK(peer_node_id->arr_len == 33);
14409         memcpy(peer_node_id_ref.compressed_form, peer_node_id->elems, 33); FREE(peer_node_id);
14410         LDKOnionMessage msg_conv;
14411         msg_conv.inner = untag_ptr(msg);
14412         msg_conv.is_owned = ptr_is_owned(msg);
14413         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14414         msg_conv.is_owned = false;
14415         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
14416 }
14417
14418 int64_t  CS_LDK_OnionMessageHandler_next_onion_message_for_peer(int64_t this_arg, int8_tArray peer_node_id) {
14419         void* this_arg_ptr = untag_ptr(this_arg);
14420         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14421         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14422         LDKPublicKey peer_node_id_ref;
14423         CHECK(peer_node_id->arr_len == 33);
14424         memcpy(peer_node_id_ref.compressed_form, peer_node_id->elems, 33); FREE(peer_node_id);
14425         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
14426         int64_t ret_ref = 0;
14427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14428         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14429         return ret_ref;
14430 }
14431
14432 int64_t  CS_LDK_OnionMessageHandler_peer_connected(int64_t this_arg, int8_tArray their_node_id, int64_t init, jboolean inbound) {
14433         void* this_arg_ptr = untag_ptr(this_arg);
14434         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14435         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14436         LDKPublicKey their_node_id_ref;
14437         CHECK(their_node_id->arr_len == 33);
14438         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14439         LDKInit init_conv;
14440         init_conv.inner = untag_ptr(init);
14441         init_conv.is_owned = ptr_is_owned(init);
14442         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14443         init_conv.is_owned = false;
14444         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14445         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv, inbound);
14446         return tag_ptr(ret_conv, true);
14447 }
14448
14449 void  CS_LDK_OnionMessageHandler_peer_disconnected(int64_t this_arg, int8_tArray their_node_id) {
14450         void* this_arg_ptr = untag_ptr(this_arg);
14451         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14452         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14453         LDKPublicKey their_node_id_ref;
14454         CHECK(their_node_id->arr_len == 33);
14455         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14456         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref);
14457 }
14458
14459 int64_t  CS_LDK_OnionMessageHandler_provided_node_features(int64_t this_arg) {
14460         void* this_arg_ptr = untag_ptr(this_arg);
14461         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14462         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14463         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14464         int64_t ret_ref = 0;
14465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14466         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14467         return ret_ref;
14468 }
14469
14470 int64_t  CS_LDK_OnionMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
14471         void* this_arg_ptr = untag_ptr(this_arg);
14472         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14473         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14474         LDKPublicKey their_node_id_ref;
14475         CHECK(their_node_id->arr_len == 33);
14476         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14477         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14478         int64_t ret_ref = 0;
14479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14481         return ret_ref;
14482 }
14483
14484 typedef struct LDKCustomMessageReader_JCalls {
14485         atomic_size_t refcnt;
14486         uint32_t instance_ptr;
14487 } LDKCustomMessageReader_JCalls;
14488 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
14489         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14490         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14491                 FREE(j_calls);
14492         }
14493 }
14494 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
14495         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14496         int16_t message_type_conv = message_type;
14497         LDKu8slice buffer_var = buffer;
14498         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
14499         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
14500         uint64_t ret = js_invoke_function_l_sl(j_calls->instance_ptr, 128, message_type_conv, (int64_t)buffer_arr);
14501         void* ret_ptr = untag_ptr(ret);
14502         CHECK_ACCESS(ret_ptr);
14503         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
14504         FREE(untag_ptr(ret));
14505         return ret_conv;
14506 }
14507 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
14508         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
14509         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14510 }
14511 static inline LDKCustomMessageReader LDKCustomMessageReader_init (int64_t o) {
14512         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
14513         atomic_init(&calls->refcnt, 1);
14514         calls->instance_ptr = o;
14515
14516         LDKCustomMessageReader ret = {
14517                 .this_arg = (void*) calls,
14518                 .read = read_LDKCustomMessageReader_jcall,
14519                 .free = LDKCustomMessageReader_JCalls_free,
14520         };
14521         return ret;
14522 }
14523 uint64_t  CS_LDK_LDKCustomMessageReader_new(int32_t o) {
14524         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
14525         *res_ptr = LDKCustomMessageReader_init(o);
14526         return tag_ptr(res_ptr, true);
14527 }
14528 int64_t  CS_LDK_CustomMessageReader_read(int64_t this_arg, int16_t message_type, int8_tArray buffer) {
14529         void* this_arg_ptr = untag_ptr(this_arg);
14530         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14531         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
14532         LDKu8slice buffer_ref;
14533         buffer_ref.datalen = buffer->arr_len;
14534         buffer_ref.data = buffer->elems;
14535         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14536         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
14537         FREE(buffer);
14538         return tag_ptr(ret_conv, true);
14539 }
14540
14541 typedef struct LDKCustomMessageHandler_JCalls {
14542         atomic_size_t refcnt;
14543         uint32_t instance_ptr;
14544         LDKCustomMessageReader_JCalls* CustomMessageReader;
14545 } LDKCustomMessageHandler_JCalls;
14546 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
14547         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14548         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14549                 FREE(j_calls);
14550         }
14551 }
14552 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
14553         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14554         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
14555         *msg_ret = msg;
14556         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
14557         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
14558         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 129, tag_ptr(msg_ret, true), (int64_t)sender_node_id_arr);
14559         void* ret_ptr = untag_ptr(ret);
14560         CHECK_ACCESS(ret_ptr);
14561         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14562         FREE(untag_ptr(ret));
14563         return ret_conv;
14564 }
14565 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
14566         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14567         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 130);
14568         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
14569         ret_constr.datalen = ret->arr_len;
14570         if (ret_constr.datalen > 0)
14571                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
14572         else
14573                 ret_constr.data = NULL;
14574         int64_t* ret_vals = ret->elems;
14575         for (size_t z = 0; z < ret_constr.datalen; z++) {
14576                 int64_t ret_conv_25 = ret_vals[z];
14577                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
14578                 CHECK_ACCESS(ret_conv_25_ptr);
14579                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
14580                 FREE(untag_ptr(ret_conv_25));
14581                 ret_constr.data[z] = ret_conv_25_conv;
14582         }
14583         FREE(ret);
14584         return ret_constr;
14585 }
14586 LDKNodeFeatures provided_node_features_LDKCustomMessageHandler_jcall(const void* this_arg) {
14587         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14588         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 131);
14589         LDKNodeFeatures ret_conv;
14590         ret_conv.inner = untag_ptr(ret);
14591         ret_conv.is_owned = ptr_is_owned(ret);
14592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14593         return ret_conv;
14594 }
14595 LDKInitFeatures provided_init_features_LDKCustomMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
14596         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14597         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
14598         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
14599         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 132, (int64_t)their_node_id_arr);
14600         LDKInitFeatures ret_conv;
14601         ret_conv.inner = untag_ptr(ret);
14602         ret_conv.is_owned = ptr_is_owned(ret);
14603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
14604         return ret_conv;
14605 }
14606 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
14607         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
14608         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14609         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
14610 }
14611 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (int64_t o, int64_t CustomMessageReader) {
14612         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
14613         atomic_init(&calls->refcnt, 1);
14614         calls->instance_ptr = o;
14615
14616         LDKCustomMessageHandler ret = {
14617                 .this_arg = (void*) calls,
14618                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
14619                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
14620                 .provided_node_features = provided_node_features_LDKCustomMessageHandler_jcall,
14621                 .provided_init_features = provided_init_features_LDKCustomMessageHandler_jcall,
14622                 .free = LDKCustomMessageHandler_JCalls_free,
14623                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
14624         };
14625         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
14626         return ret;
14627 }
14628 uint64_t  CS_LDK_LDKCustomMessageHandler_new(int32_t o, int32_t CustomMessageReader) {
14629         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
14630         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
14631         return tag_ptr(res_ptr, true);
14632 }
14633 int64_t  CS_LDK_CustomMessageHandler_handle_custom_message(int64_t this_arg, int64_t msg, int8_tArray sender_node_id) {
14634         void* this_arg_ptr = untag_ptr(this_arg);
14635         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14636         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14637         void* msg_ptr = untag_ptr(msg);
14638         CHECK_ACCESS(msg_ptr);
14639         LDKType msg_conv = *(LDKType*)(msg_ptr);
14640         if (msg_conv.free == LDKType_JCalls_free) {
14641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14642                 LDKType_JCalls_cloned(&msg_conv);
14643         }
14644         LDKPublicKey sender_node_id_ref;
14645         CHECK(sender_node_id->arr_len == 33);
14646         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
14647         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14648         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
14649         return tag_ptr(ret_conv, true);
14650 }
14651
14652 int64_tArray  CS_LDK_CustomMessageHandler_get_and_clear_pending_msg(int64_t this_arg) {
14653         void* this_arg_ptr = untag_ptr(this_arg);
14654         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14655         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14656         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
14657         int64_tArray ret_arr = NULL;
14658         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
14659         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
14660         for (size_t z = 0; z < ret_var.datalen; z++) {
14661                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
14662                 *ret_conv_25_conv = ret_var.data[z];
14663                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
14664         }
14665         
14666         FREE(ret_var.data);
14667         return ret_arr;
14668 }
14669
14670 int64_t  CS_LDK_CustomMessageHandler_provided_node_features(int64_t this_arg) {
14671         void* this_arg_ptr = untag_ptr(this_arg);
14672         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14673         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14674         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14675         int64_t ret_ref = 0;
14676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14678         return ret_ref;
14679 }
14680
14681 int64_t  CS_LDK_CustomMessageHandler_provided_init_features(int64_t this_arg, int8_tArray their_node_id) {
14682         void* this_arg_ptr = untag_ptr(this_arg);
14683         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14684         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14685         LDKPublicKey their_node_id_ref;
14686         CHECK(their_node_id->arr_len == 33);
14687         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
14688         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14689         int64_t ret_ref = 0;
14690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14692         return ret_ref;
14693 }
14694
14695 typedef struct LDKCustomOnionMessageHandler_JCalls {
14696         atomic_size_t refcnt;
14697         uint32_t instance_ptr;
14698 } LDKCustomOnionMessageHandler_JCalls;
14699 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
14700         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14701         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14702                 FREE(j_calls);
14703         }
14704 }
14705 LDKCOption_OnionMessageContentsZ handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKOnionMessageContents msg) {
14706         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14707         LDKOnionMessageContents* msg_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
14708         *msg_ret = msg;
14709         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 133, tag_ptr(msg_ret, true));
14710         void* ret_ptr = untag_ptr(ret);
14711         CHECK_ACCESS(ret_ptr);
14712         LDKCOption_OnionMessageContentsZ ret_conv = *(LDKCOption_OnionMessageContentsZ*)(ret_ptr);
14713         FREE(untag_ptr(ret));
14714         return ret_conv;
14715 }
14716 LDKCResult_COption_OnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
14717         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14718         int64_t message_type_conv = message_type;
14719         LDKu8slice buffer_var = buffer;
14720         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
14721         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
14722         uint64_t ret = js_invoke_function_l_ll(j_calls->instance_ptr, 134, message_type_conv, (int64_t)buffer_arr);
14723         void* ret_ptr = untag_ptr(ret);
14724         CHECK_ACCESS(ret_ptr);
14725         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)(ret_ptr);
14726         FREE(untag_ptr(ret));
14727         return ret_conv;
14728 }
14729 LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ release_pending_custom_messages_LDKCustomOnionMessageHandler_jcall(const void* this_arg) {
14730         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14731         int64_tArray ret = (int64_tArray)js_invoke_function_l_(j_calls->instance_ptr, 135);
14732         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret_constr;
14733         ret_constr.datalen = ret->arr_len;
14734         if (ret_constr.datalen > 0)
14735                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ Elements");
14736         else
14737                 ret_constr.data = NULL;
14738         int64_t* ret_vals = ret->elems;
14739         for (size_t e = 0; e < ret_constr.datalen; e++) {
14740                 int64_t ret_conv_56 = ret_vals[e];
14741                 void* ret_conv_56_ptr = untag_ptr(ret_conv_56);
14742                 CHECK_ACCESS(ret_conv_56_ptr);
14743                 LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ ret_conv_56_conv = *(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)(ret_conv_56_ptr);
14744                 FREE(untag_ptr(ret_conv_56));
14745                 ret_constr.data[e] = ret_conv_56_conv;
14746         }
14747         FREE(ret);
14748         return ret_constr;
14749 }
14750 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
14751         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
14752         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14753 }
14754 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (int64_t o) {
14755         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
14756         atomic_init(&calls->refcnt, 1);
14757         calls->instance_ptr = o;
14758
14759         LDKCustomOnionMessageHandler ret = {
14760                 .this_arg = (void*) calls,
14761                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
14762                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
14763                 .release_pending_custom_messages = release_pending_custom_messages_LDKCustomOnionMessageHandler_jcall,
14764                 .free = LDKCustomOnionMessageHandler_JCalls_free,
14765         };
14766         return ret;
14767 }
14768 uint64_t  CS_LDK_LDKCustomOnionMessageHandler_new(int32_t o) {
14769         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
14770         *res_ptr = LDKCustomOnionMessageHandler_init(o);
14771         return tag_ptr(res_ptr, true);
14772 }
14773 int64_t  CS_LDK_CustomOnionMessageHandler_handle_custom_message(int64_t this_arg, int64_t msg) {
14774         void* this_arg_ptr = untag_ptr(this_arg);
14775         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14776         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14777         void* msg_ptr = untag_ptr(msg);
14778         CHECK_ACCESS(msg_ptr);
14779         LDKOnionMessageContents msg_conv = *(LDKOnionMessageContents*)(msg_ptr);
14780         if (msg_conv.free == LDKOnionMessageContents_JCalls_free) {
14781                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14782                 LDKOnionMessageContents_JCalls_cloned(&msg_conv);
14783         }
14784         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
14785         *ret_copy = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
14786         int64_t ret_ref = tag_ptr(ret_copy, true);
14787         return ret_ref;
14788 }
14789
14790 int64_t  CS_LDK_CustomOnionMessageHandler_read_custom_message(int64_t this_arg, int64_t message_type, int8_tArray buffer) {
14791         void* this_arg_ptr = untag_ptr(this_arg);
14792         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14793         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14794         LDKu8slice buffer_ref;
14795         buffer_ref.datalen = buffer->arr_len;
14796         buffer_ref.data = buffer->elems;
14797         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
14798         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
14799         FREE(buffer);
14800         return tag_ptr(ret_conv, true);
14801 }
14802
14803 int64_tArray  CS_LDK_CustomOnionMessageHandler_release_pending_custom_messages(int64_t this_arg) {
14804         void* this_arg_ptr = untag_ptr(this_arg);
14805         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14806         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14807         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ ret_var = (this_arg_conv->release_pending_custom_messages)(this_arg_conv->this_arg);
14808         int64_tArray ret_arr = NULL;
14809         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
14810         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
14811         for (size_t e = 0; e < ret_var.datalen; e++) {
14812                 LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv_56_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
14813                 *ret_conv_56_conv = ret_var.data[e];
14814                 ret_arr_ptr[e] = tag_ptr(ret_conv_56_conv, true);
14815         }
14816         
14817         FREE(ret_var.data);
14818         return ret_arr;
14819 }
14820
14821 typedef struct LDKSocketDescriptor_JCalls {
14822         atomic_size_t refcnt;
14823         uint32_t instance_ptr;
14824 } LDKSocketDescriptor_JCalls;
14825 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
14826         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14827         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14828                 FREE(j_calls);
14829         }
14830 }
14831 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
14832         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14833         LDKu8slice data_var = data;
14834         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
14835         memcpy(data_arr->elems, data_var.data, data_var.datalen);
14836         jboolean resume_read_conv = resume_read;
14837         return js_invoke_function_l_lb(j_calls->instance_ptr, 136, (int64_t)data_arr, resume_read_conv);
14838 }
14839 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
14840         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14841         js_invoke_function_void_(j_calls->instance_ptr, 137);
14842 }
14843 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
14844         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14845         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14846         *other_arg_clone = SocketDescriptor_clone(other_arg);
14847         return js_invoke_function_b_l(j_calls->instance_ptr, 138, tag_ptr(other_arg_clone, true));
14848 }
14849 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
14850         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14851         return js_invoke_function_l_(j_calls->instance_ptr, 139);
14852 }
14853 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
14854         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
14855         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14856 }
14857 static inline LDKSocketDescriptor LDKSocketDescriptor_init (int64_t o) {
14858         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
14859         atomic_init(&calls->refcnt, 1);
14860         calls->instance_ptr = o;
14861
14862         LDKSocketDescriptor ret = {
14863                 .this_arg = (void*) calls,
14864                 .send_data = send_data_LDKSocketDescriptor_jcall,
14865                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
14866                 .eq = eq_LDKSocketDescriptor_jcall,
14867                 .hash = hash_LDKSocketDescriptor_jcall,
14868                 .cloned = LDKSocketDescriptor_JCalls_cloned,
14869                 .free = LDKSocketDescriptor_JCalls_free,
14870         };
14871         return ret;
14872 }
14873 uint64_t  CS_LDK_LDKSocketDescriptor_new(int32_t o) {
14874         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14875         *res_ptr = LDKSocketDescriptor_init(o);
14876         return tag_ptr(res_ptr, true);
14877 }
14878 int64_t  CS_LDK_SocketDescriptor_send_data(int64_t this_arg, int8_tArray data, jboolean resume_read) {
14879         void* this_arg_ptr = untag_ptr(this_arg);
14880         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14881         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14882         LDKu8slice data_ref;
14883         data_ref.datalen = data->arr_len;
14884         data_ref.data = data->elems;
14885         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14886         FREE(data);
14887         return ret_conv;
14888 }
14889
14890 void  CS_LDK_SocketDescriptor_disconnect_socket(int64_t this_arg) {
14891         void* this_arg_ptr = untag_ptr(this_arg);
14892         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14893         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14894         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14895 }
14896
14897 int64_t  CS_LDK_SocketDescriptor_hash(int64_t this_arg) {
14898         void* this_arg_ptr = untag_ptr(this_arg);
14899         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14900         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14901         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14902         return ret_conv;
14903 }
14904
14905 uint32_t CS_LDK_LDKEffectiveCapacity_ty_from_ptr(int64_t ptr) {
14906         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14907         switch(obj->tag) {
14908                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
14909                 case LDKEffectiveCapacity_AdvertisedMaxHTLC: return 1;
14910                 case LDKEffectiveCapacity_Total: return 2;
14911                 case LDKEffectiveCapacity_Infinite: return 3;
14912                 case LDKEffectiveCapacity_HintMaxHTLC: return 4;
14913                 case LDKEffectiveCapacity_Unknown: return 5;
14914                 default: abort();
14915         }
14916 }
14917 int64_t CS_LDK_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(int64_t ptr) {
14918         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14919         CHECK(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
14920         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14921         return liquidity_msat_conv;
14922 }
14923 int64_t CS_LDK_LDKEffectiveCapacity_AdvertisedMaxHTLC_get_amount_msat(int64_t ptr) {
14924         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14925         CHECK(obj->tag == LDKEffectiveCapacity_AdvertisedMaxHTLC);
14926         int64_t amount_msat_conv = obj->advertised_max_htlc.amount_msat;
14927         return amount_msat_conv;
14928 }
14929 int64_t CS_LDK_LDKEffectiveCapacity_Total_get_capacity_msat(int64_t ptr) {
14930         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14931         CHECK(obj->tag == LDKEffectiveCapacity_Total);
14932         int64_t capacity_msat_conv = obj->total.capacity_msat;
14933         return capacity_msat_conv;
14934 }
14935 int64_t CS_LDK_LDKEffectiveCapacity_Total_get_htlc_maximum_msat(int64_t ptr) {
14936         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14937         CHECK(obj->tag == LDKEffectiveCapacity_Total);
14938         int64_t htlc_maximum_msat_conv = obj->total.htlc_maximum_msat;
14939         return htlc_maximum_msat_conv;
14940 }
14941 int64_t CS_LDK_LDKEffectiveCapacity_HintMaxHTLC_get_amount_msat(int64_t ptr) {
14942         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14943         CHECK(obj->tag == LDKEffectiveCapacity_HintMaxHTLC);
14944         int64_t amount_msat_conv = obj->hint_max_htlc.amount_msat;
14945         return amount_msat_conv;
14946 }
14947 uint32_t CS_LDK_LDKPayee_ty_from_ptr(int64_t ptr) {
14948         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14949         switch(obj->tag) {
14950                 case LDKPayee_Blinded: return 0;
14951                 case LDKPayee_Clear: return 1;
14952                 default: abort();
14953         }
14954 }
14955 int64_tArray CS_LDK_LDKPayee_Blinded_get_route_hints(int64_t ptr) {
14956         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14957         CHECK(obj->tag == LDKPayee_Blinded);
14958         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints_var = obj->blinded.route_hints;
14959                         int64_tArray route_hints_arr = NULL;
14960                         route_hints_arr = init_int64_tArray(route_hints_var.datalen, __LINE__);
14961                         int64_t *route_hints_arr_ptr = (int64_t*)(((uint8_t*)route_hints_arr) + 8);
14962                         for (size_t l = 0; l < route_hints_var.datalen; l++) {
14963                                 LDKC2Tuple_BlindedPayInfoBlindedPathZ* route_hints_conv_37_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
14964                                 *route_hints_conv_37_conv = route_hints_var.data[l];
14965                                 *route_hints_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(route_hints_conv_37_conv);
14966                                 route_hints_arr_ptr[l] = tag_ptr(route_hints_conv_37_conv, true);
14967                         }
14968                         
14969         return route_hints_arr;
14970 }
14971 int64_t CS_LDK_LDKPayee_Blinded_get_features(int64_t ptr) {
14972         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14973         CHECK(obj->tag == LDKPayee_Blinded);
14974         LDKBolt12InvoiceFeatures features_var = obj->blinded.features;
14975                         int64_t features_ref = 0;
14976                         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_var);
14977                         features_ref = tag_ptr(features_var.inner, false);
14978         return features_ref;
14979 }
14980 int8_tArray CS_LDK_LDKPayee_Clear_get_node_id(int64_t ptr) {
14981         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14982         CHECK(obj->tag == LDKPayee_Clear);
14983         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
14984         memcpy(node_id_arr->elems, obj->clear.node_id.compressed_form, 33);
14985         return node_id_arr;
14986 }
14987 int64_tArray CS_LDK_LDKPayee_Clear_get_route_hints(int64_t ptr) {
14988         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
14989         CHECK(obj->tag == LDKPayee_Clear);
14990         LDKCVec_RouteHintZ route_hints_var = obj->clear.route_hints;
14991                         int64_tArray route_hints_arr = NULL;
14992                         route_hints_arr = init_int64_tArray(route_hints_var.datalen, __LINE__);
14993                         int64_t *route_hints_arr_ptr = (int64_t*)(((uint8_t*)route_hints_arr) + 8);
14994                         for (size_t l = 0; l < route_hints_var.datalen; l++) {
14995                                 LDKRouteHint route_hints_conv_11_var = route_hints_var.data[l];
14996                                 int64_t route_hints_conv_11_ref = 0;
14997                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_conv_11_var);
14998                                 route_hints_conv_11_ref = tag_ptr(route_hints_conv_11_var.inner, false);
14999                                 route_hints_arr_ptr[l] = route_hints_conv_11_ref;
15000                         }
15001                         
15002         return route_hints_arr;
15003 }
15004 int64_t CS_LDK_LDKPayee_Clear_get_features(int64_t ptr) {
15005         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
15006         CHECK(obj->tag == LDKPayee_Clear);
15007         LDKBolt11InvoiceFeatures features_var = obj->clear.features;
15008                         int64_t features_ref = 0;
15009                         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_var);
15010                         features_ref = tag_ptr(features_var.inner, false);
15011         return features_ref;
15012 }
15013 int32_t CS_LDK_LDKPayee_Clear_get_final_cltv_expiry_delta(int64_t ptr) {
15014         LDKPayee *obj = (LDKPayee*)untag_ptr(ptr);
15015         CHECK(obj->tag == LDKPayee_Clear);
15016         int32_t final_cltv_expiry_delta_conv = obj->clear.final_cltv_expiry_delta;
15017         return final_cltv_expiry_delta_conv;
15018 }
15019 typedef struct LDKScore_JCalls {
15020         atomic_size_t refcnt;
15021         uint32_t instance_ptr;
15022         LDKScoreLookUp_JCalls* ScoreLookUp;
15023         LDKScoreUpdate_JCalls* ScoreUpdate;
15024 } LDKScore_JCalls;
15025 static void LDKScore_JCalls_free(void* this_arg) {
15026         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
15027         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15028                 FREE(j_calls);
15029         }
15030 }
15031 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
15032         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
15033         int8_tArray ret = (int8_tArray)js_invoke_function_l_(j_calls->instance_ptr, 140);
15034         LDKCVec_u8Z ret_ref;
15035         ret_ref.datalen = ret->arr_len;
15036         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
15037         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
15038         return ret_ref;
15039 }
15040 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
15041         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
15042         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15043         atomic_fetch_add_explicit(&j_calls->ScoreLookUp->refcnt, 1, memory_order_release);
15044         atomic_fetch_add_explicit(&j_calls->ScoreUpdate->refcnt, 1, memory_order_release);
15045 }
15046 static inline LDKScore LDKScore_init (int64_t o, int64_t ScoreLookUp, int64_t ScoreUpdate) {
15047         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
15048         atomic_init(&calls->refcnt, 1);
15049         calls->instance_ptr = o;
15050
15051         LDKScore ret = {
15052                 .this_arg = (void*) calls,
15053                 .write = write_LDKScore_jcall,
15054                 .free = LDKScore_JCalls_free,
15055                 .ScoreLookUp = LDKScoreLookUp_init(ScoreLookUp),
15056                 .ScoreUpdate = LDKScoreUpdate_init(ScoreUpdate),
15057         };
15058         calls->ScoreLookUp = ret.ScoreLookUp.this_arg;
15059         calls->ScoreUpdate = ret.ScoreUpdate.this_arg;
15060         return ret;
15061 }
15062 uint64_t  CS_LDK_LDKScore_new(int32_t o, int32_t ScoreLookUp, int32_t ScoreUpdate) {
15063         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
15064         *res_ptr = LDKScore_init(o, ScoreLookUp, ScoreUpdate);
15065         return tag_ptr(res_ptr, true);
15066 }
15067 int8_tArray  CS_LDK_Score_write(int64_t this_arg) {
15068         void* this_arg_ptr = untag_ptr(this_arg);
15069         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15070         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
15071         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
15072         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
15073         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
15074         CVec_u8Z_free(ret_var);
15075         return ret_arr;
15076 }
15077
15078 typedef struct LDKMessageRouter_JCalls {
15079         atomic_size_t refcnt;
15080         uint32_t instance_ptr;
15081 } LDKMessageRouter_JCalls;
15082 static void LDKMessageRouter_JCalls_free(void* this_arg) {
15083         LDKMessageRouter_JCalls *j_calls = (LDKMessageRouter_JCalls*) this_arg;
15084         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15085                 FREE(j_calls);
15086         }
15087 }
15088 LDKCResult_OnionMessagePathNoneZ find_path_LDKMessageRouter_jcall(const void* this_arg, LDKPublicKey sender, LDKCVec_PublicKeyZ peers, LDKDestination destination) {
15089         LDKMessageRouter_JCalls *j_calls = (LDKMessageRouter_JCalls*) this_arg;
15090         int8_tArray sender_arr = init_int8_tArray(33, __LINE__);
15091         memcpy(sender_arr->elems, sender.compressed_form, 33);
15092         LDKCVec_PublicKeyZ peers_var = peers;
15093         ptrArray peers_arr = NULL;
15094         peers_arr = init_ptrArray(peers_var.datalen, __LINE__);
15095         int8_tArray *peers_arr_ptr = (int8_tArray*)(((uint8_t*)peers_arr) + 8);
15096         for (size_t i = 0; i < peers_var.datalen; i++) {
15097                 int8_tArray peers_conv_8_arr = init_int8_tArray(33, __LINE__);
15098                 memcpy(peers_conv_8_arr->elems, peers_var.data[i].compressed_form, 33);
15099                 peers_arr_ptr[i] = peers_conv_8_arr;
15100         }
15101         
15102         FREE(peers_var.data);
15103         LDKDestination *destination_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
15104         *destination_copy = destination;
15105         int64_t destination_ref = tag_ptr(destination_copy, true);
15106         uint64_t ret = js_invoke_function_l_lll(j_calls->instance_ptr, 141, (int64_t)sender_arr, (int64_t)peers_arr, destination_ref);
15107         void* ret_ptr = untag_ptr(ret);
15108         CHECK_ACCESS(ret_ptr);
15109         LDKCResult_OnionMessagePathNoneZ ret_conv = *(LDKCResult_OnionMessagePathNoneZ*)(ret_ptr);
15110         FREE(untag_ptr(ret));
15111         return ret_conv;
15112 }
15113 static void LDKMessageRouter_JCalls_cloned(LDKMessageRouter* new_obj) {
15114         LDKMessageRouter_JCalls *j_calls = (LDKMessageRouter_JCalls*) new_obj->this_arg;
15115         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15116 }
15117 static inline LDKMessageRouter LDKMessageRouter_init (int64_t o) {
15118         LDKMessageRouter_JCalls *calls = MALLOC(sizeof(LDKMessageRouter_JCalls), "LDKMessageRouter_JCalls");
15119         atomic_init(&calls->refcnt, 1);
15120         calls->instance_ptr = o;
15121
15122         LDKMessageRouter ret = {
15123                 .this_arg = (void*) calls,
15124                 .find_path = find_path_LDKMessageRouter_jcall,
15125                 .free = LDKMessageRouter_JCalls_free,
15126         };
15127         return ret;
15128 }
15129 uint64_t  CS_LDK_LDKMessageRouter_new(int32_t o) {
15130         LDKMessageRouter *res_ptr = MALLOC(sizeof(LDKMessageRouter), "LDKMessageRouter");
15131         *res_ptr = LDKMessageRouter_init(o);
15132         return tag_ptr(res_ptr, true);
15133 }
15134 int64_t  CS_LDK_MessageRouter_find_path(int64_t this_arg, int8_tArray sender, ptrArray peers, int64_t destination) {
15135         void* this_arg_ptr = untag_ptr(this_arg);
15136         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15137         LDKMessageRouter* this_arg_conv = (LDKMessageRouter*)this_arg_ptr;
15138         LDKPublicKey sender_ref;
15139         CHECK(sender->arr_len == 33);
15140         memcpy(sender_ref.compressed_form, sender->elems, 33); FREE(sender);
15141         LDKCVec_PublicKeyZ peers_constr;
15142         peers_constr.datalen = peers->arr_len;
15143         if (peers_constr.datalen > 0)
15144                 peers_constr.data = MALLOC(peers_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
15145         else
15146                 peers_constr.data = NULL;
15147         int8_tArray* peers_vals = (void*) peers->elems;
15148         for (size_t i = 0; i < peers_constr.datalen; i++) {
15149                 int8_tArray peers_conv_8 = peers_vals[i];
15150                 LDKPublicKey peers_conv_8_ref;
15151                 CHECK(peers_conv_8->arr_len == 33);
15152                 memcpy(peers_conv_8_ref.compressed_form, peers_conv_8->elems, 33); FREE(peers_conv_8);
15153                 peers_constr.data[i] = peers_conv_8_ref;
15154         }
15155         FREE(peers);
15156         void* destination_ptr = untag_ptr(destination);
15157         CHECK_ACCESS(destination_ptr);
15158         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
15159         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
15160         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
15161         *ret_conv = (this_arg_conv->find_path)(this_arg_conv->this_arg, sender_ref, peers_constr, destination_conv);
15162         return tag_ptr(ret_conv, true);
15163 }
15164
15165 typedef struct LDKCoinSelectionSource_JCalls {
15166         atomic_size_t refcnt;
15167         uint32_t instance_ptr;
15168 } LDKCoinSelectionSource_JCalls;
15169 static void LDKCoinSelectionSource_JCalls_free(void* this_arg) {
15170         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) this_arg;
15171         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15172                 FREE(j_calls);
15173         }
15174 }
15175 LDKCResult_CoinSelectionNoneZ select_confirmed_utxos_LDKCoinSelectionSource_jcall(const void* this_arg, LDKThirtyTwoBytes claim_id, LDKCVec_InputZ must_spend, LDKCVec_TxOutZ must_pay_to, uint32_t target_feerate_sat_per_1000_weight) {
15176         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) this_arg;
15177         int8_tArray claim_id_arr = init_int8_tArray(32, __LINE__);
15178         memcpy(claim_id_arr->elems, claim_id.data, 32);
15179         LDKCVec_InputZ must_spend_var = must_spend;
15180         int64_tArray must_spend_arr = NULL;
15181         must_spend_arr = init_int64_tArray(must_spend_var.datalen, __LINE__);
15182         int64_t *must_spend_arr_ptr = (int64_t*)(((uint8_t*)must_spend_arr) + 8);
15183         for (size_t h = 0; h < must_spend_var.datalen; h++) {
15184                 LDKInput must_spend_conv_7_var = must_spend_var.data[h];
15185                 int64_t must_spend_conv_7_ref = 0;
15186                 CHECK_INNER_FIELD_ACCESS_OR_NULL(must_spend_conv_7_var);
15187                 must_spend_conv_7_ref = tag_ptr(must_spend_conv_7_var.inner, must_spend_conv_7_var.is_owned);
15188                 must_spend_arr_ptr[h] = must_spend_conv_7_ref;
15189         }
15190         
15191         FREE(must_spend_var.data);
15192         LDKCVec_TxOutZ must_pay_to_var = must_pay_to;
15193         int64_tArray must_pay_to_arr = NULL;
15194         must_pay_to_arr = init_int64_tArray(must_pay_to_var.datalen, __LINE__);
15195         int64_t *must_pay_to_arr_ptr = (int64_t*)(((uint8_t*)must_pay_to_arr) + 8);
15196         for (size_t h = 0; h < must_pay_to_var.datalen; h++) {
15197                 LDKTxOut* must_pay_to_conv_7_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15198                 *must_pay_to_conv_7_ref = must_pay_to_var.data[h];
15199                 must_pay_to_arr_ptr[h] = tag_ptr(must_pay_to_conv_7_ref, true);
15200         }
15201         
15202         FREE(must_pay_to_var.data);
15203         int32_t target_feerate_sat_per_1000_weight_conv = target_feerate_sat_per_1000_weight;
15204         uint64_t ret = js_invoke_function_l_llli(j_calls->instance_ptr, 142, (int64_t)claim_id_arr, (int64_t)must_spend_arr, (int64_t)must_pay_to_arr, target_feerate_sat_per_1000_weight_conv);
15205         void* ret_ptr = untag_ptr(ret);
15206         CHECK_ACCESS(ret_ptr);
15207         LDKCResult_CoinSelectionNoneZ ret_conv = *(LDKCResult_CoinSelectionNoneZ*)(ret_ptr);
15208         FREE(untag_ptr(ret));
15209         return ret_conv;
15210 }
15211 LDKCResult_TransactionNoneZ sign_tx_LDKCoinSelectionSource_jcall(const void* this_arg, LDKTransaction tx) {
15212         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) this_arg;
15213         LDKTransaction tx_var = tx;
15214         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
15215         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
15216         Transaction_free(tx_var);
15217         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 143, (int64_t)tx_arr);
15218         void* ret_ptr = untag_ptr(ret);
15219         CHECK_ACCESS(ret_ptr);
15220         LDKCResult_TransactionNoneZ ret_conv = *(LDKCResult_TransactionNoneZ*)(ret_ptr);
15221         FREE(untag_ptr(ret));
15222         return ret_conv;
15223 }
15224 static void LDKCoinSelectionSource_JCalls_cloned(LDKCoinSelectionSource* new_obj) {
15225         LDKCoinSelectionSource_JCalls *j_calls = (LDKCoinSelectionSource_JCalls*) new_obj->this_arg;
15226         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15227 }
15228 static inline LDKCoinSelectionSource LDKCoinSelectionSource_init (int64_t o) {
15229         LDKCoinSelectionSource_JCalls *calls = MALLOC(sizeof(LDKCoinSelectionSource_JCalls), "LDKCoinSelectionSource_JCalls");
15230         atomic_init(&calls->refcnt, 1);
15231         calls->instance_ptr = o;
15232
15233         LDKCoinSelectionSource ret = {
15234                 .this_arg = (void*) calls,
15235                 .select_confirmed_utxos = select_confirmed_utxos_LDKCoinSelectionSource_jcall,
15236                 .sign_tx = sign_tx_LDKCoinSelectionSource_jcall,
15237                 .free = LDKCoinSelectionSource_JCalls_free,
15238         };
15239         return ret;
15240 }
15241 uint64_t  CS_LDK_LDKCoinSelectionSource_new(int32_t o) {
15242         LDKCoinSelectionSource *res_ptr = MALLOC(sizeof(LDKCoinSelectionSource), "LDKCoinSelectionSource");
15243         *res_ptr = LDKCoinSelectionSource_init(o);
15244         return tag_ptr(res_ptr, true);
15245 }
15246 int64_t  CS_LDK_CoinSelectionSource_select_confirmed_utxos(int64_t this_arg, int8_tArray claim_id, int64_tArray must_spend, int64_tArray must_pay_to, int32_t target_feerate_sat_per_1000_weight) {
15247         void* this_arg_ptr = untag_ptr(this_arg);
15248         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15249         LDKCoinSelectionSource* this_arg_conv = (LDKCoinSelectionSource*)this_arg_ptr;
15250         LDKThirtyTwoBytes claim_id_ref;
15251         CHECK(claim_id->arr_len == 32);
15252         memcpy(claim_id_ref.data, claim_id->elems, 32); FREE(claim_id);
15253         LDKCVec_InputZ must_spend_constr;
15254         must_spend_constr.datalen = must_spend->arr_len;
15255         if (must_spend_constr.datalen > 0)
15256                 must_spend_constr.data = MALLOC(must_spend_constr.datalen * sizeof(LDKInput), "LDKCVec_InputZ Elements");
15257         else
15258                 must_spend_constr.data = NULL;
15259         int64_t* must_spend_vals = must_spend->elems;
15260         for (size_t h = 0; h < must_spend_constr.datalen; h++) {
15261                 int64_t must_spend_conv_7 = must_spend_vals[h];
15262                 LDKInput must_spend_conv_7_conv;
15263                 must_spend_conv_7_conv.inner = untag_ptr(must_spend_conv_7);
15264                 must_spend_conv_7_conv.is_owned = ptr_is_owned(must_spend_conv_7);
15265                 CHECK_INNER_FIELD_ACCESS_OR_NULL(must_spend_conv_7_conv);
15266                 must_spend_conv_7_conv = Input_clone(&must_spend_conv_7_conv);
15267                 must_spend_constr.data[h] = must_spend_conv_7_conv;
15268         }
15269         FREE(must_spend);
15270         LDKCVec_TxOutZ must_pay_to_constr;
15271         must_pay_to_constr.datalen = must_pay_to->arr_len;
15272         if (must_pay_to_constr.datalen > 0)
15273                 must_pay_to_constr.data = MALLOC(must_pay_to_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15274         else
15275                 must_pay_to_constr.data = NULL;
15276         int64_t* must_pay_to_vals = must_pay_to->elems;
15277         for (size_t h = 0; h < must_pay_to_constr.datalen; h++) {
15278                 int64_t must_pay_to_conv_7 = must_pay_to_vals[h];
15279                 void* must_pay_to_conv_7_ptr = untag_ptr(must_pay_to_conv_7);
15280                 CHECK_ACCESS(must_pay_to_conv_7_ptr);
15281                 LDKTxOut must_pay_to_conv_7_conv = *(LDKTxOut*)(must_pay_to_conv_7_ptr);
15282                 must_pay_to_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(must_pay_to_conv_7));
15283                 must_pay_to_constr.data[h] = must_pay_to_conv_7_conv;
15284         }
15285         FREE(must_pay_to);
15286         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
15287         *ret_conv = (this_arg_conv->select_confirmed_utxos)(this_arg_conv->this_arg, claim_id_ref, must_spend_constr, must_pay_to_constr, target_feerate_sat_per_1000_weight);
15288         return tag_ptr(ret_conv, true);
15289 }
15290
15291 int64_t  CS_LDK_CoinSelectionSource_sign_tx(int64_t this_arg, int8_tArray tx) {
15292         void* this_arg_ptr = untag_ptr(this_arg);
15293         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15294         LDKCoinSelectionSource* this_arg_conv = (LDKCoinSelectionSource*)this_arg_ptr;
15295         LDKTransaction tx_ref;
15296         tx_ref.datalen = tx->arr_len;
15297         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
15298         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
15299         tx_ref.data_is_owned = true;
15300         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15301         *ret_conv = (this_arg_conv->sign_tx)(this_arg_conv->this_arg, tx_ref);
15302         return tag_ptr(ret_conv, true);
15303 }
15304
15305 typedef struct LDKWalletSource_JCalls {
15306         atomic_size_t refcnt;
15307         uint32_t instance_ptr;
15308 } LDKWalletSource_JCalls;
15309 static void LDKWalletSource_JCalls_free(void* this_arg) {
15310         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15311         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15312                 FREE(j_calls);
15313         }
15314 }
15315 LDKCResult_CVec_UtxoZNoneZ list_confirmed_utxos_LDKWalletSource_jcall(const void* this_arg) {
15316         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15317         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 144);
15318         void* ret_ptr = untag_ptr(ret);
15319         CHECK_ACCESS(ret_ptr);
15320         LDKCResult_CVec_UtxoZNoneZ ret_conv = *(LDKCResult_CVec_UtxoZNoneZ*)(ret_ptr);
15321         FREE(untag_ptr(ret));
15322         return ret_conv;
15323 }
15324 LDKCResult_CVec_u8ZNoneZ get_change_script_LDKWalletSource_jcall(const void* this_arg) {
15325         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15326         uint64_t ret = js_invoke_function_l_(j_calls->instance_ptr, 145);
15327         void* ret_ptr = untag_ptr(ret);
15328         CHECK_ACCESS(ret_ptr);
15329         LDKCResult_CVec_u8ZNoneZ ret_conv = *(LDKCResult_CVec_u8ZNoneZ*)(ret_ptr);
15330         FREE(untag_ptr(ret));
15331         return ret_conv;
15332 }
15333 LDKCResult_TransactionNoneZ sign_tx_LDKWalletSource_jcall(const void* this_arg, LDKTransaction tx) {
15334         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) this_arg;
15335         LDKTransaction tx_var = tx;
15336         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
15337         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
15338         Transaction_free(tx_var);
15339         uint64_t ret = js_invoke_function_l_l(j_calls->instance_ptr, 146, (int64_t)tx_arr);
15340         void* ret_ptr = untag_ptr(ret);
15341         CHECK_ACCESS(ret_ptr);
15342         LDKCResult_TransactionNoneZ ret_conv = *(LDKCResult_TransactionNoneZ*)(ret_ptr);
15343         FREE(untag_ptr(ret));
15344         return ret_conv;
15345 }
15346 static void LDKWalletSource_JCalls_cloned(LDKWalletSource* new_obj) {
15347         LDKWalletSource_JCalls *j_calls = (LDKWalletSource_JCalls*) new_obj->this_arg;
15348         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15349 }
15350 static inline LDKWalletSource LDKWalletSource_init (int64_t o) {
15351         LDKWalletSource_JCalls *calls = MALLOC(sizeof(LDKWalletSource_JCalls), "LDKWalletSource_JCalls");
15352         atomic_init(&calls->refcnt, 1);
15353         calls->instance_ptr = o;
15354
15355         LDKWalletSource ret = {
15356                 .this_arg = (void*) calls,
15357                 .list_confirmed_utxos = list_confirmed_utxos_LDKWalletSource_jcall,
15358                 .get_change_script = get_change_script_LDKWalletSource_jcall,
15359                 .sign_tx = sign_tx_LDKWalletSource_jcall,
15360                 .free = LDKWalletSource_JCalls_free,
15361         };
15362         return ret;
15363 }
15364 uint64_t  CS_LDK_LDKWalletSource_new(int32_t o) {
15365         LDKWalletSource *res_ptr = MALLOC(sizeof(LDKWalletSource), "LDKWalletSource");
15366         *res_ptr = LDKWalletSource_init(o);
15367         return tag_ptr(res_ptr, true);
15368 }
15369 int64_t  CS_LDK_WalletSource_list_confirmed_utxos(int64_t this_arg) {
15370         void* this_arg_ptr = untag_ptr(this_arg);
15371         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15372         LDKWalletSource* this_arg_conv = (LDKWalletSource*)this_arg_ptr;
15373         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
15374         *ret_conv = (this_arg_conv->list_confirmed_utxos)(this_arg_conv->this_arg);
15375         return tag_ptr(ret_conv, true);
15376 }
15377
15378 int64_t  CS_LDK_WalletSource_get_change_script(int64_t this_arg) {
15379         void* this_arg_ptr = untag_ptr(this_arg);
15380         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15381         LDKWalletSource* this_arg_conv = (LDKWalletSource*)this_arg_ptr;
15382         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
15383         *ret_conv = (this_arg_conv->get_change_script)(this_arg_conv->this_arg);
15384         return tag_ptr(ret_conv, true);
15385 }
15386
15387 int64_t  CS_LDK_WalletSource_sign_tx(int64_t this_arg, int8_tArray tx) {
15388         void* this_arg_ptr = untag_ptr(this_arg);
15389         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15390         LDKWalletSource* this_arg_conv = (LDKWalletSource*)this_arg_ptr;
15391         LDKTransaction tx_ref;
15392         tx_ref.datalen = tx->arr_len;
15393         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
15394         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
15395         tx_ref.data_is_owned = true;
15396         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15397         *ret_conv = (this_arg_conv->sign_tx)(this_arg_conv->this_arg, tx_ref);
15398         return tag_ptr(ret_conv, true);
15399 }
15400
15401 uint32_t CS_LDK_LDKGossipSync_ty_from_ptr(int64_t ptr) {
15402         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15403         switch(obj->tag) {
15404                 case LDKGossipSync_P2P: return 0;
15405                 case LDKGossipSync_Rapid: return 1;
15406                 case LDKGossipSync_None: return 2;
15407                 default: abort();
15408         }
15409 }
15410 int64_t CS_LDK_LDKGossipSync_P2P_get_p2p(int64_t ptr) {
15411         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15412         CHECK(obj->tag == LDKGossipSync_P2P);
15413         LDKP2PGossipSync p2p_var = obj->p2p;
15414                         int64_t p2p_ref = 0;
15415                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
15416                         p2p_ref = tag_ptr(p2p_var.inner, false);
15417         return p2p_ref;
15418 }
15419 int64_t CS_LDK_LDKGossipSync_Rapid_get_rapid(int64_t ptr) {
15420         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15421         CHECK(obj->tag == LDKGossipSync_Rapid);
15422         LDKRapidGossipSync rapid_var = obj->rapid;
15423                         int64_t rapid_ref = 0;
15424                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
15425                         rapid_ref = tag_ptr(rapid_var.inner, false);
15426         return rapid_ref;
15427 }
15428 uint32_t CS_LDK_LDKFallback_ty_from_ptr(int64_t ptr) {
15429         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15430         switch(obj->tag) {
15431                 case LDKFallback_SegWitProgram: return 0;
15432                 case LDKFallback_PubKeyHash: return 1;
15433                 case LDKFallback_ScriptHash: return 2;
15434                 default: abort();
15435         }
15436 }
15437 int8_t CS_LDK_LDKFallback_SegWitProgram_get_version(int64_t ptr) {
15438         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15439         CHECK(obj->tag == LDKFallback_SegWitProgram);
15440         uint8_t version_val = obj->seg_wit_program.version._0;
15441         return version_val;
15442 }
15443 int8_tArray CS_LDK_LDKFallback_SegWitProgram_get_program(int64_t ptr) {
15444         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15445         CHECK(obj->tag == LDKFallback_SegWitProgram);
15446         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
15447                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
15448                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
15449         return program_arr;
15450 }
15451 int8_tArray CS_LDK_LDKFallback_PubKeyHash_get_pub_key_hash(int64_t ptr) {
15452         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15453         CHECK(obj->tag == LDKFallback_PubKeyHash);
15454         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
15455         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
15456         return pub_key_hash_arr;
15457 }
15458 int8_tArray CS_LDK_LDKFallback_ScriptHash_get_script_hash(int64_t ptr) {
15459         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15460         CHECK(obj->tag == LDKFallback_ScriptHash);
15461         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
15462         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
15463         return script_hash_arr;
15464 }
15465 jstring  CS_LDK__ldk_get_compiled_version() {
15466         LDKStr ret_str = _ldk_get_compiled_version();
15467         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
15468         Str_free(ret_str);
15469         return ret_conv;
15470 }
15471
15472 jstring  CS_LDK__ldk_c_bindings_get_compiled_version() {
15473         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15474         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
15475         Str_free(ret_str);
15476         return ret_conv;
15477 }
15478
15479 int8_tArray  CS_LDK_U128_le_bytes(int8_tArray val) {
15480         LDKU128 val_ref;
15481         CHECK(val->arr_len == 16);
15482         memcpy(val_ref.le_bytes, val->elems, 16); FREE(val);
15483         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
15484         memcpy(ret_arr->elems, U128_le_bytes(val_ref).data, 16);
15485         return ret_arr;
15486 }
15487
15488 int8_tArray  CS_LDK_U128_new(int8_tArray le_bytes) {
15489         LDKSixteenBytes le_bytes_ref;
15490         CHECK(le_bytes->arr_len == 16);
15491         memcpy(le_bytes_ref.data, le_bytes->elems, 16); FREE(le_bytes);
15492         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
15493         memcpy(ret_arr->elems, U128_new(le_bytes_ref).le_bytes, 16);
15494         return ret_arr;
15495 }
15496
15497 int64_t  CS_LDK_BigEndianScalar_new(int8_tArray big_endian_bytes) {
15498         LDKThirtyTwoBytes big_endian_bytes_ref;
15499         CHECK(big_endian_bytes->arr_len == 32);
15500         memcpy(big_endian_bytes_ref.data, big_endian_bytes->elems, 32); FREE(big_endian_bytes);
15501         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15502         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15503         return tag_ptr(ret_ref, true);
15504 }
15505
15506 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15507         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15508         *ret_copy = Bech32Error_clone(arg);
15509         int64_t ret_ref = tag_ptr(ret_copy, true);
15510         return ret_ref;
15511 }
15512 int64_t  CS_LDK_Bech32Error_clone_ptr(int64_t arg) {
15513         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15514         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15515         return ret_conv;
15516 }
15517
15518 int64_t  CS_LDK_Bech32Error_clone(int64_t orig) {
15519         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15520         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15521         *ret_copy = Bech32Error_clone(orig_conv);
15522         int64_t ret_ref = tag_ptr(ret_copy, true);
15523         return ret_ref;
15524 }
15525
15526 void  CS_LDK_Bech32Error_free(int64_t o) {
15527         if (!ptr_is_owned(o)) return;
15528         void* o_ptr = untag_ptr(o);
15529         CHECK_ACCESS(o_ptr);
15530         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15531         FREE(untag_ptr(o));
15532         Bech32Error_free(o_conv);
15533 }
15534
15535 void  CS_LDK_Transaction_free(int8_tArray _res) {
15536         LDKTransaction _res_ref;
15537         _res_ref.datalen = _res->arr_len;
15538         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15539         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15540         _res_ref.data_is_owned = true;
15541         Transaction_free(_res_ref);
15542 }
15543
15544 void  CS_LDK_Witness_free(int8_tArray _res) {
15545         LDKWitness _res_ref;
15546         _res_ref.datalen = _res->arr_len;
15547         _res_ref.data = MALLOC(_res_ref.datalen, "LDKWitness Bytes");
15548         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15549         _res_ref.data_is_owned = true;
15550         Witness_free(_res_ref);
15551 }
15552
15553 void  CS_LDK_TxIn_free(int64_t _res) {
15554         if (!ptr_is_owned(_res)) return;
15555         void* _res_ptr = untag_ptr(_res);
15556         CHECK_ACCESS(_res_ptr);
15557         LDKTxIn _res_conv = *(LDKTxIn*)(_res_ptr);
15558         FREE(untag_ptr(_res));
15559         TxIn_free(_res_conv);
15560 }
15561
15562 int64_t  CS_LDK_TxIn_new(int8_tArray witness, int8_tArray script_sig, int32_t sequence, int8_tArray previous_txid, int32_t previous_vout) {
15563         LDKWitness witness_ref;
15564         witness_ref.datalen = witness->arr_len;
15565         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
15566         memcpy(witness_ref.data, witness->elems, witness_ref.datalen); FREE(witness);
15567         witness_ref.data_is_owned = true;
15568         LDKCVec_u8Z script_sig_ref;
15569         script_sig_ref.datalen = script_sig->arr_len;
15570         script_sig_ref.data = MALLOC(script_sig_ref.datalen, "LDKCVec_u8Z Bytes");
15571         memcpy(script_sig_ref.data, script_sig->elems, script_sig_ref.datalen); FREE(script_sig);
15572         LDKThirtyTwoBytes previous_txid_ref;
15573         CHECK(previous_txid->arr_len == 32);
15574         memcpy(previous_txid_ref.data, previous_txid->elems, 32); FREE(previous_txid);
15575         LDKTxIn* ret_ref = MALLOC(sizeof(LDKTxIn), "LDKTxIn");
15576         *ret_ref = TxIn_new(witness_ref, script_sig_ref, sequence, previous_txid_ref, previous_vout);
15577         return tag_ptr(ret_ref, true);
15578 }
15579
15580 int64_t  CS_LDK_TxOut_new(int8_tArray script_pubkey, int64_t value) {
15581         LDKCVec_u8Z script_pubkey_ref;
15582         script_pubkey_ref.datalen = script_pubkey->arr_len;
15583         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15584         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
15585         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15586         *ret_ref = TxOut_new(script_pubkey_ref, value);
15587         return tag_ptr(ret_ref, true);
15588 }
15589
15590 void  CS_LDK_TxOut_free(int64_t _res) {
15591         if (!ptr_is_owned(_res)) return;
15592         void* _res_ptr = untag_ptr(_res);
15593         CHECK_ACCESS(_res_ptr);
15594         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15595         FREE(untag_ptr(_res));
15596         TxOut_free(_res_conv);
15597 }
15598
15599 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15600         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15601         *ret_ref = TxOut_clone(arg);
15602         return tag_ptr(ret_ref, true);
15603 }
15604 int64_t  CS_LDK_TxOut_clone_ptr(int64_t arg) {
15605         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15606         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15607         return ret_conv;
15608 }
15609
15610 int64_t  CS_LDK_TxOut_clone(int64_t orig) {
15611         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15612         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15613         *ret_ref = TxOut_clone(orig_conv);
15614         return tag_ptr(ret_ref, true);
15615 }
15616
15617 void  CS_LDK_Str_free(jstring _res) {
15618         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15619         Str_free(dummy);
15620 }
15621
15622 int64_t  CS_LDK_COption_u64Z_some(int64_t o) {
15623         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15624         *ret_copy = COption_u64Z_some(o);
15625         int64_t ret_ref = tag_ptr(ret_copy, true);
15626         return ret_ref;
15627 }
15628
15629 int64_t  CS_LDK_COption_u64Z_none() {
15630         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15631         *ret_copy = COption_u64Z_none();
15632         int64_t ret_ref = tag_ptr(ret_copy, true);
15633         return ret_ref;
15634 }
15635
15636 void  CS_LDK_COption_u64Z_free(int64_t _res) {
15637         if (!ptr_is_owned(_res)) return;
15638         void* _res_ptr = untag_ptr(_res);
15639         CHECK_ACCESS(_res_ptr);
15640         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
15641         FREE(untag_ptr(_res));
15642         COption_u64Z_free(_res_conv);
15643 }
15644
15645 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
15646         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15647         *ret_copy = COption_u64Z_clone(arg);
15648         int64_t ret_ref = tag_ptr(ret_copy, true);
15649         return ret_ref;
15650 }
15651 int64_t  CS_LDK_COption_u64Z_clone_ptr(int64_t arg) {
15652         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
15653         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
15654         return ret_conv;
15655 }
15656
15657 int64_t  CS_LDK_COption_u64Z_clone(int64_t orig) {
15658         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
15659         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
15660         *ret_copy = COption_u64Z_clone(orig_conv);
15661         int64_t ret_ref = tag_ptr(ret_copy, true);
15662         return ret_ref;
15663 }
15664
15665 void  CS_LDK_CVec_BlindedPathZ_free(int64_tArray _res) {
15666         LDKCVec_BlindedPathZ _res_constr;
15667         _res_constr.datalen = _res->arr_len;
15668         if (_res_constr.datalen > 0)
15669                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedPath), "LDKCVec_BlindedPathZ Elements");
15670         else
15671                 _res_constr.data = NULL;
15672         int64_t* _res_vals = _res->elems;
15673         for (size_t n = 0; n < _res_constr.datalen; n++) {
15674                 int64_t _res_conv_13 = _res_vals[n];
15675                 LDKBlindedPath _res_conv_13_conv;
15676                 _res_conv_13_conv.inner = untag_ptr(_res_conv_13);
15677                 _res_conv_13_conv.is_owned = ptr_is_owned(_res_conv_13);
15678                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_13_conv);
15679                 _res_constr.data[n] = _res_conv_13_conv;
15680         }
15681         FREE(_res);
15682         CVec_BlindedPathZ_free(_res_constr);
15683 }
15684
15685 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_ok(int64_t o) {
15686         LDKRefund o_conv;
15687         o_conv.inner = untag_ptr(o);
15688         o_conv.is_owned = ptr_is_owned(o);
15689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15690         o_conv = Refund_clone(&o_conv);
15691         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15692         *ret_conv = CResult_RefundBolt12ParseErrorZ_ok(o_conv);
15693         return tag_ptr(ret_conv, true);
15694 }
15695
15696 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_err(int64_t e) {
15697         LDKBolt12ParseError e_conv;
15698         e_conv.inner = untag_ptr(e);
15699         e_conv.is_owned = ptr_is_owned(e);
15700         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15701         e_conv = Bolt12ParseError_clone(&e_conv);
15702         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15703         *ret_conv = CResult_RefundBolt12ParseErrorZ_err(e_conv);
15704         return tag_ptr(ret_conv, true);
15705 }
15706
15707 jboolean  CS_LDK_CResult_RefundBolt12ParseErrorZ_is_ok(int64_t o) {
15708         LDKCResult_RefundBolt12ParseErrorZ* o_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(o);
15709         jboolean ret_conv = CResult_RefundBolt12ParseErrorZ_is_ok(o_conv);
15710         return ret_conv;
15711 }
15712
15713 void  CS_LDK_CResult_RefundBolt12ParseErrorZ_free(int64_t _res) {
15714         if (!ptr_is_owned(_res)) return;
15715         void* _res_ptr = untag_ptr(_res);
15716         CHECK_ACCESS(_res_ptr);
15717         LDKCResult_RefundBolt12ParseErrorZ _res_conv = *(LDKCResult_RefundBolt12ParseErrorZ*)(_res_ptr);
15718         FREE(untag_ptr(_res));
15719         CResult_RefundBolt12ParseErrorZ_free(_res_conv);
15720 }
15721
15722 static inline uint64_t CResult_RefundBolt12ParseErrorZ_clone_ptr(LDKCResult_RefundBolt12ParseErrorZ *NONNULL_PTR arg) {
15723         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15724         *ret_conv = CResult_RefundBolt12ParseErrorZ_clone(arg);
15725         return tag_ptr(ret_conv, true);
15726 }
15727 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_clone_ptr(int64_t arg) {
15728         LDKCResult_RefundBolt12ParseErrorZ* arg_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(arg);
15729         int64_t ret_conv = CResult_RefundBolt12ParseErrorZ_clone_ptr(arg_conv);
15730         return ret_conv;
15731 }
15732
15733 int64_t  CS_LDK_CResult_RefundBolt12ParseErrorZ_clone(int64_t orig) {
15734         LDKCResult_RefundBolt12ParseErrorZ* orig_conv = (LDKCResult_RefundBolt12ParseErrorZ*)untag_ptr(orig);
15735         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
15736         *ret_conv = CResult_RefundBolt12ParseErrorZ_clone(orig_conv);
15737         return tag_ptr(ret_conv, true);
15738 }
15739
15740 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_ok(int64_t o) {
15741         void* o_ptr = untag_ptr(o);
15742         CHECK_ACCESS(o_ptr);
15743         LDKRetry o_conv = *(LDKRetry*)(o_ptr);
15744         o_conv = Retry_clone((LDKRetry*)untag_ptr(o));
15745         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15746         *ret_conv = CResult_RetryDecodeErrorZ_ok(o_conv);
15747         return tag_ptr(ret_conv, true);
15748 }
15749
15750 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_err(int64_t e) {
15751         void* e_ptr = untag_ptr(e);
15752         CHECK_ACCESS(e_ptr);
15753         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15754         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15755         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15756         *ret_conv = CResult_RetryDecodeErrorZ_err(e_conv);
15757         return tag_ptr(ret_conv, true);
15758 }
15759
15760 jboolean  CS_LDK_CResult_RetryDecodeErrorZ_is_ok(int64_t o) {
15761         LDKCResult_RetryDecodeErrorZ* o_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(o);
15762         jboolean ret_conv = CResult_RetryDecodeErrorZ_is_ok(o_conv);
15763         return ret_conv;
15764 }
15765
15766 void  CS_LDK_CResult_RetryDecodeErrorZ_free(int64_t _res) {
15767         if (!ptr_is_owned(_res)) return;
15768         void* _res_ptr = untag_ptr(_res);
15769         CHECK_ACCESS(_res_ptr);
15770         LDKCResult_RetryDecodeErrorZ _res_conv = *(LDKCResult_RetryDecodeErrorZ*)(_res_ptr);
15771         FREE(untag_ptr(_res));
15772         CResult_RetryDecodeErrorZ_free(_res_conv);
15773 }
15774
15775 static inline uint64_t CResult_RetryDecodeErrorZ_clone_ptr(LDKCResult_RetryDecodeErrorZ *NONNULL_PTR arg) {
15776         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15777         *ret_conv = CResult_RetryDecodeErrorZ_clone(arg);
15778         return tag_ptr(ret_conv, true);
15779 }
15780 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_clone_ptr(int64_t arg) {
15781         LDKCResult_RetryDecodeErrorZ* arg_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(arg);
15782         int64_t ret_conv = CResult_RetryDecodeErrorZ_clone_ptr(arg_conv);
15783         return ret_conv;
15784 }
15785
15786 int64_t  CS_LDK_CResult_RetryDecodeErrorZ_clone(int64_t orig) {
15787         LDKCResult_RetryDecodeErrorZ* orig_conv = (LDKCResult_RetryDecodeErrorZ*)untag_ptr(orig);
15788         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
15789         *ret_conv = CResult_RetryDecodeErrorZ_clone(orig_conv);
15790         return tag_ptr(ret_conv, true);
15791 }
15792
15793 int64_t  CS_LDK_CResult_NoneAPIErrorZ_ok() {
15794         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15795         *ret_conv = CResult_NoneAPIErrorZ_ok();
15796         return tag_ptr(ret_conv, true);
15797 }
15798
15799 int64_t  CS_LDK_CResult_NoneAPIErrorZ_err(int64_t e) {
15800         void* e_ptr = untag_ptr(e);
15801         CHECK_ACCESS(e_ptr);
15802         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15803         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
15804         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15805         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15806         return tag_ptr(ret_conv, true);
15807 }
15808
15809 jboolean  CS_LDK_CResult_NoneAPIErrorZ_is_ok(int64_t o) {
15810         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
15811         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15812         return ret_conv;
15813 }
15814
15815 void  CS_LDK_CResult_NoneAPIErrorZ_free(int64_t _res) {
15816         if (!ptr_is_owned(_res)) return;
15817         void* _res_ptr = untag_ptr(_res);
15818         CHECK_ACCESS(_res_ptr);
15819         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15820         FREE(untag_ptr(_res));
15821         CResult_NoneAPIErrorZ_free(_res_conv);
15822 }
15823
15824 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15825         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15826         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15827         return tag_ptr(ret_conv, true);
15828 }
15829 int64_t  CS_LDK_CResult_NoneAPIErrorZ_clone_ptr(int64_t arg) {
15830         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
15831         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15832         return ret_conv;
15833 }
15834
15835 int64_t  CS_LDK_CResult_NoneAPIErrorZ_clone(int64_t orig) {
15836         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
15837         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15838         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15839         return tag_ptr(ret_conv, true);
15840 }
15841
15842 void  CS_LDK_CVec_CResult_NoneAPIErrorZZ_free(int64_tArray _res) {
15843         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15844         _res_constr.datalen = _res->arr_len;
15845         if (_res_constr.datalen > 0)
15846                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15847         else
15848                 _res_constr.data = NULL;
15849         int64_t* _res_vals = _res->elems;
15850         for (size_t w = 0; w < _res_constr.datalen; w++) {
15851                 int64_t _res_conv_22 = _res_vals[w];
15852                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
15853                 CHECK_ACCESS(_res_conv_22_ptr);
15854                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15855                 FREE(untag_ptr(_res_conv_22));
15856                 _res_constr.data[w] = _res_conv_22_conv;
15857         }
15858         FREE(_res);
15859         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15860 }
15861
15862 void  CS_LDK_CVec_APIErrorZ_free(int64_tArray _res) {
15863         LDKCVec_APIErrorZ _res_constr;
15864         _res_constr.datalen = _res->arr_len;
15865         if (_res_constr.datalen > 0)
15866                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15867         else
15868                 _res_constr.data = NULL;
15869         int64_t* _res_vals = _res->elems;
15870         for (size_t k = 0; k < _res_constr.datalen; k++) {
15871                 int64_t _res_conv_10 = _res_vals[k];
15872                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
15873                 CHECK_ACCESS(_res_conv_10_ptr);
15874                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15875                 FREE(untag_ptr(_res_conv_10));
15876                 _res_constr.data[k] = _res_conv_10_conv;
15877         }
15878         FREE(_res);
15879         CVec_APIErrorZ_free(_res_constr);
15880 }
15881
15882 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_some(int8_tArray o) {
15883         LDKThirtyTwoBytes o_ref;
15884         CHECK(o->arr_len == 32);
15885         memcpy(o_ref.data, o->elems, 32); FREE(o);
15886         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15887         *ret_copy = COption_ThirtyTwoBytesZ_some(o_ref);
15888         int64_t ret_ref = tag_ptr(ret_copy, true);
15889         return ret_ref;
15890 }
15891
15892 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_none() {
15893         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15894         *ret_copy = COption_ThirtyTwoBytesZ_none();
15895         int64_t ret_ref = tag_ptr(ret_copy, true);
15896         return ret_ref;
15897 }
15898
15899 void  CS_LDK_COption_ThirtyTwoBytesZ_free(int64_t _res) {
15900         if (!ptr_is_owned(_res)) return;
15901         void* _res_ptr = untag_ptr(_res);
15902         CHECK_ACCESS(_res_ptr);
15903         LDKCOption_ThirtyTwoBytesZ _res_conv = *(LDKCOption_ThirtyTwoBytesZ*)(_res_ptr);
15904         FREE(untag_ptr(_res));
15905         COption_ThirtyTwoBytesZ_free(_res_conv);
15906 }
15907
15908 static inline uint64_t COption_ThirtyTwoBytesZ_clone_ptr(LDKCOption_ThirtyTwoBytesZ *NONNULL_PTR arg) {
15909         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15910         *ret_copy = COption_ThirtyTwoBytesZ_clone(arg);
15911         int64_t ret_ref = tag_ptr(ret_copy, true);
15912         return ret_ref;
15913 }
15914 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_clone_ptr(int64_t arg) {
15915         LDKCOption_ThirtyTwoBytesZ* arg_conv = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(arg);
15916         int64_t ret_conv = COption_ThirtyTwoBytesZ_clone_ptr(arg_conv);
15917         return ret_conv;
15918 }
15919
15920 int64_t  CS_LDK_COption_ThirtyTwoBytesZ_clone(int64_t orig) {
15921         LDKCOption_ThirtyTwoBytesZ* orig_conv = (LDKCOption_ThirtyTwoBytesZ*)untag_ptr(orig);
15922         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
15923         *ret_copy = COption_ThirtyTwoBytesZ_clone(orig_conv);
15924         int64_t ret_ref = tag_ptr(ret_copy, true);
15925         return ret_ref;
15926 }
15927
15928 void  CS_LDK_CVec_u8Z_free(int8_tArray _res) {
15929         LDKCVec_u8Z _res_ref;
15930         _res_ref.datalen = _res->arr_len;
15931         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
15932         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
15933         CVec_u8Z_free(_res_ref);
15934 }
15935
15936 int64_t  CS_LDK_COption_CVec_u8ZZ_some(int8_tArray o) {
15937         LDKCVec_u8Z o_ref;
15938         o_ref.datalen = o->arr_len;
15939         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
15940         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15941         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15942         *ret_copy = COption_CVec_u8ZZ_some(o_ref);
15943         int64_t ret_ref = tag_ptr(ret_copy, true);
15944         return ret_ref;
15945 }
15946
15947 int64_t  CS_LDK_COption_CVec_u8ZZ_none() {
15948         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15949         *ret_copy = COption_CVec_u8ZZ_none();
15950         int64_t ret_ref = tag_ptr(ret_copy, true);
15951         return ret_ref;
15952 }
15953
15954 void  CS_LDK_COption_CVec_u8ZZ_free(int64_t _res) {
15955         if (!ptr_is_owned(_res)) return;
15956         void* _res_ptr = untag_ptr(_res);
15957         CHECK_ACCESS(_res_ptr);
15958         LDKCOption_CVec_u8ZZ _res_conv = *(LDKCOption_CVec_u8ZZ*)(_res_ptr);
15959         FREE(untag_ptr(_res));
15960         COption_CVec_u8ZZ_free(_res_conv);
15961 }
15962
15963 static inline uint64_t COption_CVec_u8ZZ_clone_ptr(LDKCOption_CVec_u8ZZ *NONNULL_PTR arg) {
15964         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15965         *ret_copy = COption_CVec_u8ZZ_clone(arg);
15966         int64_t ret_ref = tag_ptr(ret_copy, true);
15967         return ret_ref;
15968 }
15969 int64_t  CS_LDK_COption_CVec_u8ZZ_clone_ptr(int64_t arg) {
15970         LDKCOption_CVec_u8ZZ* arg_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(arg);
15971         int64_t ret_conv = COption_CVec_u8ZZ_clone_ptr(arg_conv);
15972         return ret_conv;
15973 }
15974
15975 int64_t  CS_LDK_COption_CVec_u8ZZ_clone(int64_t orig) {
15976         LDKCOption_CVec_u8ZZ* orig_conv = (LDKCOption_CVec_u8ZZ*)untag_ptr(orig);
15977         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
15978         *ret_copy = COption_CVec_u8ZZ_clone(orig_conv);
15979         int64_t ret_ref = tag_ptr(ret_copy, true);
15980         return ret_ref;
15981 }
15982
15983 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_ok(int64_t o) {
15984         LDKRecipientOnionFields o_conv;
15985         o_conv.inner = untag_ptr(o);
15986         o_conv.is_owned = ptr_is_owned(o);
15987         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15988         o_conv = RecipientOnionFields_clone(&o_conv);
15989         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
15990         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_ok(o_conv);
15991         return tag_ptr(ret_conv, true);
15992 }
15993
15994 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_err(int64_t e) {
15995         void* e_ptr = untag_ptr(e);
15996         CHECK_ACCESS(e_ptr);
15997         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15998         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15999         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16000         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_err(e_conv);
16001         return tag_ptr(ret_conv, true);
16002 }
16003
16004 jboolean  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(int64_t o) {
16005         LDKCResult_RecipientOnionFieldsDecodeErrorZ* o_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(o);
16006         jboolean ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_is_ok(o_conv);
16007         return ret_conv;
16008 }
16009
16010 void  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_free(int64_t _res) {
16011         if (!ptr_is_owned(_res)) return;
16012         void* _res_ptr = untag_ptr(_res);
16013         CHECK_ACCESS(_res_ptr);
16014         LDKCResult_RecipientOnionFieldsDecodeErrorZ _res_conv = *(LDKCResult_RecipientOnionFieldsDecodeErrorZ*)(_res_ptr);
16015         FREE(untag_ptr(_res));
16016         CResult_RecipientOnionFieldsDecodeErrorZ_free(_res_conv);
16017 }
16018
16019 static inline uint64_t CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(LDKCResult_RecipientOnionFieldsDecodeErrorZ *NONNULL_PTR arg) {
16020         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16021         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(arg);
16022         return tag_ptr(ret_conv, true);
16023 }
16024 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(int64_t arg) {
16025         LDKCResult_RecipientOnionFieldsDecodeErrorZ* arg_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(arg);
16026         int64_t ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone_ptr(arg_conv);
16027         return ret_conv;
16028 }
16029
16030 int64_t  CS_LDK_CResult_RecipientOnionFieldsDecodeErrorZ_clone(int64_t orig) {
16031         LDKCResult_RecipientOnionFieldsDecodeErrorZ* orig_conv = (LDKCResult_RecipientOnionFieldsDecodeErrorZ*)untag_ptr(orig);
16032         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
16033         *ret_conv = CResult_RecipientOnionFieldsDecodeErrorZ_clone(orig_conv);
16034         return tag_ptr(ret_conv, true);
16035 }
16036
16037 static inline uint64_t C2Tuple_u64CVec_u8ZZ_clone_ptr(LDKC2Tuple_u64CVec_u8ZZ *NONNULL_PTR arg) {
16038         LDKC2Tuple_u64CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
16039         *ret_conv = C2Tuple_u64CVec_u8ZZ_clone(arg);
16040         return tag_ptr(ret_conv, true);
16041 }
16042 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_clone_ptr(int64_t arg) {
16043         LDKC2Tuple_u64CVec_u8ZZ* arg_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(arg);
16044         int64_t ret_conv = C2Tuple_u64CVec_u8ZZ_clone_ptr(arg_conv);
16045         return ret_conv;
16046 }
16047
16048 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_clone(int64_t orig) {
16049         LDKC2Tuple_u64CVec_u8ZZ* orig_conv = (LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(orig);
16050         LDKC2Tuple_u64CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
16051         *ret_conv = C2Tuple_u64CVec_u8ZZ_clone(orig_conv);
16052         return tag_ptr(ret_conv, true);
16053 }
16054
16055 int64_t  CS_LDK_C2Tuple_u64CVec_u8ZZ_new(int64_t a, int8_tArray b) {
16056         LDKCVec_u8Z b_ref;
16057         b_ref.datalen = b->arr_len;
16058         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
16059         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
16060         LDKC2Tuple_u64CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
16061         *ret_conv = C2Tuple_u64CVec_u8ZZ_new(a, b_ref);
16062         return tag_ptr(ret_conv, true);
16063 }
16064
16065 void  CS_LDK_C2Tuple_u64CVec_u8ZZ_free(int64_t _res) {
16066         if (!ptr_is_owned(_res)) return;
16067         void* _res_ptr = untag_ptr(_res);
16068         CHECK_ACCESS(_res_ptr);
16069         LDKC2Tuple_u64CVec_u8ZZ _res_conv = *(LDKC2Tuple_u64CVec_u8ZZ*)(_res_ptr);
16070         FREE(untag_ptr(_res));
16071         C2Tuple_u64CVec_u8ZZ_free(_res_conv);
16072 }
16073
16074 void  CS_LDK_CVec_C2Tuple_u64CVec_u8ZZZ_free(int64_tArray _res) {
16075         LDKCVec_C2Tuple_u64CVec_u8ZZZ _res_constr;
16076         _res_constr.datalen = _res->arr_len;
16077         if (_res_constr.datalen > 0)
16078                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKCVec_C2Tuple_u64CVec_u8ZZZ Elements");
16079         else
16080                 _res_constr.data = NULL;
16081         int64_t* _res_vals = _res->elems;
16082         for (size_t x = 0; x < _res_constr.datalen; x++) {
16083                 int64_t _res_conv_23 = _res_vals[x];
16084                 void* _res_conv_23_ptr = untag_ptr(_res_conv_23);
16085                 CHECK_ACCESS(_res_conv_23_ptr);
16086                 LDKC2Tuple_u64CVec_u8ZZ _res_conv_23_conv = *(LDKC2Tuple_u64CVec_u8ZZ*)(_res_conv_23_ptr);
16087                 FREE(untag_ptr(_res_conv_23));
16088                 _res_constr.data[x] = _res_conv_23_conv;
16089         }
16090         FREE(_res);
16091         CVec_C2Tuple_u64CVec_u8ZZZ_free(_res_constr);
16092 }
16093
16094 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_ok(int64_t o) {
16095         LDKRecipientOnionFields o_conv;
16096         o_conv.inner = untag_ptr(o);
16097         o_conv.is_owned = ptr_is_owned(o);
16098         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16099         o_conv = RecipientOnionFields_clone(&o_conv);
16100         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16101         *ret_conv = CResult_RecipientOnionFieldsNoneZ_ok(o_conv);
16102         return tag_ptr(ret_conv, true);
16103 }
16104
16105 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_err() {
16106         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16107         *ret_conv = CResult_RecipientOnionFieldsNoneZ_err();
16108         return tag_ptr(ret_conv, true);
16109 }
16110
16111 jboolean  CS_LDK_CResult_RecipientOnionFieldsNoneZ_is_ok(int64_t o) {
16112         LDKCResult_RecipientOnionFieldsNoneZ* o_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(o);
16113         jboolean ret_conv = CResult_RecipientOnionFieldsNoneZ_is_ok(o_conv);
16114         return ret_conv;
16115 }
16116
16117 void  CS_LDK_CResult_RecipientOnionFieldsNoneZ_free(int64_t _res) {
16118         if (!ptr_is_owned(_res)) return;
16119         void* _res_ptr = untag_ptr(_res);
16120         CHECK_ACCESS(_res_ptr);
16121         LDKCResult_RecipientOnionFieldsNoneZ _res_conv = *(LDKCResult_RecipientOnionFieldsNoneZ*)(_res_ptr);
16122         FREE(untag_ptr(_res));
16123         CResult_RecipientOnionFieldsNoneZ_free(_res_conv);
16124 }
16125
16126 static inline uint64_t CResult_RecipientOnionFieldsNoneZ_clone_ptr(LDKCResult_RecipientOnionFieldsNoneZ *NONNULL_PTR arg) {
16127         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16128         *ret_conv = CResult_RecipientOnionFieldsNoneZ_clone(arg);
16129         return tag_ptr(ret_conv, true);
16130 }
16131 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_clone_ptr(int64_t arg) {
16132         LDKCResult_RecipientOnionFieldsNoneZ* arg_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(arg);
16133         int64_t ret_conv = CResult_RecipientOnionFieldsNoneZ_clone_ptr(arg_conv);
16134         return ret_conv;
16135 }
16136
16137 int64_t  CS_LDK_CResult_RecipientOnionFieldsNoneZ_clone(int64_t orig) {
16138         LDKCResult_RecipientOnionFieldsNoneZ* orig_conv = (LDKCResult_RecipientOnionFieldsNoneZ*)untag_ptr(orig);
16139         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
16140         *ret_conv = CResult_RecipientOnionFieldsNoneZ_clone(orig_conv);
16141         return tag_ptr(ret_conv, true);
16142 }
16143
16144 void  CS_LDK_CVec_ThirtyTwoBytesZ_free(ptrArray _res) {
16145         LDKCVec_ThirtyTwoBytesZ _res_constr;
16146         _res_constr.datalen = _res->arr_len;
16147         if (_res_constr.datalen > 0)
16148                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16149         else
16150                 _res_constr.data = NULL;
16151         int8_tArray* _res_vals = (void*) _res->elems;
16152         for (size_t i = 0; i < _res_constr.datalen; i++) {
16153                 int8_tArray _res_conv_8 = _res_vals[i];
16154                 LDKThirtyTwoBytes _res_conv_8_ref;
16155                 CHECK(_res_conv_8->arr_len == 32);
16156                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, 32); FREE(_res_conv_8);
16157                 _res_constr.data[i] = _res_conv_8_ref;
16158         }
16159         FREE(_res);
16160         CVec_ThirtyTwoBytesZ_free(_res_constr);
16161 }
16162
16163 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_some(ptrArray o) {
16164         LDKCVec_ThirtyTwoBytesZ o_constr;
16165         o_constr.datalen = o->arr_len;
16166         if (o_constr.datalen > 0)
16167                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
16168         else
16169                 o_constr.data = NULL;
16170         int8_tArray* o_vals = (void*) o->elems;
16171         for (size_t i = 0; i < o_constr.datalen; i++) {
16172                 int8_tArray o_conv_8 = o_vals[i];
16173                 LDKThirtyTwoBytes o_conv_8_ref;
16174                 CHECK(o_conv_8->arr_len == 32);
16175                 memcpy(o_conv_8_ref.data, o_conv_8->elems, 32); FREE(o_conv_8);
16176                 o_constr.data[i] = o_conv_8_ref;
16177         }
16178         FREE(o);
16179         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16180         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_some(o_constr);
16181         int64_t ret_ref = tag_ptr(ret_copy, true);
16182         return ret_ref;
16183 }
16184
16185 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_none() {
16186         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16187         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_none();
16188         int64_t ret_ref = tag_ptr(ret_copy, true);
16189         return ret_ref;
16190 }
16191
16192 void  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_free(int64_t _res) {
16193         if (!ptr_is_owned(_res)) return;
16194         void* _res_ptr = untag_ptr(_res);
16195         CHECK_ACCESS(_res_ptr);
16196         LDKCOption_CVec_ThirtyTwoBytesZZ _res_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(_res_ptr);
16197         FREE(untag_ptr(_res));
16198         COption_CVec_ThirtyTwoBytesZZ_free(_res_conv);
16199 }
16200
16201 static inline uint64_t COption_CVec_ThirtyTwoBytesZZ_clone_ptr(LDKCOption_CVec_ThirtyTwoBytesZZ *NONNULL_PTR arg) {
16202         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16203         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_clone(arg);
16204         int64_t ret_ref = tag_ptr(ret_copy, true);
16205         return ret_ref;
16206 }
16207 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_clone_ptr(int64_t arg) {
16208         LDKCOption_CVec_ThirtyTwoBytesZZ* arg_conv = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(arg);
16209         int64_t ret_conv = COption_CVec_ThirtyTwoBytesZZ_clone_ptr(arg_conv);
16210         return ret_conv;
16211 }
16212
16213 int64_t  CS_LDK_COption_CVec_ThirtyTwoBytesZZ_clone(int64_t orig) {
16214         LDKCOption_CVec_ThirtyTwoBytesZZ* orig_conv = (LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(orig);
16215         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
16216         *ret_copy = COption_CVec_ThirtyTwoBytesZZ_clone(orig_conv);
16217         int64_t ret_ref = tag_ptr(ret_copy, true);
16218         return ret_ref;
16219 }
16220
16221 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_ok(int8_tArray o) {
16222         LDKThirtyTwoBytes o_ref;
16223         CHECK(o->arr_len == 32);
16224         memcpy(o_ref.data, o->elems, 32); FREE(o);
16225         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16226         *ret_conv = CResult_ThirtyTwoBytesNoneZ_ok(o_ref);
16227         return tag_ptr(ret_conv, true);
16228 }
16229
16230 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_err() {
16231         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16232         *ret_conv = CResult_ThirtyTwoBytesNoneZ_err();
16233         return tag_ptr(ret_conv, true);
16234 }
16235
16236 jboolean  CS_LDK_CResult_ThirtyTwoBytesNoneZ_is_ok(int64_t o) {
16237         LDKCResult_ThirtyTwoBytesNoneZ* o_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(o);
16238         jboolean ret_conv = CResult_ThirtyTwoBytesNoneZ_is_ok(o_conv);
16239         return ret_conv;
16240 }
16241
16242 void  CS_LDK_CResult_ThirtyTwoBytesNoneZ_free(int64_t _res) {
16243         if (!ptr_is_owned(_res)) return;
16244         void* _res_ptr = untag_ptr(_res);
16245         CHECK_ACCESS(_res_ptr);
16246         LDKCResult_ThirtyTwoBytesNoneZ _res_conv = *(LDKCResult_ThirtyTwoBytesNoneZ*)(_res_ptr);
16247         FREE(untag_ptr(_res));
16248         CResult_ThirtyTwoBytesNoneZ_free(_res_conv);
16249 }
16250
16251 static inline uint64_t CResult_ThirtyTwoBytesNoneZ_clone_ptr(LDKCResult_ThirtyTwoBytesNoneZ *NONNULL_PTR arg) {
16252         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16253         *ret_conv = CResult_ThirtyTwoBytesNoneZ_clone(arg);
16254         return tag_ptr(ret_conv, true);
16255 }
16256 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_clone_ptr(int64_t arg) {
16257         LDKCResult_ThirtyTwoBytesNoneZ* arg_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(arg);
16258         int64_t ret_conv = CResult_ThirtyTwoBytesNoneZ_clone_ptr(arg_conv);
16259         return ret_conv;
16260 }
16261
16262 int64_t  CS_LDK_CResult_ThirtyTwoBytesNoneZ_clone(int64_t orig) {
16263         LDKCResult_ThirtyTwoBytesNoneZ* orig_conv = (LDKCResult_ThirtyTwoBytesNoneZ*)untag_ptr(orig);
16264         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
16265         *ret_conv = CResult_ThirtyTwoBytesNoneZ_clone(orig_conv);
16266         return tag_ptr(ret_conv, true);
16267 }
16268
16269 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_ok(int64_t o) {
16270         LDKBlindedPayInfo o_conv;
16271         o_conv.inner = untag_ptr(o);
16272         o_conv.is_owned = ptr_is_owned(o);
16273         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16274         o_conv = BlindedPayInfo_clone(&o_conv);
16275         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16276         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_ok(o_conv);
16277         return tag_ptr(ret_conv, true);
16278 }
16279
16280 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_err(int64_t e) {
16281         void* e_ptr = untag_ptr(e);
16282         CHECK_ACCESS(e_ptr);
16283         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16284         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16285         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16286         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_err(e_conv);
16287         return tag_ptr(ret_conv, true);
16288 }
16289
16290 jboolean  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_is_ok(int64_t o) {
16291         LDKCResult_BlindedPayInfoDecodeErrorZ* o_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(o);
16292         jboolean ret_conv = CResult_BlindedPayInfoDecodeErrorZ_is_ok(o_conv);
16293         return ret_conv;
16294 }
16295
16296 void  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_free(int64_t _res) {
16297         if (!ptr_is_owned(_res)) return;
16298         void* _res_ptr = untag_ptr(_res);
16299         CHECK_ACCESS(_res_ptr);
16300         LDKCResult_BlindedPayInfoDecodeErrorZ _res_conv = *(LDKCResult_BlindedPayInfoDecodeErrorZ*)(_res_ptr);
16301         FREE(untag_ptr(_res));
16302         CResult_BlindedPayInfoDecodeErrorZ_free(_res_conv);
16303 }
16304
16305 static inline uint64_t CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(LDKCResult_BlindedPayInfoDecodeErrorZ *NONNULL_PTR arg) {
16306         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16307         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(arg);
16308         return tag_ptr(ret_conv, true);
16309 }
16310 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(int64_t arg) {
16311         LDKCResult_BlindedPayInfoDecodeErrorZ* arg_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(arg);
16312         int64_t ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone_ptr(arg_conv);
16313         return ret_conv;
16314 }
16315
16316 int64_t  CS_LDK_CResult_BlindedPayInfoDecodeErrorZ_clone(int64_t orig) {
16317         LDKCResult_BlindedPayInfoDecodeErrorZ* orig_conv = (LDKCResult_BlindedPayInfoDecodeErrorZ*)untag_ptr(orig);
16318         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
16319         *ret_conv = CResult_BlindedPayInfoDecodeErrorZ_clone(orig_conv);
16320         return tag_ptr(ret_conv, true);
16321 }
16322
16323 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(int64_t o) {
16324         LDKDelayedPaymentOutputDescriptor o_conv;
16325         o_conv.inner = untag_ptr(o);
16326         o_conv.is_owned = ptr_is_owned(o);
16327         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16328         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
16329         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16330         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16331         return tag_ptr(ret_conv, true);
16332 }
16333
16334 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(int64_t e) {
16335         void* e_ptr = untag_ptr(e);
16336         CHECK_ACCESS(e_ptr);
16337         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16338         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16339         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16340         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16341         return tag_ptr(ret_conv, true);
16342 }
16343
16344 jboolean  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(int64_t o) {
16345         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
16346         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16347         return ret_conv;
16348 }
16349
16350 void  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(int64_t _res) {
16351         if (!ptr_is_owned(_res)) return;
16352         void* _res_ptr = untag_ptr(_res);
16353         CHECK_ACCESS(_res_ptr);
16354         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16355         FREE(untag_ptr(_res));
16356         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16357 }
16358
16359 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16360         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16361         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16362         return tag_ptr(ret_conv, true);
16363 }
16364 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16365         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
16366         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16367         return ret_conv;
16368 }
16369
16370 int64_t  CS_LDK_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(int64_t orig) {
16371         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
16372         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
16373         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16374         return tag_ptr(ret_conv, true);
16375 }
16376
16377 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(int64_t o) {
16378         LDKStaticPaymentOutputDescriptor o_conv;
16379         o_conv.inner = untag_ptr(o);
16380         o_conv.is_owned = ptr_is_owned(o);
16381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16382         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
16383         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16384         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
16385         return tag_ptr(ret_conv, true);
16386 }
16387
16388 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(int64_t e) {
16389         void* e_ptr = untag_ptr(e);
16390         CHECK_ACCESS(e_ptr);
16391         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16392         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16393         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16394         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
16395         return tag_ptr(ret_conv, true);
16396 }
16397
16398 jboolean  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(int64_t o) {
16399         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
16400         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16401         return ret_conv;
16402 }
16403
16404 void  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(int64_t _res) {
16405         if (!ptr_is_owned(_res)) return;
16406         void* _res_ptr = untag_ptr(_res);
16407         CHECK_ACCESS(_res_ptr);
16408         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
16409         FREE(untag_ptr(_res));
16410         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
16411 }
16412
16413 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16414         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16415         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
16416         return tag_ptr(ret_conv, true);
16417 }
16418 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16419         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
16420         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16421         return ret_conv;
16422 }
16423
16424 int64_t  CS_LDK_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(int64_t orig) {
16425         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
16426         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
16427         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
16428         return tag_ptr(ret_conv, true);
16429 }
16430
16431 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(int64_t o) {
16432         void* o_ptr = untag_ptr(o);
16433         CHECK_ACCESS(o_ptr);
16434         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
16435         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
16436         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16437         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
16438         return tag_ptr(ret_conv, true);
16439 }
16440
16441 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_err(int64_t e) {
16442         void* e_ptr = untag_ptr(e);
16443         CHECK_ACCESS(e_ptr);
16444         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16445         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16446         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16447         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
16448         return tag_ptr(ret_conv, true);
16449 }
16450
16451 jboolean  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(int64_t o) {
16452         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
16453         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
16454         return ret_conv;
16455 }
16456
16457 void  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_free(int64_t _res) {
16458         if (!ptr_is_owned(_res)) return;
16459         void* _res_ptr = untag_ptr(_res);
16460         CHECK_ACCESS(_res_ptr);
16461         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
16462         FREE(untag_ptr(_res));
16463         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
16464 }
16465
16466 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16467         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16468         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
16469         return tag_ptr(ret_conv, true);
16470 }
16471 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16472         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
16473         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16474         return ret_conv;
16475 }
16476
16477 int64_t  CS_LDK_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(int64_t orig) {
16478         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
16479         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
16480         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
16481         return tag_ptr(ret_conv, true);
16482 }
16483
16484 void  CS_LDK_CVec_SpendableOutputDescriptorZ_free(int64_tArray _res) {
16485         LDKCVec_SpendableOutputDescriptorZ _res_constr;
16486         _res_constr.datalen = _res->arr_len;
16487         if (_res_constr.datalen > 0)
16488                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16489         else
16490                 _res_constr.data = NULL;
16491         int64_t* _res_vals = _res->elems;
16492         for (size_t b = 0; b < _res_constr.datalen; b++) {
16493                 int64_t _res_conv_27 = _res_vals[b];
16494                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
16495                 CHECK_ACCESS(_res_conv_27_ptr);
16496                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
16497                 FREE(untag_ptr(_res_conv_27));
16498                 _res_constr.data[b] = _res_conv_27_conv;
16499         }
16500         FREE(_res);
16501         CVec_SpendableOutputDescriptorZ_free(_res_constr);
16502 }
16503
16504 void  CS_LDK_CVec_TxOutZ_free(int64_tArray _res) {
16505         LDKCVec_TxOutZ _res_constr;
16506         _res_constr.datalen = _res->arr_len;
16507         if (_res_constr.datalen > 0)
16508                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
16509         else
16510                 _res_constr.data = NULL;
16511         int64_t* _res_vals = _res->elems;
16512         for (size_t h = 0; h < _res_constr.datalen; h++) {
16513                 int64_t _res_conv_7 = _res_vals[h];
16514                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
16515                 CHECK_ACCESS(_res_conv_7_ptr);
16516                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
16517                 FREE(untag_ptr(_res_conv_7));
16518                 _res_constr.data[h] = _res_conv_7_conv;
16519         }
16520         FREE(_res);
16521         CVec_TxOutZ_free(_res_constr);
16522 }
16523
16524 int64_t  CS_LDK_COption_u32Z_some(int32_t o) {
16525         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16526         *ret_copy = COption_u32Z_some(o);
16527         int64_t ret_ref = tag_ptr(ret_copy, true);
16528         return ret_ref;
16529 }
16530
16531 int64_t  CS_LDK_COption_u32Z_none() {
16532         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16533         *ret_copy = COption_u32Z_none();
16534         int64_t ret_ref = tag_ptr(ret_copy, true);
16535         return ret_ref;
16536 }
16537
16538 void  CS_LDK_COption_u32Z_free(int64_t _res) {
16539         if (!ptr_is_owned(_res)) return;
16540         void* _res_ptr = untag_ptr(_res);
16541         CHECK_ACCESS(_res_ptr);
16542         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
16543         FREE(untag_ptr(_res));
16544         COption_u32Z_free(_res_conv);
16545 }
16546
16547 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
16548         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16549         *ret_copy = COption_u32Z_clone(arg);
16550         int64_t ret_ref = tag_ptr(ret_copy, true);
16551         return ret_ref;
16552 }
16553 int64_t  CS_LDK_COption_u32Z_clone_ptr(int64_t arg) {
16554         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
16555         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
16556         return ret_conv;
16557 }
16558
16559 int64_t  CS_LDK_COption_u32Z_clone(int64_t orig) {
16560         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
16561         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16562         *ret_copy = COption_u32Z_clone(orig_conv);
16563         int64_t ret_ref = tag_ptr(ret_copy, true);
16564         return ret_ref;
16565 }
16566
16567 static inline uint64_t C2Tuple_CVec_u8ZusizeZ_clone_ptr(LDKC2Tuple_CVec_u8ZusizeZ *NONNULL_PTR arg) {
16568         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
16569         *ret_conv = C2Tuple_CVec_u8ZusizeZ_clone(arg);
16570         return tag_ptr(ret_conv, true);
16571 }
16572 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_clone_ptr(int64_t arg) {
16573         LDKC2Tuple_CVec_u8ZusizeZ* arg_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(arg);
16574         int64_t ret_conv = C2Tuple_CVec_u8ZusizeZ_clone_ptr(arg_conv);
16575         return ret_conv;
16576 }
16577
16578 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_clone(int64_t orig) {
16579         LDKC2Tuple_CVec_u8ZusizeZ* orig_conv = (LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(orig);
16580         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
16581         *ret_conv = C2Tuple_CVec_u8ZusizeZ_clone(orig_conv);
16582         return tag_ptr(ret_conv, true);
16583 }
16584
16585 int64_t  CS_LDK_C2Tuple_CVec_u8ZusizeZ_new(int8_tArray a, int64_t b) {
16586         LDKCVec_u8Z a_ref;
16587         a_ref.datalen = a->arr_len;
16588         a_ref.data = MALLOC(a_ref.datalen, "LDKCVec_u8Z Bytes");
16589         memcpy(a_ref.data, a->elems, a_ref.datalen); FREE(a);
16590         LDKC2Tuple_CVec_u8ZusizeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_CVec_u8ZusizeZ), "LDKC2Tuple_CVec_u8ZusizeZ");
16591         *ret_conv = C2Tuple_CVec_u8ZusizeZ_new(a_ref, b);
16592         return tag_ptr(ret_conv, true);
16593 }
16594
16595 void  CS_LDK_C2Tuple_CVec_u8ZusizeZ_free(int64_t _res) {
16596         if (!ptr_is_owned(_res)) return;
16597         void* _res_ptr = untag_ptr(_res);
16598         CHECK_ACCESS(_res_ptr);
16599         LDKC2Tuple_CVec_u8ZusizeZ _res_conv = *(LDKC2Tuple_CVec_u8ZusizeZ*)(_res_ptr);
16600         FREE(untag_ptr(_res));
16601         C2Tuple_CVec_u8ZusizeZ_free(_res_conv);
16602 }
16603
16604 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_ok(int64_t o) {
16605         void* o_ptr = untag_ptr(o);
16606         CHECK_ACCESS(o_ptr);
16607         LDKC2Tuple_CVec_u8ZusizeZ o_conv = *(LDKC2Tuple_CVec_u8ZusizeZ*)(o_ptr);
16608         o_conv = C2Tuple_CVec_u8ZusizeZ_clone((LDKC2Tuple_CVec_u8ZusizeZ*)untag_ptr(o));
16609         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16610         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_ok(o_conv);
16611         return tag_ptr(ret_conv, true);
16612 }
16613
16614 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_err() {
16615         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16616         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_err();
16617         return tag_ptr(ret_conv, true);
16618 }
16619
16620 jboolean  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_is_ok(int64_t o) {
16621         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* o_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(o);
16622         jboolean ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_is_ok(o_conv);
16623         return ret_conv;
16624 }
16625
16626 void  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_free(int64_t _res) {
16627         if (!ptr_is_owned(_res)) return;
16628         void* _res_ptr = untag_ptr(_res);
16629         CHECK_ACCESS(_res_ptr);
16630         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ _res_conv = *(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)(_res_ptr);
16631         FREE(untag_ptr(_res));
16632         CResult_C2Tuple_CVec_u8ZusizeZNoneZ_free(_res_conv);
16633 }
16634
16635 static inline uint64_t CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone_ptr(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ *NONNULL_PTR arg) {
16636         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16637         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone(arg);
16638         return tag_ptr(ret_conv, true);
16639 }
16640 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone_ptr(int64_t arg) {
16641         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* arg_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(arg);
16642         int64_t ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone_ptr(arg_conv);
16643         return ret_conv;
16644 }
16645
16646 int64_t  CS_LDK_CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone(int64_t orig) {
16647         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* orig_conv = (LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ*)untag_ptr(orig);
16648         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
16649         *ret_conv = CResult_C2Tuple_CVec_u8ZusizeZNoneZ_clone(orig_conv);
16650         return tag_ptr(ret_conv, true);
16651 }
16652
16653 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_ok(int64_t o) {
16654         LDKChannelDerivationParameters o_conv;
16655         o_conv.inner = untag_ptr(o);
16656         o_conv.is_owned = ptr_is_owned(o);
16657         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16658         o_conv = ChannelDerivationParameters_clone(&o_conv);
16659         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16660         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_ok(o_conv);
16661         return tag_ptr(ret_conv, true);
16662 }
16663
16664 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_err(int64_t e) {
16665         void* e_ptr = untag_ptr(e);
16666         CHECK_ACCESS(e_ptr);
16667         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16668         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16669         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16670         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_err(e_conv);
16671         return tag_ptr(ret_conv, true);
16672 }
16673
16674 jboolean  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_is_ok(int64_t o) {
16675         LDKCResult_ChannelDerivationParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(o);
16676         jboolean ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_is_ok(o_conv);
16677         return ret_conv;
16678 }
16679
16680 void  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_free(int64_t _res) {
16681         if (!ptr_is_owned(_res)) return;
16682         void* _res_ptr = untag_ptr(_res);
16683         CHECK_ACCESS(_res_ptr);
16684         LDKCResult_ChannelDerivationParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelDerivationParametersDecodeErrorZ*)(_res_ptr);
16685         FREE(untag_ptr(_res));
16686         CResult_ChannelDerivationParametersDecodeErrorZ_free(_res_conv);
16687 }
16688
16689 static inline uint64_t CResult_ChannelDerivationParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelDerivationParametersDecodeErrorZ *NONNULL_PTR arg) {
16690         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16691         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_clone(arg);
16692         return tag_ptr(ret_conv, true);
16693 }
16694 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_clone_ptr(int64_t arg) {
16695         LDKCResult_ChannelDerivationParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(arg);
16696         int64_t ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_clone_ptr(arg_conv);
16697         return ret_conv;
16698 }
16699
16700 int64_t  CS_LDK_CResult_ChannelDerivationParametersDecodeErrorZ_clone(int64_t orig) {
16701         LDKCResult_ChannelDerivationParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelDerivationParametersDecodeErrorZ*)untag_ptr(orig);
16702         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
16703         *ret_conv = CResult_ChannelDerivationParametersDecodeErrorZ_clone(orig_conv);
16704         return tag_ptr(ret_conv, true);
16705 }
16706
16707 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_ok(int64_t o) {
16708         LDKHTLCDescriptor o_conv;
16709         o_conv.inner = untag_ptr(o);
16710         o_conv.is_owned = ptr_is_owned(o);
16711         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16712         o_conv = HTLCDescriptor_clone(&o_conv);
16713         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16714         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_ok(o_conv);
16715         return tag_ptr(ret_conv, true);
16716 }
16717
16718 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_err(int64_t e) {
16719         void* e_ptr = untag_ptr(e);
16720         CHECK_ACCESS(e_ptr);
16721         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16722         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16723         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16724         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_err(e_conv);
16725         return tag_ptr(ret_conv, true);
16726 }
16727
16728 jboolean  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_is_ok(int64_t o) {
16729         LDKCResult_HTLCDescriptorDecodeErrorZ* o_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(o);
16730         jboolean ret_conv = CResult_HTLCDescriptorDecodeErrorZ_is_ok(o_conv);
16731         return ret_conv;
16732 }
16733
16734 void  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_free(int64_t _res) {
16735         if (!ptr_is_owned(_res)) return;
16736         void* _res_ptr = untag_ptr(_res);
16737         CHECK_ACCESS(_res_ptr);
16738         LDKCResult_HTLCDescriptorDecodeErrorZ _res_conv = *(LDKCResult_HTLCDescriptorDecodeErrorZ*)(_res_ptr);
16739         FREE(untag_ptr(_res));
16740         CResult_HTLCDescriptorDecodeErrorZ_free(_res_conv);
16741 }
16742
16743 static inline uint64_t CResult_HTLCDescriptorDecodeErrorZ_clone_ptr(LDKCResult_HTLCDescriptorDecodeErrorZ *NONNULL_PTR arg) {
16744         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16745         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_clone(arg);
16746         return tag_ptr(ret_conv, true);
16747 }
16748 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_clone_ptr(int64_t arg) {
16749         LDKCResult_HTLCDescriptorDecodeErrorZ* arg_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(arg);
16750         int64_t ret_conv = CResult_HTLCDescriptorDecodeErrorZ_clone_ptr(arg_conv);
16751         return ret_conv;
16752 }
16753
16754 int64_t  CS_LDK_CResult_HTLCDescriptorDecodeErrorZ_clone(int64_t orig) {
16755         LDKCResult_HTLCDescriptorDecodeErrorZ* orig_conv = (LDKCResult_HTLCDescriptorDecodeErrorZ*)untag_ptr(orig);
16756         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
16757         *ret_conv = CResult_HTLCDescriptorDecodeErrorZ_clone(orig_conv);
16758         return tag_ptr(ret_conv, true);
16759 }
16760
16761 int64_t  CS_LDK_CResult_NoneNoneZ_ok() {
16762         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16763         *ret_conv = CResult_NoneNoneZ_ok();
16764         return tag_ptr(ret_conv, true);
16765 }
16766
16767 int64_t  CS_LDK_CResult_NoneNoneZ_err() {
16768         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16769         *ret_conv = CResult_NoneNoneZ_err();
16770         return tag_ptr(ret_conv, true);
16771 }
16772
16773 jboolean  CS_LDK_CResult_NoneNoneZ_is_ok(int64_t o) {
16774         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
16775         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
16776         return ret_conv;
16777 }
16778
16779 void  CS_LDK_CResult_NoneNoneZ_free(int64_t _res) {
16780         if (!ptr_is_owned(_res)) return;
16781         void* _res_ptr = untag_ptr(_res);
16782         CHECK_ACCESS(_res_ptr);
16783         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
16784         FREE(untag_ptr(_res));
16785         CResult_NoneNoneZ_free(_res_conv);
16786 }
16787
16788 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
16789         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16790         *ret_conv = CResult_NoneNoneZ_clone(arg);
16791         return tag_ptr(ret_conv, true);
16792 }
16793 int64_t  CS_LDK_CResult_NoneNoneZ_clone_ptr(int64_t arg) {
16794         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
16795         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
16796         return ret_conv;
16797 }
16798
16799 int64_t  CS_LDK_CResult_NoneNoneZ_clone(int64_t orig) {
16800         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
16801         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
16802         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
16803         return tag_ptr(ret_conv, true);
16804 }
16805
16806 void  CS_LDK_CVec_ECDSASignatureZ_free(ptrArray _res) {
16807         LDKCVec_ECDSASignatureZ _res_constr;
16808         _res_constr.datalen = _res->arr_len;
16809         if (_res_constr.datalen > 0)
16810                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
16811         else
16812                 _res_constr.data = NULL;
16813         int8_tArray* _res_vals = (void*) _res->elems;
16814         for (size_t i = 0; i < _res_constr.datalen; i++) {
16815                 int8_tArray _res_conv_8 = _res_vals[i];
16816                 LDKECDSASignature _res_conv_8_ref;
16817                 CHECK(_res_conv_8->arr_len == 64);
16818                 memcpy(_res_conv_8_ref.compact_form, _res_conv_8->elems, 64); FREE(_res_conv_8);
16819                 _res_constr.data[i] = _res_conv_8_ref;
16820         }
16821         FREE(_res);
16822         CVec_ECDSASignatureZ_free(_res_constr);
16823 }
16824
16825 static inline uint64_t C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone_ptr(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ *NONNULL_PTR arg) {
16826         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
16827         *ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(arg);
16828         return tag_ptr(ret_conv, true);
16829 }
16830 int64_t  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone_ptr(int64_t arg) {
16831         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* arg_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(arg);
16832         int64_t ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone_ptr(arg_conv);
16833         return ret_conv;
16834 }
16835
16836 int64_t  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(int64_t orig) {
16837         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* orig_conv = (LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(orig);
16838         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
16839         *ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone(orig_conv);
16840         return tag_ptr(ret_conv, true);
16841 }
16842
16843 int64_t  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_new(int8_tArray a, ptrArray b) {
16844         LDKECDSASignature a_ref;
16845         CHECK(a->arr_len == 64);
16846         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
16847         LDKCVec_ECDSASignatureZ b_constr;
16848         b_constr.datalen = b->arr_len;
16849         if (b_constr.datalen > 0)
16850                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
16851         else
16852                 b_constr.data = NULL;
16853         int8_tArray* b_vals = (void*) b->elems;
16854         for (size_t i = 0; i < b_constr.datalen; i++) {
16855                 int8_tArray b_conv_8 = b_vals[i];
16856                 LDKECDSASignature b_conv_8_ref;
16857                 CHECK(b_conv_8->arr_len == 64);
16858                 memcpy(b_conv_8_ref.compact_form, b_conv_8->elems, 64); FREE(b_conv_8);
16859                 b_constr.data[i] = b_conv_8_ref;
16860         }
16861         FREE(b);
16862         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ), "LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ");
16863         *ret_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_new(a_ref, b_constr);
16864         return tag_ptr(ret_conv, true);
16865 }
16866
16867 void  CS_LDK_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_free(int64_t _res) {
16868         if (!ptr_is_owned(_res)) return;
16869         void* _res_ptr = untag_ptr(_res);
16870         CHECK_ACCESS(_res_ptr);
16871         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ _res_conv = *(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)(_res_ptr);
16872         FREE(untag_ptr(_res));
16873         C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_free(_res_conv);
16874 }
16875
16876 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_ok(int64_t o) {
16877         void* o_ptr = untag_ptr(o);
16878         CHECK_ACCESS(o_ptr);
16879         LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ o_conv = *(LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)(o_ptr);
16880         o_conv = C2Tuple_ECDSASignatureCVec_ECDSASignatureZZ_clone((LDKC2Tuple_ECDSASignatureCVec_ECDSASignatureZZ*)untag_ptr(o));
16881         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16882         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_ok(o_conv);
16883         return tag_ptr(ret_conv, true);
16884 }
16885
16886 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_err() {
16887         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16888         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_err();
16889         return tag_ptr(ret_conv, true);
16890 }
16891
16892 jboolean  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_is_ok(int64_t o) {
16893         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(o);
16894         jboolean ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_is_ok(o_conv);
16895         return ret_conv;
16896 }
16897
16898 void  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_free(int64_t _res) {
16899         if (!ptr_is_owned(_res)) return;
16900         void* _res_ptr = untag_ptr(_res);
16901         CHECK_ACCESS(_res_ptr);
16902         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)(_res_ptr);
16903         FREE(untag_ptr(_res));
16904         CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_free(_res_conv);
16905 }
16906
16907 static inline uint64_t CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ *NONNULL_PTR arg) {
16908         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16909         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(arg);
16910         return tag_ptr(ret_conv, true);
16911 }
16912 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone_ptr(int64_t arg) {
16913         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(arg);
16914         int64_t ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone_ptr(arg_conv);
16915         return ret_conv;
16916 }
16917
16918 int64_t  CS_LDK_CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(int64_t orig) {
16919         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ*)untag_ptr(orig);
16920         LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ), "LDKCResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ");
16921         *ret_conv = CResult_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ_clone(orig_conv);
16922         return tag_ptr(ret_conv, true);
16923 }
16924
16925 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_ok(int8_tArray o) {
16926         LDKECDSASignature o_ref;
16927         CHECK(o->arr_len == 64);
16928         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
16929         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16930         *ret_conv = CResult_ECDSASignatureNoneZ_ok(o_ref);
16931         return tag_ptr(ret_conv, true);
16932 }
16933
16934 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_err() {
16935         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16936         *ret_conv = CResult_ECDSASignatureNoneZ_err();
16937         return tag_ptr(ret_conv, true);
16938 }
16939
16940 jboolean  CS_LDK_CResult_ECDSASignatureNoneZ_is_ok(int64_t o) {
16941         LDKCResult_ECDSASignatureNoneZ* o_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(o);
16942         jboolean ret_conv = CResult_ECDSASignatureNoneZ_is_ok(o_conv);
16943         return ret_conv;
16944 }
16945
16946 void  CS_LDK_CResult_ECDSASignatureNoneZ_free(int64_t _res) {
16947         if (!ptr_is_owned(_res)) return;
16948         void* _res_ptr = untag_ptr(_res);
16949         CHECK_ACCESS(_res_ptr);
16950         LDKCResult_ECDSASignatureNoneZ _res_conv = *(LDKCResult_ECDSASignatureNoneZ*)(_res_ptr);
16951         FREE(untag_ptr(_res));
16952         CResult_ECDSASignatureNoneZ_free(_res_conv);
16953 }
16954
16955 static inline uint64_t CResult_ECDSASignatureNoneZ_clone_ptr(LDKCResult_ECDSASignatureNoneZ *NONNULL_PTR arg) {
16956         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16957         *ret_conv = CResult_ECDSASignatureNoneZ_clone(arg);
16958         return tag_ptr(ret_conv, true);
16959 }
16960 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_clone_ptr(int64_t arg) {
16961         LDKCResult_ECDSASignatureNoneZ* arg_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(arg);
16962         int64_t ret_conv = CResult_ECDSASignatureNoneZ_clone_ptr(arg_conv);
16963         return ret_conv;
16964 }
16965
16966 int64_t  CS_LDK_CResult_ECDSASignatureNoneZ_clone(int64_t orig) {
16967         LDKCResult_ECDSASignatureNoneZ* orig_conv = (LDKCResult_ECDSASignatureNoneZ*)untag_ptr(orig);
16968         LDKCResult_ECDSASignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ECDSASignatureNoneZ), "LDKCResult_ECDSASignatureNoneZ");
16969         *ret_conv = CResult_ECDSASignatureNoneZ_clone(orig_conv);
16970         return tag_ptr(ret_conv, true);
16971 }
16972
16973 int64_t  CS_LDK_CResult_PublicKeyNoneZ_ok(int8_tArray o) {
16974         LDKPublicKey o_ref;
16975         CHECK(o->arr_len == 33);
16976         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
16977         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
16978         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
16979         return tag_ptr(ret_conv, true);
16980 }
16981
16982 int64_t  CS_LDK_CResult_PublicKeyNoneZ_err() {
16983         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
16984         *ret_conv = CResult_PublicKeyNoneZ_err();
16985         return tag_ptr(ret_conv, true);
16986 }
16987
16988 jboolean  CS_LDK_CResult_PublicKeyNoneZ_is_ok(int64_t o) {
16989         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
16990         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
16991         return ret_conv;
16992 }
16993
16994 void  CS_LDK_CResult_PublicKeyNoneZ_free(int64_t _res) {
16995         if (!ptr_is_owned(_res)) return;
16996         void* _res_ptr = untag_ptr(_res);
16997         CHECK_ACCESS(_res_ptr);
16998         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
16999         FREE(untag_ptr(_res));
17000         CResult_PublicKeyNoneZ_free(_res_conv);
17001 }
17002
17003 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
17004         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
17005         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
17006         return tag_ptr(ret_conv, true);
17007 }
17008 int64_t  CS_LDK_CResult_PublicKeyNoneZ_clone_ptr(int64_t arg) {
17009         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
17010         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
17011         return ret_conv;
17012 }
17013
17014 int64_t  CS_LDK_CResult_PublicKeyNoneZ_clone(int64_t orig) {
17015         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
17016         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
17017         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
17018         return tag_ptr(ret_conv, true);
17019 }
17020
17021 int64_t  CS_LDK_COption_BigEndianScalarZ_some(int64_t o) {
17022         void* o_ptr = untag_ptr(o);
17023         CHECK_ACCESS(o_ptr);
17024         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
17025         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
17026         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17027         *ret_copy = COption_BigEndianScalarZ_some(o_conv);
17028         int64_t ret_ref = tag_ptr(ret_copy, true);
17029         return ret_ref;
17030 }
17031
17032 int64_t  CS_LDK_COption_BigEndianScalarZ_none() {
17033         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17034         *ret_copy = COption_BigEndianScalarZ_none();
17035         int64_t ret_ref = tag_ptr(ret_copy, true);
17036         return ret_ref;
17037 }
17038
17039 void  CS_LDK_COption_BigEndianScalarZ_free(int64_t _res) {
17040         if (!ptr_is_owned(_res)) return;
17041         void* _res_ptr = untag_ptr(_res);
17042         CHECK_ACCESS(_res_ptr);
17043         LDKCOption_BigEndianScalarZ _res_conv = *(LDKCOption_BigEndianScalarZ*)(_res_ptr);
17044         FREE(untag_ptr(_res));
17045         COption_BigEndianScalarZ_free(_res_conv);
17046 }
17047
17048 static inline uint64_t COption_BigEndianScalarZ_clone_ptr(LDKCOption_BigEndianScalarZ *NONNULL_PTR arg) {
17049         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17050         *ret_copy = COption_BigEndianScalarZ_clone(arg);
17051         int64_t ret_ref = tag_ptr(ret_copy, true);
17052         return ret_ref;
17053 }
17054 int64_t  CS_LDK_COption_BigEndianScalarZ_clone_ptr(int64_t arg) {
17055         LDKCOption_BigEndianScalarZ* arg_conv = (LDKCOption_BigEndianScalarZ*)untag_ptr(arg);
17056         int64_t ret_conv = COption_BigEndianScalarZ_clone_ptr(arg_conv);
17057         return ret_conv;
17058 }
17059
17060 int64_t  CS_LDK_COption_BigEndianScalarZ_clone(int64_t orig) {
17061         LDKCOption_BigEndianScalarZ* orig_conv = (LDKCOption_BigEndianScalarZ*)untag_ptr(orig);
17062         LDKCOption_BigEndianScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_BigEndianScalarZ), "LDKCOption_BigEndianScalarZ");
17063         *ret_copy = COption_BigEndianScalarZ_clone(orig_conv);
17064         int64_t ret_ref = tag_ptr(ret_copy, true);
17065         return ret_ref;
17066 }
17067
17068 void  CS_LDK_CVec_U5Z_free(ptrArray _res) {
17069         LDKCVec_U5Z _res_constr;
17070         _res_constr.datalen = _res->arr_len;
17071         if (_res_constr.datalen > 0)
17072                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
17073         else
17074                 _res_constr.data = NULL;
17075         int8_t* _res_vals = (void*) _res->elems;
17076         for (size_t h = 0; h < _res_constr.datalen; h++) {
17077                 int8_t _res_conv_7 = _res_vals[h];
17078                 
17079                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
17080         }
17081         FREE(_res);
17082         CVec_U5Z_free(_res_constr);
17083 }
17084
17085 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
17086         LDKRecoverableSignature o_ref;
17087         CHECK(o->arr_len == 68);
17088         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
17089         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17090         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
17091         return tag_ptr(ret_conv, true);
17092 }
17093
17094 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_err() {
17095         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17096         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
17097         return tag_ptr(ret_conv, true);
17098 }
17099
17100 jboolean  CS_LDK_CResult_RecoverableSignatureNoneZ_is_ok(int64_t o) {
17101         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
17102         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
17103         return ret_conv;
17104 }
17105
17106 void  CS_LDK_CResult_RecoverableSignatureNoneZ_free(int64_t _res) {
17107         if (!ptr_is_owned(_res)) return;
17108         void* _res_ptr = untag_ptr(_res);
17109         CHECK_ACCESS(_res_ptr);
17110         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
17111         FREE(untag_ptr(_res));
17112         CResult_RecoverableSignatureNoneZ_free(_res_conv);
17113 }
17114
17115 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
17116         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17117         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
17118         return tag_ptr(ret_conv, true);
17119 }
17120 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_clone_ptr(int64_t arg) {
17121         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
17122         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
17123         return ret_conv;
17124 }
17125
17126 int64_t  CS_LDK_CResult_RecoverableSignatureNoneZ_clone(int64_t orig) {
17127         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
17128         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
17129         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
17130         return tag_ptr(ret_conv, true);
17131 }
17132
17133 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_ok(int8_tArray o) {
17134         LDKSchnorrSignature o_ref;
17135         CHECK(o->arr_len == 64);
17136         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
17137         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17138         *ret_conv = CResult_SchnorrSignatureNoneZ_ok(o_ref);
17139         return tag_ptr(ret_conv, true);
17140 }
17141
17142 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_err() {
17143         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17144         *ret_conv = CResult_SchnorrSignatureNoneZ_err();
17145         return tag_ptr(ret_conv, true);
17146 }
17147
17148 jboolean  CS_LDK_CResult_SchnorrSignatureNoneZ_is_ok(int64_t o) {
17149         LDKCResult_SchnorrSignatureNoneZ* o_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(o);
17150         jboolean ret_conv = CResult_SchnorrSignatureNoneZ_is_ok(o_conv);
17151         return ret_conv;
17152 }
17153
17154 void  CS_LDK_CResult_SchnorrSignatureNoneZ_free(int64_t _res) {
17155         if (!ptr_is_owned(_res)) return;
17156         void* _res_ptr = untag_ptr(_res);
17157         CHECK_ACCESS(_res_ptr);
17158         LDKCResult_SchnorrSignatureNoneZ _res_conv = *(LDKCResult_SchnorrSignatureNoneZ*)(_res_ptr);
17159         FREE(untag_ptr(_res));
17160         CResult_SchnorrSignatureNoneZ_free(_res_conv);
17161 }
17162
17163 static inline uint64_t CResult_SchnorrSignatureNoneZ_clone_ptr(LDKCResult_SchnorrSignatureNoneZ *NONNULL_PTR arg) {
17164         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17165         *ret_conv = CResult_SchnorrSignatureNoneZ_clone(arg);
17166         return tag_ptr(ret_conv, true);
17167 }
17168 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_clone_ptr(int64_t arg) {
17169         LDKCResult_SchnorrSignatureNoneZ* arg_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(arg);
17170         int64_t ret_conv = CResult_SchnorrSignatureNoneZ_clone_ptr(arg_conv);
17171         return ret_conv;
17172 }
17173
17174 int64_t  CS_LDK_CResult_SchnorrSignatureNoneZ_clone(int64_t orig) {
17175         LDKCResult_SchnorrSignatureNoneZ* orig_conv = (LDKCResult_SchnorrSignatureNoneZ*)untag_ptr(orig);
17176         LDKCResult_SchnorrSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SchnorrSignatureNoneZ), "LDKCResult_SchnorrSignatureNoneZ");
17177         *ret_conv = CResult_SchnorrSignatureNoneZ_clone(orig_conv);
17178         return tag_ptr(ret_conv, true);
17179 }
17180
17181 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(int64_t o) {
17182         void* o_ptr = untag_ptr(o);
17183         CHECK_ACCESS(o_ptr);
17184         LDKWriteableEcdsaChannelSigner o_conv = *(LDKWriteableEcdsaChannelSigner*)(o_ptr);
17185         if (o_conv.free == LDKWriteableEcdsaChannelSigner_JCalls_free) {
17186                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17187                 LDKWriteableEcdsaChannelSigner_JCalls_cloned(&o_conv);
17188         }
17189         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17190         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_ok(o_conv);
17191         return tag_ptr(ret_conv, true);
17192 }
17193
17194 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(int64_t e) {
17195         void* e_ptr = untag_ptr(e);
17196         CHECK_ACCESS(e_ptr);
17197         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17198         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17199         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17200         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_err(e_conv);
17201         return tag_ptr(ret_conv, true);
17202 }
17203
17204 jboolean  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(int64_t o) {
17205         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* o_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(o);
17206         jboolean ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_is_ok(o_conv);
17207         return ret_conv;
17208 }
17209
17210 void  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(int64_t _res) {
17211         if (!ptr_is_owned(_res)) return;
17212         void* _res_ptr = untag_ptr(_res);
17213         CHECK_ACCESS(_res_ptr);
17214         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ _res_conv = *(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)(_res_ptr);
17215         FREE(untag_ptr(_res));
17216         CResult_WriteableEcdsaChannelSignerDecodeErrorZ_free(_res_conv);
17217 }
17218
17219 static inline uint64_t CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ *NONNULL_PTR arg) {
17220         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17221         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(arg);
17222         return tag_ptr(ret_conv, true);
17223 }
17224 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(int64_t arg) {
17225         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* arg_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(arg);
17226         int64_t ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone_ptr(arg_conv);
17227         return ret_conv;
17228 }
17229
17230 int64_t  CS_LDK_CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(int64_t orig) {
17231         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* orig_conv = (LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ*)untag_ptr(orig);
17232         LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ), "LDKCResult_WriteableEcdsaChannelSignerDecodeErrorZ");
17233         *ret_conv = CResult_WriteableEcdsaChannelSignerDecodeErrorZ_clone(orig_conv);
17234         return tag_ptr(ret_conv, true);
17235 }
17236
17237 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_ok(int8_tArray o) {
17238         LDKCVec_u8Z o_ref;
17239         o_ref.datalen = o->arr_len;
17240         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
17241         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
17242         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17243         *ret_conv = CResult_CVec_u8ZNoneZ_ok(o_ref);
17244         return tag_ptr(ret_conv, true);
17245 }
17246
17247 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_err() {
17248         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17249         *ret_conv = CResult_CVec_u8ZNoneZ_err();
17250         return tag_ptr(ret_conv, true);
17251 }
17252
17253 jboolean  CS_LDK_CResult_CVec_u8ZNoneZ_is_ok(int64_t o) {
17254         LDKCResult_CVec_u8ZNoneZ* o_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(o);
17255         jboolean ret_conv = CResult_CVec_u8ZNoneZ_is_ok(o_conv);
17256         return ret_conv;
17257 }
17258
17259 void  CS_LDK_CResult_CVec_u8ZNoneZ_free(int64_t _res) {
17260         if (!ptr_is_owned(_res)) return;
17261         void* _res_ptr = untag_ptr(_res);
17262         CHECK_ACCESS(_res_ptr);
17263         LDKCResult_CVec_u8ZNoneZ _res_conv = *(LDKCResult_CVec_u8ZNoneZ*)(_res_ptr);
17264         FREE(untag_ptr(_res));
17265         CResult_CVec_u8ZNoneZ_free(_res_conv);
17266 }
17267
17268 static inline uint64_t CResult_CVec_u8ZNoneZ_clone_ptr(LDKCResult_CVec_u8ZNoneZ *NONNULL_PTR arg) {
17269         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17270         *ret_conv = CResult_CVec_u8ZNoneZ_clone(arg);
17271         return tag_ptr(ret_conv, true);
17272 }
17273 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_clone_ptr(int64_t arg) {
17274         LDKCResult_CVec_u8ZNoneZ* arg_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(arg);
17275         int64_t ret_conv = CResult_CVec_u8ZNoneZ_clone_ptr(arg_conv);
17276         return ret_conv;
17277 }
17278
17279 int64_t  CS_LDK_CResult_CVec_u8ZNoneZ_clone(int64_t orig) {
17280         LDKCResult_CVec_u8ZNoneZ* orig_conv = (LDKCResult_CVec_u8ZNoneZ*)untag_ptr(orig);
17281         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
17282         *ret_conv = CResult_CVec_u8ZNoneZ_clone(orig_conv);
17283         return tag_ptr(ret_conv, true);
17284 }
17285
17286 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_ok(int64_t o) {
17287         LDKShutdownScript o_conv;
17288         o_conv.inner = untag_ptr(o);
17289         o_conv.is_owned = ptr_is_owned(o);
17290         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17291         o_conv = ShutdownScript_clone(&o_conv);
17292         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17293         *ret_conv = CResult_ShutdownScriptNoneZ_ok(o_conv);
17294         return tag_ptr(ret_conv, true);
17295 }
17296
17297 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_err() {
17298         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17299         *ret_conv = CResult_ShutdownScriptNoneZ_err();
17300         return tag_ptr(ret_conv, true);
17301 }
17302
17303 jboolean  CS_LDK_CResult_ShutdownScriptNoneZ_is_ok(int64_t o) {
17304         LDKCResult_ShutdownScriptNoneZ* o_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(o);
17305         jboolean ret_conv = CResult_ShutdownScriptNoneZ_is_ok(o_conv);
17306         return ret_conv;
17307 }
17308
17309 void  CS_LDK_CResult_ShutdownScriptNoneZ_free(int64_t _res) {
17310         if (!ptr_is_owned(_res)) return;
17311         void* _res_ptr = untag_ptr(_res);
17312         CHECK_ACCESS(_res_ptr);
17313         LDKCResult_ShutdownScriptNoneZ _res_conv = *(LDKCResult_ShutdownScriptNoneZ*)(_res_ptr);
17314         FREE(untag_ptr(_res));
17315         CResult_ShutdownScriptNoneZ_free(_res_conv);
17316 }
17317
17318 static inline uint64_t CResult_ShutdownScriptNoneZ_clone_ptr(LDKCResult_ShutdownScriptNoneZ *NONNULL_PTR arg) {
17319         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17320         *ret_conv = CResult_ShutdownScriptNoneZ_clone(arg);
17321         return tag_ptr(ret_conv, true);
17322 }
17323 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_clone_ptr(int64_t arg) {
17324         LDKCResult_ShutdownScriptNoneZ* arg_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(arg);
17325         int64_t ret_conv = CResult_ShutdownScriptNoneZ_clone_ptr(arg_conv);
17326         return ret_conv;
17327 }
17328
17329 int64_t  CS_LDK_CResult_ShutdownScriptNoneZ_clone(int64_t orig) {
17330         LDKCResult_ShutdownScriptNoneZ* orig_conv = (LDKCResult_ShutdownScriptNoneZ*)untag_ptr(orig);
17331         LDKCResult_ShutdownScriptNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptNoneZ), "LDKCResult_ShutdownScriptNoneZ");
17332         *ret_conv = CResult_ShutdownScriptNoneZ_clone(orig_conv);
17333         return tag_ptr(ret_conv, true);
17334 }
17335
17336 int64_t  CS_LDK_COption_u16Z_some(int16_t o) {
17337         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17338         *ret_copy = COption_u16Z_some(o);
17339         int64_t ret_ref = tag_ptr(ret_copy, true);
17340         return ret_ref;
17341 }
17342
17343 int64_t  CS_LDK_COption_u16Z_none() {
17344         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17345         *ret_copy = COption_u16Z_none();
17346         int64_t ret_ref = tag_ptr(ret_copy, true);
17347         return ret_ref;
17348 }
17349
17350 void  CS_LDK_COption_u16Z_free(int64_t _res) {
17351         if (!ptr_is_owned(_res)) return;
17352         void* _res_ptr = untag_ptr(_res);
17353         CHECK_ACCESS(_res_ptr);
17354         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
17355         FREE(untag_ptr(_res));
17356         COption_u16Z_free(_res_conv);
17357 }
17358
17359 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
17360         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17361         *ret_copy = COption_u16Z_clone(arg);
17362         int64_t ret_ref = tag_ptr(ret_copy, true);
17363         return ret_ref;
17364 }
17365 int64_t  CS_LDK_COption_u16Z_clone_ptr(int64_t arg) {
17366         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
17367         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
17368         return ret_conv;
17369 }
17370
17371 int64_t  CS_LDK_COption_u16Z_clone(int64_t orig) {
17372         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
17373         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
17374         *ret_copy = COption_u16Z_clone(orig_conv);
17375         int64_t ret_ref = tag_ptr(ret_copy, true);
17376         return ret_ref;
17377 }
17378
17379 int64_t  CS_LDK_COption_boolZ_some(jboolean o) {
17380         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17381         *ret_copy = COption_boolZ_some(o);
17382         int64_t ret_ref = tag_ptr(ret_copy, true);
17383         return ret_ref;
17384 }
17385
17386 int64_t  CS_LDK_COption_boolZ_none() {
17387         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17388         *ret_copy = COption_boolZ_none();
17389         int64_t ret_ref = tag_ptr(ret_copy, true);
17390         return ret_ref;
17391 }
17392
17393 void  CS_LDK_COption_boolZ_free(int64_t _res) {
17394         if (!ptr_is_owned(_res)) return;
17395         void* _res_ptr = untag_ptr(_res);
17396         CHECK_ACCESS(_res_ptr);
17397         LDKCOption_boolZ _res_conv = *(LDKCOption_boolZ*)(_res_ptr);
17398         FREE(untag_ptr(_res));
17399         COption_boolZ_free(_res_conv);
17400 }
17401
17402 static inline uint64_t COption_boolZ_clone_ptr(LDKCOption_boolZ *NONNULL_PTR arg) {
17403         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17404         *ret_copy = COption_boolZ_clone(arg);
17405         int64_t ret_ref = tag_ptr(ret_copy, true);
17406         return ret_ref;
17407 }
17408 int64_t  CS_LDK_COption_boolZ_clone_ptr(int64_t arg) {
17409         LDKCOption_boolZ* arg_conv = (LDKCOption_boolZ*)untag_ptr(arg);
17410         int64_t ret_conv = COption_boolZ_clone_ptr(arg_conv);
17411         return ret_conv;
17412 }
17413
17414 int64_t  CS_LDK_COption_boolZ_clone(int64_t orig) {
17415         LDKCOption_boolZ* orig_conv = (LDKCOption_boolZ*)untag_ptr(orig);
17416         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
17417         *ret_copy = COption_boolZ_clone(orig_conv);
17418         int64_t ret_ref = tag_ptr(ret_copy, true);
17419         return ret_ref;
17420 }
17421
17422 void  CS_LDK_CVec_CVec_u8ZZ_free(ptrArray _res) {
17423         LDKCVec_CVec_u8ZZ _res_constr;
17424         _res_constr.datalen = _res->arr_len;
17425         if (_res_constr.datalen > 0)
17426                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17427         else
17428                 _res_constr.data = NULL;
17429         int8_tArray* _res_vals = (void*) _res->elems;
17430         for (size_t i = 0; i < _res_constr.datalen; i++) {
17431                 int8_tArray _res_conv_8 = _res_vals[i];
17432                 LDKCVec_u8Z _res_conv_8_ref;
17433                 _res_conv_8_ref.datalen = _res_conv_8->arr_len;
17434                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17435                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, _res_conv_8_ref.datalen); FREE(_res_conv_8);
17436                 _res_constr.data[i] = _res_conv_8_ref;
17437         }
17438         FREE(_res);
17439         CVec_CVec_u8ZZ_free(_res_constr);
17440 }
17441
17442 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
17443         LDKCVec_CVec_u8ZZ o_constr;
17444         o_constr.datalen = o->arr_len;
17445         if (o_constr.datalen > 0)
17446                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
17447         else
17448                 o_constr.data = NULL;
17449         int8_tArray* o_vals = (void*) o->elems;
17450         for (size_t i = 0; i < o_constr.datalen; i++) {
17451                 int8_tArray o_conv_8 = o_vals[i];
17452                 LDKCVec_u8Z o_conv_8_ref;
17453                 o_conv_8_ref.datalen = o_conv_8->arr_len;
17454                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
17455                 memcpy(o_conv_8_ref.data, o_conv_8->elems, o_conv_8_ref.datalen); FREE(o_conv_8);
17456                 o_constr.data[i] = o_conv_8_ref;
17457         }
17458         FREE(o);
17459         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17460         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
17461         return tag_ptr(ret_conv, true);
17462 }
17463
17464 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_err() {
17465         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17466         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
17467         return tag_ptr(ret_conv, true);
17468 }
17469
17470 jboolean  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_is_ok(int64_t o) {
17471         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
17472         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
17473         return ret_conv;
17474 }
17475
17476 void  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_free(int64_t _res) {
17477         if (!ptr_is_owned(_res)) return;
17478         void* _res_ptr = untag_ptr(_res);
17479         CHECK_ACCESS(_res_ptr);
17480         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
17481         FREE(untag_ptr(_res));
17482         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
17483 }
17484
17485 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
17486         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17487         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
17488         return tag_ptr(ret_conv, true);
17489 }
17490 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(int64_t arg) {
17491         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
17492         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
17493         return ret_conv;
17494 }
17495
17496 int64_t  CS_LDK_CResult_CVec_CVec_u8ZZNoneZ_clone(int64_t orig) {
17497         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
17498         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
17499         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
17500         return tag_ptr(ret_conv, true);
17501 }
17502
17503 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_ok(int64_t o) {
17504         LDKInMemorySigner o_conv;
17505         o_conv.inner = untag_ptr(o);
17506         o_conv.is_owned = ptr_is_owned(o);
17507         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17508         o_conv = InMemorySigner_clone(&o_conv);
17509         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17510         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
17511         return tag_ptr(ret_conv, true);
17512 }
17513
17514 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_err(int64_t e) {
17515         void* e_ptr = untag_ptr(e);
17516         CHECK_ACCESS(e_ptr);
17517         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17518         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17519         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17520         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
17521         return tag_ptr(ret_conv, true);
17522 }
17523
17524 jboolean  CS_LDK_CResult_InMemorySignerDecodeErrorZ_is_ok(int64_t o) {
17525         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
17526         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
17527         return ret_conv;
17528 }
17529
17530 void  CS_LDK_CResult_InMemorySignerDecodeErrorZ_free(int64_t _res) {
17531         if (!ptr_is_owned(_res)) return;
17532         void* _res_ptr = untag_ptr(_res);
17533         CHECK_ACCESS(_res_ptr);
17534         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
17535         FREE(untag_ptr(_res));
17536         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
17537 }
17538
17539 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
17540         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17541         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
17542         return tag_ptr(ret_conv, true);
17543 }
17544 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_clone_ptr(int64_t arg) {
17545         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
17546         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
17547         return ret_conv;
17548 }
17549
17550 int64_t  CS_LDK_CResult_InMemorySignerDecodeErrorZ_clone(int64_t orig) {
17551         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
17552         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
17553         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
17554         return tag_ptr(ret_conv, true);
17555 }
17556
17557 int64_t  CS_LDK_CResult_TransactionNoneZ_ok(int8_tArray o) {
17558         LDKTransaction o_ref;
17559         o_ref.datalen = o->arr_len;
17560         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
17561         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
17562         o_ref.data_is_owned = true;
17563         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17564         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
17565         return tag_ptr(ret_conv, true);
17566 }
17567
17568 int64_t  CS_LDK_CResult_TransactionNoneZ_err() {
17569         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17570         *ret_conv = CResult_TransactionNoneZ_err();
17571         return tag_ptr(ret_conv, true);
17572 }
17573
17574 jboolean  CS_LDK_CResult_TransactionNoneZ_is_ok(int64_t o) {
17575         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
17576         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
17577         return ret_conv;
17578 }
17579
17580 void  CS_LDK_CResult_TransactionNoneZ_free(int64_t _res) {
17581         if (!ptr_is_owned(_res)) return;
17582         void* _res_ptr = untag_ptr(_res);
17583         CHECK_ACCESS(_res_ptr);
17584         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
17585         FREE(untag_ptr(_res));
17586         CResult_TransactionNoneZ_free(_res_conv);
17587 }
17588
17589 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
17590         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17591         *ret_conv = CResult_TransactionNoneZ_clone(arg);
17592         return tag_ptr(ret_conv, true);
17593 }
17594 int64_t  CS_LDK_CResult_TransactionNoneZ_clone_ptr(int64_t arg) {
17595         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
17596         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
17597         return ret_conv;
17598 }
17599
17600 int64_t  CS_LDK_CResult_TransactionNoneZ_clone(int64_t orig) {
17601         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
17602         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
17603         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
17604         return tag_ptr(ret_conv, true);
17605 }
17606
17607 int64_t  CS_LDK_COption_WriteableScoreZ_some(int64_t o) {
17608         void* o_ptr = untag_ptr(o);
17609         CHECK_ACCESS(o_ptr);
17610         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
17611         if (o_conv.free == LDKWriteableScore_JCalls_free) {
17612                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17613                 LDKWriteableScore_JCalls_cloned(&o_conv);
17614         }
17615         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17616         *ret_copy = COption_WriteableScoreZ_some(o_conv);
17617         int64_t ret_ref = tag_ptr(ret_copy, true);
17618         return ret_ref;
17619 }
17620
17621 int64_t  CS_LDK_COption_WriteableScoreZ_none() {
17622         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
17623         *ret_copy = COption_WriteableScoreZ_none();
17624         int64_t ret_ref = tag_ptr(ret_copy, true);
17625         return ret_ref;
17626 }
17627
17628 void  CS_LDK_COption_WriteableScoreZ_free(int64_t _res) {
17629         if (!ptr_is_owned(_res)) return;
17630         void* _res_ptr = untag_ptr(_res);
17631         CHECK_ACCESS(_res_ptr);
17632         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
17633         FREE(untag_ptr(_res));
17634         COption_WriteableScoreZ_free(_res_conv);
17635 }
17636
17637 int64_t  CS_LDK_CResult_NoneIOErrorZ_ok() {
17638         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17639         *ret_conv = CResult_NoneIOErrorZ_ok();
17640         return tag_ptr(ret_conv, true);
17641 }
17642
17643 int64_t  CS_LDK_CResult_NoneIOErrorZ_err(int32_t e) {
17644         LDKIOError e_conv = LDKIOError_from_cs(e);
17645         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17646         *ret_conv = CResult_NoneIOErrorZ_err(e_conv);
17647         return tag_ptr(ret_conv, true);
17648 }
17649
17650 jboolean  CS_LDK_CResult_NoneIOErrorZ_is_ok(int64_t o) {
17651         LDKCResult_NoneIOErrorZ* o_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(o);
17652         jboolean ret_conv = CResult_NoneIOErrorZ_is_ok(o_conv);
17653         return ret_conv;
17654 }
17655
17656 void  CS_LDK_CResult_NoneIOErrorZ_free(int64_t _res) {
17657         if (!ptr_is_owned(_res)) return;
17658         void* _res_ptr = untag_ptr(_res);
17659         CHECK_ACCESS(_res_ptr);
17660         LDKCResult_NoneIOErrorZ _res_conv = *(LDKCResult_NoneIOErrorZ*)(_res_ptr);
17661         FREE(untag_ptr(_res));
17662         CResult_NoneIOErrorZ_free(_res_conv);
17663 }
17664
17665 static inline uint64_t CResult_NoneIOErrorZ_clone_ptr(LDKCResult_NoneIOErrorZ *NONNULL_PTR arg) {
17666         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17667         *ret_conv = CResult_NoneIOErrorZ_clone(arg);
17668         return tag_ptr(ret_conv, true);
17669 }
17670 int64_t  CS_LDK_CResult_NoneIOErrorZ_clone_ptr(int64_t arg) {
17671         LDKCResult_NoneIOErrorZ* arg_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(arg);
17672         int64_t ret_conv = CResult_NoneIOErrorZ_clone_ptr(arg_conv);
17673         return ret_conv;
17674 }
17675
17676 int64_t  CS_LDK_CResult_NoneIOErrorZ_clone(int64_t orig) {
17677         LDKCResult_NoneIOErrorZ* orig_conv = (LDKCResult_NoneIOErrorZ*)untag_ptr(orig);
17678         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
17679         *ret_conv = CResult_NoneIOErrorZ_clone(orig_conv);
17680         return tag_ptr(ret_conv, true);
17681 }
17682
17683 void  CS_LDK_CVec_ChannelDetailsZ_free(int64_tArray _res) {
17684         LDKCVec_ChannelDetailsZ _res_constr;
17685         _res_constr.datalen = _res->arr_len;
17686         if (_res_constr.datalen > 0)
17687                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17688         else
17689                 _res_constr.data = NULL;
17690         int64_t* _res_vals = _res->elems;
17691         for (size_t q = 0; q < _res_constr.datalen; q++) {
17692                 int64_t _res_conv_16 = _res_vals[q];
17693                 LDKChannelDetails _res_conv_16_conv;
17694                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17695                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17696                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17697                 _res_constr.data[q] = _res_conv_16_conv;
17698         }
17699         FREE(_res);
17700         CVec_ChannelDetailsZ_free(_res_constr);
17701 }
17702
17703 int64_t  CS_LDK_CResult_RouteLightningErrorZ_ok(int64_t o) {
17704         LDKRoute o_conv;
17705         o_conv.inner = untag_ptr(o);
17706         o_conv.is_owned = ptr_is_owned(o);
17707         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17708         o_conv = Route_clone(&o_conv);
17709         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17710         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17711         return tag_ptr(ret_conv, true);
17712 }
17713
17714 int64_t  CS_LDK_CResult_RouteLightningErrorZ_err(int64_t e) {
17715         LDKLightningError e_conv;
17716         e_conv.inner = untag_ptr(e);
17717         e_conv.is_owned = ptr_is_owned(e);
17718         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17719         e_conv = LightningError_clone(&e_conv);
17720         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17721         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17722         return tag_ptr(ret_conv, true);
17723 }
17724
17725 jboolean  CS_LDK_CResult_RouteLightningErrorZ_is_ok(int64_t o) {
17726         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17727         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17728         return ret_conv;
17729 }
17730
17731 void  CS_LDK_CResult_RouteLightningErrorZ_free(int64_t _res) {
17732         if (!ptr_is_owned(_res)) return;
17733         void* _res_ptr = untag_ptr(_res);
17734         CHECK_ACCESS(_res_ptr);
17735         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17736         FREE(untag_ptr(_res));
17737         CResult_RouteLightningErrorZ_free(_res_conv);
17738 }
17739
17740 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17741         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17742         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17743         return tag_ptr(ret_conv, true);
17744 }
17745 int64_t  CS_LDK_CResult_RouteLightningErrorZ_clone_ptr(int64_t arg) {
17746         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17747         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17748         return ret_conv;
17749 }
17750
17751 int64_t  CS_LDK_CResult_RouteLightningErrorZ_clone(int64_t orig) {
17752         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17753         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17754         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17755         return tag_ptr(ret_conv, true);
17756 }
17757
17758 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_ok(int64_t o) {
17759         LDKInFlightHtlcs o_conv;
17760         o_conv.inner = untag_ptr(o);
17761         o_conv.is_owned = ptr_is_owned(o);
17762         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17763         o_conv = InFlightHtlcs_clone(&o_conv);
17764         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17765         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
17766         return tag_ptr(ret_conv, true);
17767 }
17768
17769 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_err(int64_t e) {
17770         void* e_ptr = untag_ptr(e);
17771         CHECK_ACCESS(e_ptr);
17772         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17773         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17774         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17775         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
17776         return tag_ptr(ret_conv, true);
17777 }
17778
17779 jboolean  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_is_ok(int64_t o) {
17780         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
17781         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
17782         return ret_conv;
17783 }
17784
17785 void  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_free(int64_t _res) {
17786         if (!ptr_is_owned(_res)) return;
17787         void* _res_ptr = untag_ptr(_res);
17788         CHECK_ACCESS(_res_ptr);
17789         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
17790         FREE(untag_ptr(_res));
17791         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
17792 }
17793
17794 static inline uint64_t CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR arg) {
17795         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17796         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(arg);
17797         return tag_ptr(ret_conv, true);
17798 }
17799 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(int64_t arg) {
17800         LDKCResult_InFlightHtlcsDecodeErrorZ* arg_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(arg);
17801         int64_t ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(arg_conv);
17802         return ret_conv;
17803 }
17804
17805 int64_t  CS_LDK_CResult_InFlightHtlcsDecodeErrorZ_clone(int64_t orig) {
17806         LDKCResult_InFlightHtlcsDecodeErrorZ* orig_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(orig);
17807         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17808         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(orig_conv);
17809         return tag_ptr(ret_conv, true);
17810 }
17811
17812 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_ok(int64_t o) {
17813         LDKRouteHop o_conv;
17814         o_conv.inner = untag_ptr(o);
17815         o_conv.is_owned = ptr_is_owned(o);
17816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17817         o_conv = RouteHop_clone(&o_conv);
17818         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17819         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
17820         return tag_ptr(ret_conv, true);
17821 }
17822
17823 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_err(int64_t e) {
17824         void* e_ptr = untag_ptr(e);
17825         CHECK_ACCESS(e_ptr);
17826         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17827         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17828         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17829         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
17830         return tag_ptr(ret_conv, true);
17831 }
17832
17833 jboolean  CS_LDK_CResult_RouteHopDecodeErrorZ_is_ok(int64_t o) {
17834         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
17835         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
17836         return ret_conv;
17837 }
17838
17839 void  CS_LDK_CResult_RouteHopDecodeErrorZ_free(int64_t _res) {
17840         if (!ptr_is_owned(_res)) return;
17841         void* _res_ptr = untag_ptr(_res);
17842         CHECK_ACCESS(_res_ptr);
17843         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
17844         FREE(untag_ptr(_res));
17845         CResult_RouteHopDecodeErrorZ_free(_res_conv);
17846 }
17847
17848 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
17849         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17850         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
17851         return tag_ptr(ret_conv, true);
17852 }
17853 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_clone_ptr(int64_t arg) {
17854         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
17855         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
17856         return ret_conv;
17857 }
17858
17859 int64_t  CS_LDK_CResult_RouteHopDecodeErrorZ_clone(int64_t orig) {
17860         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
17861         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17862         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
17863         return tag_ptr(ret_conv, true);
17864 }
17865
17866 void  CS_LDK_CVec_BlindedHopZ_free(int64_tArray _res) {
17867         LDKCVec_BlindedHopZ _res_constr;
17868         _res_constr.datalen = _res->arr_len;
17869         if (_res_constr.datalen > 0)
17870                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
17871         else
17872                 _res_constr.data = NULL;
17873         int64_t* _res_vals = _res->elems;
17874         for (size_t m = 0; m < _res_constr.datalen; m++) {
17875                 int64_t _res_conv_12 = _res_vals[m];
17876                 LDKBlindedHop _res_conv_12_conv;
17877                 _res_conv_12_conv.inner = untag_ptr(_res_conv_12);
17878                 _res_conv_12_conv.is_owned = ptr_is_owned(_res_conv_12);
17879                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv);
17880                 _res_constr.data[m] = _res_conv_12_conv;
17881         }
17882         FREE(_res);
17883         CVec_BlindedHopZ_free(_res_constr);
17884 }
17885
17886 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_ok(int64_t o) {
17887         LDKBlindedTail o_conv;
17888         o_conv.inner = untag_ptr(o);
17889         o_conv.is_owned = ptr_is_owned(o);
17890         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17891         o_conv = BlindedTail_clone(&o_conv);
17892         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17893         *ret_conv = CResult_BlindedTailDecodeErrorZ_ok(o_conv);
17894         return tag_ptr(ret_conv, true);
17895 }
17896
17897 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_err(int64_t e) {
17898         void* e_ptr = untag_ptr(e);
17899         CHECK_ACCESS(e_ptr);
17900         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17901         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17902         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17903         *ret_conv = CResult_BlindedTailDecodeErrorZ_err(e_conv);
17904         return tag_ptr(ret_conv, true);
17905 }
17906
17907 jboolean  CS_LDK_CResult_BlindedTailDecodeErrorZ_is_ok(int64_t o) {
17908         LDKCResult_BlindedTailDecodeErrorZ* o_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(o);
17909         jboolean ret_conv = CResult_BlindedTailDecodeErrorZ_is_ok(o_conv);
17910         return ret_conv;
17911 }
17912
17913 void  CS_LDK_CResult_BlindedTailDecodeErrorZ_free(int64_t _res) {
17914         if (!ptr_is_owned(_res)) return;
17915         void* _res_ptr = untag_ptr(_res);
17916         CHECK_ACCESS(_res_ptr);
17917         LDKCResult_BlindedTailDecodeErrorZ _res_conv = *(LDKCResult_BlindedTailDecodeErrorZ*)(_res_ptr);
17918         FREE(untag_ptr(_res));
17919         CResult_BlindedTailDecodeErrorZ_free(_res_conv);
17920 }
17921
17922 static inline uint64_t CResult_BlindedTailDecodeErrorZ_clone_ptr(LDKCResult_BlindedTailDecodeErrorZ *NONNULL_PTR arg) {
17923         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17924         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(arg);
17925         return tag_ptr(ret_conv, true);
17926 }
17927 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_clone_ptr(int64_t arg) {
17928         LDKCResult_BlindedTailDecodeErrorZ* arg_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(arg);
17929         int64_t ret_conv = CResult_BlindedTailDecodeErrorZ_clone_ptr(arg_conv);
17930         return ret_conv;
17931 }
17932
17933 int64_t  CS_LDK_CResult_BlindedTailDecodeErrorZ_clone(int64_t orig) {
17934         LDKCResult_BlindedTailDecodeErrorZ* orig_conv = (LDKCResult_BlindedTailDecodeErrorZ*)untag_ptr(orig);
17935         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
17936         *ret_conv = CResult_BlindedTailDecodeErrorZ_clone(orig_conv);
17937         return tag_ptr(ret_conv, true);
17938 }
17939
17940 void  CS_LDK_CVec_RouteHopZ_free(int64_tArray _res) {
17941         LDKCVec_RouteHopZ _res_constr;
17942         _res_constr.datalen = _res->arr_len;
17943         if (_res_constr.datalen > 0)
17944                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17945         else
17946                 _res_constr.data = NULL;
17947         int64_t* _res_vals = _res->elems;
17948         for (size_t k = 0; k < _res_constr.datalen; k++) {
17949                 int64_t _res_conv_10 = _res_vals[k];
17950                 LDKRouteHop _res_conv_10_conv;
17951                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
17952                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
17953                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
17954                 _res_constr.data[k] = _res_conv_10_conv;
17955         }
17956         FREE(_res);
17957         CVec_RouteHopZ_free(_res_constr);
17958 }
17959
17960 void  CS_LDK_CVec_PathZ_free(int64_tArray _res) {
17961         LDKCVec_PathZ _res_constr;
17962         _res_constr.datalen = _res->arr_len;
17963         if (_res_constr.datalen > 0)
17964                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
17965         else
17966                 _res_constr.data = NULL;
17967         int64_t* _res_vals = _res->elems;
17968         for (size_t g = 0; g < _res_constr.datalen; g++) {
17969                 int64_t _res_conv_6 = _res_vals[g];
17970                 LDKPath _res_conv_6_conv;
17971                 _res_conv_6_conv.inner = untag_ptr(_res_conv_6);
17972                 _res_conv_6_conv.is_owned = ptr_is_owned(_res_conv_6);
17973                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_6_conv);
17974                 _res_constr.data[g] = _res_conv_6_conv;
17975         }
17976         FREE(_res);
17977         CVec_PathZ_free(_res_constr);
17978 }
17979
17980 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_ok(int64_t o) {
17981         LDKRoute o_conv;
17982         o_conv.inner = untag_ptr(o);
17983         o_conv.is_owned = ptr_is_owned(o);
17984         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17985         o_conv = Route_clone(&o_conv);
17986         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17987         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
17988         return tag_ptr(ret_conv, true);
17989 }
17990
17991 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_err(int64_t e) {
17992         void* e_ptr = untag_ptr(e);
17993         CHECK_ACCESS(e_ptr);
17994         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17995         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17996         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17997         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
17998         return tag_ptr(ret_conv, true);
17999 }
18000
18001 jboolean  CS_LDK_CResult_RouteDecodeErrorZ_is_ok(int64_t o) {
18002         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
18003         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
18004         return ret_conv;
18005 }
18006
18007 void  CS_LDK_CResult_RouteDecodeErrorZ_free(int64_t _res) {
18008         if (!ptr_is_owned(_res)) return;
18009         void* _res_ptr = untag_ptr(_res);
18010         CHECK_ACCESS(_res_ptr);
18011         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
18012         FREE(untag_ptr(_res));
18013         CResult_RouteDecodeErrorZ_free(_res_conv);
18014 }
18015
18016 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
18017         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18018         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
18019         return tag_ptr(ret_conv, true);
18020 }
18021 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_clone_ptr(int64_t arg) {
18022         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
18023         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
18024         return ret_conv;
18025 }
18026
18027 int64_t  CS_LDK_CResult_RouteDecodeErrorZ_clone(int64_t orig) {
18028         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
18029         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
18030         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
18031         return tag_ptr(ret_conv, true);
18032 }
18033
18034 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_ok(int64_t o) {
18035         LDKRouteParameters o_conv;
18036         o_conv.inner = untag_ptr(o);
18037         o_conv.is_owned = ptr_is_owned(o);
18038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18039         o_conv = RouteParameters_clone(&o_conv);
18040         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18041         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
18042         return tag_ptr(ret_conv, true);
18043 }
18044
18045 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_err(int64_t e) {
18046         void* e_ptr = untag_ptr(e);
18047         CHECK_ACCESS(e_ptr);
18048         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18049         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18050         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18051         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
18052         return tag_ptr(ret_conv, true);
18053 }
18054
18055 jboolean  CS_LDK_CResult_RouteParametersDecodeErrorZ_is_ok(int64_t o) {
18056         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
18057         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
18058         return ret_conv;
18059 }
18060
18061 void  CS_LDK_CResult_RouteParametersDecodeErrorZ_free(int64_t _res) {
18062         if (!ptr_is_owned(_res)) return;
18063         void* _res_ptr = untag_ptr(_res);
18064         CHECK_ACCESS(_res_ptr);
18065         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
18066         FREE(untag_ptr(_res));
18067         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
18068 }
18069
18070 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
18071         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18072         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
18073         return tag_ptr(ret_conv, true);
18074 }
18075 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_clone_ptr(int64_t arg) {
18076         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
18077         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
18078         return ret_conv;
18079 }
18080
18081 int64_t  CS_LDK_CResult_RouteParametersDecodeErrorZ_clone(int64_t orig) {
18082         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
18083         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
18084         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
18085         return tag_ptr(ret_conv, true);
18086 }
18087
18088 void  CS_LDK_CVec_u64Z_free(int64_tArray _res) {
18089         LDKCVec_u64Z _res_constr;
18090         _res_constr.datalen = _res->arr_len;
18091         if (_res_constr.datalen > 0)
18092                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
18093         else
18094                 _res_constr.data = NULL;
18095         int64_t* _res_vals = _res->elems;
18096         for (size_t g = 0; g < _res_constr.datalen; g++) {
18097                 int64_t _res_conv_6 = _res_vals[g];
18098                 _res_constr.data[g] = _res_conv_6;
18099         }
18100         FREE(_res);
18101         CVec_u64Z_free(_res_constr);
18102 }
18103
18104 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_ok(int64_t o) {
18105         LDKPaymentParameters o_conv;
18106         o_conv.inner = untag_ptr(o);
18107         o_conv.is_owned = ptr_is_owned(o);
18108         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18109         o_conv = PaymentParameters_clone(&o_conv);
18110         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18111         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
18112         return tag_ptr(ret_conv, true);
18113 }
18114
18115 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_err(int64_t e) {
18116         void* e_ptr = untag_ptr(e);
18117         CHECK_ACCESS(e_ptr);
18118         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18119         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18120         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18121         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
18122         return tag_ptr(ret_conv, true);
18123 }
18124
18125 jboolean  CS_LDK_CResult_PaymentParametersDecodeErrorZ_is_ok(int64_t o) {
18126         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
18127         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
18128         return ret_conv;
18129 }
18130
18131 void  CS_LDK_CResult_PaymentParametersDecodeErrorZ_free(int64_t _res) {
18132         if (!ptr_is_owned(_res)) return;
18133         void* _res_ptr = untag_ptr(_res);
18134         CHECK_ACCESS(_res_ptr);
18135         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
18136         FREE(untag_ptr(_res));
18137         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
18138 }
18139
18140 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
18141         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18142         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
18143         return tag_ptr(ret_conv, true);
18144 }
18145 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_clone_ptr(int64_t arg) {
18146         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
18147         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
18148         return ret_conv;
18149 }
18150
18151 int64_t  CS_LDK_CResult_PaymentParametersDecodeErrorZ_clone(int64_t orig) {
18152         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
18153         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
18154         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
18155         return tag_ptr(ret_conv, true);
18156 }
18157
18158 static inline uint64_t C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(LDKC2Tuple_BlindedPayInfoBlindedPathZ *NONNULL_PTR arg) {
18159         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
18160         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(arg);
18161         return tag_ptr(ret_conv, true);
18162 }
18163 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(int64_t arg) {
18164         LDKC2Tuple_BlindedPayInfoBlindedPathZ* arg_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(arg);
18165         int64_t ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone_ptr(arg_conv);
18166         return ret_conv;
18167 }
18168
18169 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_clone(int64_t orig) {
18170         LDKC2Tuple_BlindedPayInfoBlindedPathZ* orig_conv = (LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(orig);
18171         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
18172         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone(orig_conv);
18173         return tag_ptr(ret_conv, true);
18174 }
18175
18176 int64_t  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_new(int64_t a, int64_t b) {
18177         LDKBlindedPayInfo a_conv;
18178         a_conv.inner = untag_ptr(a);
18179         a_conv.is_owned = ptr_is_owned(a);
18180         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18181         a_conv = BlindedPayInfo_clone(&a_conv);
18182         LDKBlindedPath b_conv;
18183         b_conv.inner = untag_ptr(b);
18184         b_conv.is_owned = ptr_is_owned(b);
18185         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18186         b_conv = BlindedPath_clone(&b_conv);
18187         LDKC2Tuple_BlindedPayInfoBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKC2Tuple_BlindedPayInfoBlindedPathZ");
18188         *ret_conv = C2Tuple_BlindedPayInfoBlindedPathZ_new(a_conv, b_conv);
18189         return tag_ptr(ret_conv, true);
18190 }
18191
18192 void  CS_LDK_C2Tuple_BlindedPayInfoBlindedPathZ_free(int64_t _res) {
18193         if (!ptr_is_owned(_res)) return;
18194         void* _res_ptr = untag_ptr(_res);
18195         CHECK_ACCESS(_res_ptr);
18196         LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_ptr);
18197         FREE(untag_ptr(_res));
18198         C2Tuple_BlindedPayInfoBlindedPathZ_free(_res_conv);
18199 }
18200
18201 void  CS_LDK_CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(int64_tArray _res) {
18202         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ _res_constr;
18203         _res_constr.datalen = _res->arr_len;
18204         if (_res_constr.datalen > 0)
18205                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
18206         else
18207                 _res_constr.data = NULL;
18208         int64_t* _res_vals = _res->elems;
18209         for (size_t l = 0; l < _res_constr.datalen; l++) {
18210                 int64_t _res_conv_37 = _res_vals[l];
18211                 void* _res_conv_37_ptr = untag_ptr(_res_conv_37);
18212                 CHECK_ACCESS(_res_conv_37_ptr);
18213                 LDKC2Tuple_BlindedPayInfoBlindedPathZ _res_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(_res_conv_37_ptr);
18214                 FREE(untag_ptr(_res_conv_37));
18215                 _res_constr.data[l] = _res_conv_37_conv;
18216         }
18217         FREE(_res);
18218         CVec_C2Tuple_BlindedPayInfoBlindedPathZZ_free(_res_constr);
18219 }
18220
18221 void  CS_LDK_CVec_RouteHintZ_free(int64_tArray _res) {
18222         LDKCVec_RouteHintZ _res_constr;
18223         _res_constr.datalen = _res->arr_len;
18224         if (_res_constr.datalen > 0)
18225                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
18226         else
18227                 _res_constr.data = NULL;
18228         int64_t* _res_vals = _res->elems;
18229         for (size_t l = 0; l < _res_constr.datalen; l++) {
18230                 int64_t _res_conv_11 = _res_vals[l];
18231                 LDKRouteHint _res_conv_11_conv;
18232                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
18233                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
18234                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
18235                 _res_constr.data[l] = _res_conv_11_conv;
18236         }
18237         FREE(_res);
18238         CVec_RouteHintZ_free(_res_constr);
18239 }
18240
18241 void  CS_LDK_CVec_RouteHintHopZ_free(int64_tArray _res) {
18242         LDKCVec_RouteHintHopZ _res_constr;
18243         _res_constr.datalen = _res->arr_len;
18244         if (_res_constr.datalen > 0)
18245                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
18246         else
18247                 _res_constr.data = NULL;
18248         int64_t* _res_vals = _res->elems;
18249         for (size_t o = 0; o < _res_constr.datalen; o++) {
18250                 int64_t _res_conv_14 = _res_vals[o];
18251                 LDKRouteHintHop _res_conv_14_conv;
18252                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
18253                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
18254                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
18255                 _res_constr.data[o] = _res_conv_14_conv;
18256         }
18257         FREE(_res);
18258         CVec_RouteHintHopZ_free(_res_constr);
18259 }
18260
18261 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_ok(int64_t o) {
18262         LDKRouteHint o_conv;
18263         o_conv.inner = untag_ptr(o);
18264         o_conv.is_owned = ptr_is_owned(o);
18265         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18266         o_conv = RouteHint_clone(&o_conv);
18267         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18268         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
18269         return tag_ptr(ret_conv, true);
18270 }
18271
18272 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_err(int64_t e) {
18273         void* e_ptr = untag_ptr(e);
18274         CHECK_ACCESS(e_ptr);
18275         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18276         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18277         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18278         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
18279         return tag_ptr(ret_conv, true);
18280 }
18281
18282 jboolean  CS_LDK_CResult_RouteHintDecodeErrorZ_is_ok(int64_t o) {
18283         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
18284         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
18285         return ret_conv;
18286 }
18287
18288 void  CS_LDK_CResult_RouteHintDecodeErrorZ_free(int64_t _res) {
18289         if (!ptr_is_owned(_res)) return;
18290         void* _res_ptr = untag_ptr(_res);
18291         CHECK_ACCESS(_res_ptr);
18292         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
18293         FREE(untag_ptr(_res));
18294         CResult_RouteHintDecodeErrorZ_free(_res_conv);
18295 }
18296
18297 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
18298         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18299         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
18300         return tag_ptr(ret_conv, true);
18301 }
18302 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_clone_ptr(int64_t arg) {
18303         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
18304         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
18305         return ret_conv;
18306 }
18307
18308 int64_t  CS_LDK_CResult_RouteHintDecodeErrorZ_clone(int64_t orig) {
18309         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
18310         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
18311         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
18312         return tag_ptr(ret_conv, true);
18313 }
18314
18315 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_ok(int64_t o) {
18316         LDKRouteHintHop o_conv;
18317         o_conv.inner = untag_ptr(o);
18318         o_conv.is_owned = ptr_is_owned(o);
18319         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18320         o_conv = RouteHintHop_clone(&o_conv);
18321         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18322         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
18323         return tag_ptr(ret_conv, true);
18324 }
18325
18326 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_err(int64_t e) {
18327         void* e_ptr = untag_ptr(e);
18328         CHECK_ACCESS(e_ptr);
18329         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18330         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18331         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18332         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
18333         return tag_ptr(ret_conv, true);
18334 }
18335
18336 jboolean  CS_LDK_CResult_RouteHintHopDecodeErrorZ_is_ok(int64_t o) {
18337         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
18338         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
18339         return ret_conv;
18340 }
18341
18342 void  CS_LDK_CResult_RouteHintHopDecodeErrorZ_free(int64_t _res) {
18343         if (!ptr_is_owned(_res)) return;
18344         void* _res_ptr = untag_ptr(_res);
18345         CHECK_ACCESS(_res_ptr);
18346         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
18347         FREE(untag_ptr(_res));
18348         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
18349 }
18350
18351 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
18352         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18353         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
18354         return tag_ptr(ret_conv, true);
18355 }
18356 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_clone_ptr(int64_t arg) {
18357         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
18358         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
18359         return ret_conv;
18360 }
18361
18362 int64_t  CS_LDK_CResult_RouteHintHopDecodeErrorZ_clone(int64_t orig) {
18363         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
18364         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
18365         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
18366         return tag_ptr(ret_conv, true);
18367 }
18368
18369 void  CS_LDK_CVec_PublicKeyZ_free(ptrArray _res) {
18370         LDKCVec_PublicKeyZ _res_constr;
18371         _res_constr.datalen = _res->arr_len;
18372         if (_res_constr.datalen > 0)
18373                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
18374         else
18375                 _res_constr.data = NULL;
18376         int8_tArray* _res_vals = (void*) _res->elems;
18377         for (size_t i = 0; i < _res_constr.datalen; i++) {
18378                 int8_tArray _res_conv_8 = _res_vals[i];
18379                 LDKPublicKey _res_conv_8_ref;
18380                 CHECK(_res_conv_8->arr_len == 33);
18381                 memcpy(_res_conv_8_ref.compressed_form, _res_conv_8->elems, 33); FREE(_res_conv_8);
18382                 _res_constr.data[i] = _res_conv_8_ref;
18383         }
18384         FREE(_res);
18385         CVec_PublicKeyZ_free(_res_constr);
18386 }
18387
18388 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_ok(int64_t o) {
18389         LDKFixedPenaltyScorer o_conv;
18390         o_conv.inner = untag_ptr(o);
18391         o_conv.is_owned = ptr_is_owned(o);
18392         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18393         o_conv = FixedPenaltyScorer_clone(&o_conv);
18394         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18395         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
18396         return tag_ptr(ret_conv, true);
18397 }
18398
18399 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_err(int64_t e) {
18400         void* e_ptr = untag_ptr(e);
18401         CHECK_ACCESS(e_ptr);
18402         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18403         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18404         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18405         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
18406         return tag_ptr(ret_conv, true);
18407 }
18408
18409 jboolean  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(int64_t o) {
18410         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
18411         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
18412         return ret_conv;
18413 }
18414
18415 void  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_free(int64_t _res) {
18416         if (!ptr_is_owned(_res)) return;
18417         void* _res_ptr = untag_ptr(_res);
18418         CHECK_ACCESS(_res_ptr);
18419         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
18420         FREE(untag_ptr(_res));
18421         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
18422 }
18423
18424 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
18425         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18426         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
18427         return tag_ptr(ret_conv, true);
18428 }
18429 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(int64_t arg) {
18430         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
18431         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
18432         return ret_conv;
18433 }
18434
18435 int64_t  CS_LDK_CResult_FixedPenaltyScorerDecodeErrorZ_clone(int64_t orig) {
18436         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
18437         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18438         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
18439         return tag_ptr(ret_conv, true);
18440 }
18441
18442 void  CS_LDK_CVec_NodeIdZ_free(int64_tArray _res) {
18443         LDKCVec_NodeIdZ _res_constr;
18444         _res_constr.datalen = _res->arr_len;
18445         if (_res_constr.datalen > 0)
18446                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
18447         else
18448                 _res_constr.data = NULL;
18449         int64_t* _res_vals = _res->elems;
18450         for (size_t i = 0; i < _res_constr.datalen; i++) {
18451                 int64_t _res_conv_8 = _res_vals[i];
18452                 LDKNodeId _res_conv_8_conv;
18453                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
18454                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
18455                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
18456                 _res_constr.data[i] = _res_conv_8_conv;
18457         }
18458         FREE(_res);
18459         CVec_NodeIdZ_free(_res_constr);
18460 }
18461
18462 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
18463         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18464         *ret_conv = C2Tuple_u64u64Z_clone(arg);
18465         return tag_ptr(ret_conv, true);
18466 }
18467 int64_t  CS_LDK_C2Tuple_u64u64Z_clone_ptr(int64_t arg) {
18468         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
18469         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
18470         return ret_conv;
18471 }
18472
18473 int64_t  CS_LDK_C2Tuple_u64u64Z_clone(int64_t orig) {
18474         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
18475         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18476         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
18477         return tag_ptr(ret_conv, true);
18478 }
18479
18480 int64_t  CS_LDK_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
18481         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18482         *ret_conv = C2Tuple_u64u64Z_new(a, b);
18483         return tag_ptr(ret_conv, true);
18484 }
18485
18486 void  CS_LDK_C2Tuple_u64u64Z_free(int64_t _res) {
18487         if (!ptr_is_owned(_res)) return;
18488         void* _res_ptr = untag_ptr(_res);
18489         CHECK_ACCESS(_res_ptr);
18490         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
18491         FREE(untag_ptr(_res));
18492         C2Tuple_u64u64Z_free(_res_conv);
18493 }
18494
18495 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_some(int64_t o) {
18496         void* o_ptr = untag_ptr(o);
18497         CHECK_ACCESS(o_ptr);
18498         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
18499         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
18500         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18501         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
18502         int64_t ret_ref = tag_ptr(ret_copy, true);
18503         return ret_ref;
18504 }
18505
18506 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_none() {
18507         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18508         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
18509         int64_t ret_ref = tag_ptr(ret_copy, true);
18510         return ret_ref;
18511 }
18512
18513 void  CS_LDK_COption_C2Tuple_u64u64ZZ_free(int64_t _res) {
18514         if (!ptr_is_owned(_res)) return;
18515         void* _res_ptr = untag_ptr(_res);
18516         CHECK_ACCESS(_res_ptr);
18517         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
18518         FREE(untag_ptr(_res));
18519         COption_C2Tuple_u64u64ZZ_free(_res_conv);
18520 }
18521
18522 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
18523         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18524         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
18525         int64_t ret_ref = tag_ptr(ret_copy, true);
18526         return ret_ref;
18527 }
18528 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_clone_ptr(int64_t arg) {
18529         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
18530         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
18531         return ret_conv;
18532 }
18533
18534 int64_t  CS_LDK_COption_C2Tuple_u64u64ZZ_clone(int64_t orig) {
18535         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
18536         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18537         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
18538         int64_t ret_ref = tag_ptr(ret_copy, true);
18539         return ret_ref;
18540 }
18541
18542 int64_t  CS_LDK_C2Tuple_Z_new(int16_tArray a, int16_tArray b) {
18543         LDKThirtyTwoU16s a_ref;
18544         CHECK(a->arr_len == 32);
18545         memcpy(a_ref.data, a->elems, 32 * 2); FREE(a);
18546         LDKThirtyTwoU16s b_ref;
18547         CHECK(b->arr_len == 32);
18548         memcpy(b_ref.data, b->elems, 32 * 2); FREE(b);
18549         LDKC2Tuple_Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_Z), "LDKC2Tuple_Z");
18550         *ret_conv = C2Tuple_Z_new(a_ref, b_ref);
18551         return tag_ptr(ret_conv, true);
18552 }
18553
18554 void  CS_LDK_C2Tuple_Z_free(int64_t _res) {
18555         if (!ptr_is_owned(_res)) return;
18556         void* _res_ptr = untag_ptr(_res);
18557         CHECK_ACCESS(_res_ptr);
18558         LDKC2Tuple_Z _res_conv = *(LDKC2Tuple_Z*)(_res_ptr);
18559         FREE(untag_ptr(_res));
18560         C2Tuple_Z_free(_res_conv);
18561 }
18562
18563 int64_t  CS_LDK_C2Tuple__u1632_u1632Z_new(int16_tArray a, int16_tArray b) {
18564         LDKThirtyTwoU16s a_ref;
18565         CHECK(a->arr_len == 32);
18566         memcpy(a_ref.data, a->elems, 32 * 2); FREE(a);
18567         LDKThirtyTwoU16s b_ref;
18568         CHECK(b->arr_len == 32);
18569         memcpy(b_ref.data, b->elems, 32 * 2); FREE(b);
18570         LDKC2Tuple__u1632_u1632Z* ret_conv = MALLOC(sizeof(LDKC2Tuple__u1632_u1632Z), "LDKC2Tuple__u1632_u1632Z");
18571         *ret_conv = C2Tuple__u1632_u1632Z_new(a_ref, b_ref);
18572         return tag_ptr(ret_conv, true);
18573 }
18574
18575 void  CS_LDK_C2Tuple__u1632_u1632Z_free(int64_t _res) {
18576         if (!ptr_is_owned(_res)) return;
18577         void* _res_ptr = untag_ptr(_res);
18578         CHECK_ACCESS(_res_ptr);
18579         LDKC2Tuple__u1632_u1632Z _res_conv = *(LDKC2Tuple__u1632_u1632Z*)(_res_ptr);
18580         FREE(untag_ptr(_res));
18581         C2Tuple__u1632_u1632Z_free(_res_conv);
18582 }
18583
18584 int64_t  CS_LDK_COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_some(int64_t o) {
18585         void* o_ptr = untag_ptr(o);
18586         CHECK_ACCESS(o_ptr);
18587         LDKC2Tuple__u1632_u1632Z o_conv = *(LDKC2Tuple__u1632_u1632Z*)(o_ptr);
18588         // WARNING: we may need a move here but no clone is available for LDKC2Tuple__u1632_u1632Z
18589         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ), "LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ");
18590         *ret_copy = COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_some(o_conv);
18591         int64_t ret_ref = tag_ptr(ret_copy, true);
18592         return ret_ref;
18593 }
18594
18595 int64_t  CS_LDK_COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_none() {
18596         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ), "LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ");
18597         *ret_copy = COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_none();
18598         int64_t ret_ref = tag_ptr(ret_copy, true);
18599         return ret_ref;
18600 }
18601
18602 void  CS_LDK_COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_free(int64_t _res) {
18603         if (!ptr_is_owned(_res)) return;
18604         void* _res_ptr = untag_ptr(_res);
18605         CHECK_ACCESS(_res_ptr);
18606         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ _res_conv = *(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ*)(_res_ptr);
18607         FREE(untag_ptr(_res));
18608         COption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ_free(_res_conv);
18609 }
18610
18611 int64_t  CS_LDK_COption_f64Z_some(double o) {
18612         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18613         *ret_copy = COption_f64Z_some(o);
18614         int64_t ret_ref = tag_ptr(ret_copy, true);
18615         return ret_ref;
18616 }
18617
18618 int64_t  CS_LDK_COption_f64Z_none() {
18619         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18620         *ret_copy = COption_f64Z_none();
18621         int64_t ret_ref = tag_ptr(ret_copy, true);
18622         return ret_ref;
18623 }
18624
18625 void  CS_LDK_COption_f64Z_free(int64_t _res) {
18626         if (!ptr_is_owned(_res)) return;
18627         void* _res_ptr = untag_ptr(_res);
18628         CHECK_ACCESS(_res_ptr);
18629         LDKCOption_f64Z _res_conv = *(LDKCOption_f64Z*)(_res_ptr);
18630         FREE(untag_ptr(_res));
18631         COption_f64Z_free(_res_conv);
18632 }
18633
18634 static inline uint64_t COption_f64Z_clone_ptr(LDKCOption_f64Z *NONNULL_PTR arg) {
18635         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18636         *ret_copy = COption_f64Z_clone(arg);
18637         int64_t ret_ref = tag_ptr(ret_copy, true);
18638         return ret_ref;
18639 }
18640 int64_t  CS_LDK_COption_f64Z_clone_ptr(int64_t arg) {
18641         LDKCOption_f64Z* arg_conv = (LDKCOption_f64Z*)untag_ptr(arg);
18642         int64_t ret_conv = COption_f64Z_clone_ptr(arg_conv);
18643         return ret_conv;
18644 }
18645
18646 int64_t  CS_LDK_COption_f64Z_clone(int64_t orig) {
18647         LDKCOption_f64Z* orig_conv = (LDKCOption_f64Z*)untag_ptr(orig);
18648         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
18649         *ret_copy = COption_f64Z_clone(orig_conv);
18650         int64_t ret_ref = tag_ptr(ret_copy, true);
18651         return ret_ref;
18652 }
18653
18654 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_ok(int64_t o) {
18655         LDKProbabilisticScorer o_conv;
18656         o_conv.inner = untag_ptr(o);
18657         o_conv.is_owned = ptr_is_owned(o);
18658         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18659         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
18660         
18661         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18662         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18663         return tag_ptr(ret_conv, true);
18664 }
18665
18666 int64_t  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_err(int64_t e) {
18667         void* e_ptr = untag_ptr(e);
18668         CHECK_ACCESS(e_ptr);
18669         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18670         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18671         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18672         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18673         return tag_ptr(ret_conv, true);
18674 }
18675
18676 jboolean  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(int64_t o) {
18677         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18678         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18679         return ret_conv;
18680 }
18681
18682 void  CS_LDK_CResult_ProbabilisticScorerDecodeErrorZ_free(int64_t _res) {
18683         if (!ptr_is_owned(_res)) return;
18684         void* _res_ptr = untag_ptr(_res);
18685         CHECK_ACCESS(_res_ptr);
18686         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18687         FREE(untag_ptr(_res));
18688         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18689 }
18690
18691 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
18692         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18693         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
18694         return tag_ptr(ret_conv, true);
18695 }
18696 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_clone_ptr(int64_t arg) {
18697         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
18698         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
18699         return ret_conv;
18700 }
18701
18702 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_clone(int64_t orig) {
18703         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
18704         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18705         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
18706         return tag_ptr(ret_conv, true);
18707 }
18708
18709 int64_t  CS_LDK_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
18710         LDKTransaction b_ref;
18711         b_ref.datalen = b->arr_len;
18712         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
18713         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
18714         b_ref.data_is_owned = true;
18715         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18716         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
18717         return tag_ptr(ret_conv, true);
18718 }
18719
18720 void  CS_LDK_C2Tuple_usizeTransactionZ_free(int64_t _res) {
18721         if (!ptr_is_owned(_res)) return;
18722         void* _res_ptr = untag_ptr(_res);
18723         CHECK_ACCESS(_res_ptr);
18724         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
18725         FREE(untag_ptr(_res));
18726         C2Tuple_usizeTransactionZ_free(_res_conv);
18727 }
18728
18729 void  CS_LDK_CVec_C2Tuple_usizeTransactionZZ_free(int64_tArray _res) {
18730         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
18731         _res_constr.datalen = _res->arr_len;
18732         if (_res_constr.datalen > 0)
18733                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18734         else
18735                 _res_constr.data = NULL;
18736         int64_t* _res_vals = _res->elems;
18737         for (size_t c = 0; c < _res_constr.datalen; c++) {
18738                 int64_t _res_conv_28 = _res_vals[c];
18739                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
18740                 CHECK_ACCESS(_res_conv_28_ptr);
18741                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
18742                 FREE(untag_ptr(_res_conv_28));
18743                 _res_constr.data[c] = _res_conv_28_conv;
18744         }
18745         FREE(_res);
18746         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
18747 }
18748
18749 static inline uint64_t C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ *NONNULL_PTR arg) {
18750         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
18751         *ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(arg);
18752         return tag_ptr(ret_conv, true);
18753 }
18754 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone_ptr(int64_t arg) {
18755         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(arg);
18756         int64_t ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone_ptr(arg_conv);
18757         return ret_conv;
18758 }
18759
18760 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(int64_t orig) {
18761         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)untag_ptr(orig);
18762         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
18763         *ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_clone(orig_conv);
18764         return tag_ptr(ret_conv, true);
18765 }
18766
18767 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_new(int8_tArray a, int64_t b) {
18768         LDKThirtyTwoBytes a_ref;
18769         CHECK(a->arr_len == 32);
18770         memcpy(a_ref.data, a->elems, 32); FREE(a);
18771         void* b_ptr = untag_ptr(b);
18772         CHECK_ACCESS(b_ptr);
18773         LDKCOption_ThirtyTwoBytesZ b_conv = *(LDKCOption_ThirtyTwoBytesZ*)(b_ptr);
18774         b_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(b));
18775         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
18776         *ret_conv = C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_new(a_ref, b_conv);
18777         return tag_ptr(ret_conv, true);
18778 }
18779
18780 void  CS_LDK_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_free(int64_t _res) {
18781         if (!ptr_is_owned(_res)) return;
18782         void* _res_ptr = untag_ptr(_res);
18783         CHECK_ACCESS(_res_ptr);
18784         LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)(_res_ptr);
18785         FREE(untag_ptr(_res));
18786         C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ_free(_res_conv);
18787 }
18788
18789 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ_free(int64_tArray _res) {
18790         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ _res_constr;
18791         _res_constr.datalen = _res->arr_len;
18792         if (_res_constr.datalen > 0)
18793                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ Elements");
18794         else
18795                 _res_constr.data = NULL;
18796         int64_t* _res_vals = _res->elems;
18797         for (size_t x = 0; x < _res_constr.datalen; x++) {
18798                 int64_t _res_conv_49 = _res_vals[x];
18799                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18800                 CHECK_ACCESS(_res_conv_49_ptr);
18801                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ _res_conv_49_conv = *(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ*)(_res_conv_49_ptr);
18802                 FREE(untag_ptr(_res_conv_49));
18803                 _res_constr.data[x] = _res_conv_49_conv;
18804         }
18805         FREE(_res);
18806         CVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ_free(_res_constr);
18807 }
18808
18809 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_ok(int32_t o) {
18810         LDKChannelMonitorUpdateStatus o_conv = LDKChannelMonitorUpdateStatus_from_cs(o);
18811         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18812         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_ok(o_conv);
18813         return tag_ptr(ret_conv, true);
18814 }
18815
18816 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_err() {
18817         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18818         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_err();
18819         return tag_ptr(ret_conv, true);
18820 }
18821
18822 jboolean  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_is_ok(int64_t o) {
18823         LDKCResult_ChannelMonitorUpdateStatusNoneZ* o_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(o);
18824         jboolean ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_is_ok(o_conv);
18825         return ret_conv;
18826 }
18827
18828 void  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_free(int64_t _res) {
18829         if (!ptr_is_owned(_res)) return;
18830         void* _res_ptr = untag_ptr(_res);
18831         CHECK_ACCESS(_res_ptr);
18832         LDKCResult_ChannelMonitorUpdateStatusNoneZ _res_conv = *(LDKCResult_ChannelMonitorUpdateStatusNoneZ*)(_res_ptr);
18833         FREE(untag_ptr(_res));
18834         CResult_ChannelMonitorUpdateStatusNoneZ_free(_res_conv);
18835 }
18836
18837 static inline uint64_t CResult_ChannelMonitorUpdateStatusNoneZ_clone_ptr(LDKCResult_ChannelMonitorUpdateStatusNoneZ *NONNULL_PTR arg) {
18838         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18839         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_clone(arg);
18840         return tag_ptr(ret_conv, true);
18841 }
18842 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_clone_ptr(int64_t arg) {
18843         LDKCResult_ChannelMonitorUpdateStatusNoneZ* arg_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(arg);
18844         int64_t ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_clone_ptr(arg_conv);
18845         return ret_conv;
18846 }
18847
18848 int64_t  CS_LDK_CResult_ChannelMonitorUpdateStatusNoneZ_clone(int64_t orig) {
18849         LDKCResult_ChannelMonitorUpdateStatusNoneZ* orig_conv = (LDKCResult_ChannelMonitorUpdateStatusNoneZ*)untag_ptr(orig);
18850         LDKCResult_ChannelMonitorUpdateStatusNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateStatusNoneZ), "LDKCResult_ChannelMonitorUpdateStatusNoneZ");
18851         *ret_conv = CResult_ChannelMonitorUpdateStatusNoneZ_clone(orig_conv);
18852         return tag_ptr(ret_conv, true);
18853 }
18854
18855 void  CS_LDK_CVec_MonitorEventZ_free(int64_tArray _res) {
18856         LDKCVec_MonitorEventZ _res_constr;
18857         _res_constr.datalen = _res->arr_len;
18858         if (_res_constr.datalen > 0)
18859                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18860         else
18861                 _res_constr.data = NULL;
18862         int64_t* _res_vals = _res->elems;
18863         for (size_t o = 0; o < _res_constr.datalen; o++) {
18864                 int64_t _res_conv_14 = _res_vals[o];
18865                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
18866                 CHECK_ACCESS(_res_conv_14_ptr);
18867                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
18868                 FREE(untag_ptr(_res_conv_14));
18869                 _res_constr.data[o] = _res_conv_14_conv;
18870         }
18871         FREE(_res);
18872         CVec_MonitorEventZ_free(_res_constr);
18873 }
18874
18875 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
18876         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18877         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
18878         return tag_ptr(ret_conv, true);
18879 }
18880 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(int64_t arg) {
18881         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
18882         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
18883         return ret_conv;
18884 }
18885
18886 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(int64_t orig) {
18887         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
18888         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18889         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
18890         return tag_ptr(ret_conv, true);
18891 }
18892
18893 int64_t  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(int64_t a, int64_tArray b, int8_tArray c) {
18894         LDKOutPoint a_conv;
18895         a_conv.inner = untag_ptr(a);
18896         a_conv.is_owned = ptr_is_owned(a);
18897         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18898         a_conv = OutPoint_clone(&a_conv);
18899         LDKCVec_MonitorEventZ b_constr;
18900         b_constr.datalen = b->arr_len;
18901         if (b_constr.datalen > 0)
18902                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18903         else
18904                 b_constr.data = NULL;
18905         int64_t* b_vals = b->elems;
18906         for (size_t o = 0; o < b_constr.datalen; o++) {
18907                 int64_t b_conv_14 = b_vals[o];
18908                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
18909                 CHECK_ACCESS(b_conv_14_ptr);
18910                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
18911                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
18912                 b_constr.data[o] = b_conv_14_conv;
18913         }
18914         FREE(b);
18915         LDKPublicKey c_ref;
18916         CHECK(c->arr_len == 33);
18917         memcpy(c_ref.compressed_form, c->elems, 33); FREE(c);
18918         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18919         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
18920         return tag_ptr(ret_conv, true);
18921 }
18922
18923 void  CS_LDK_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(int64_t _res) {
18924         if (!ptr_is_owned(_res)) return;
18925         void* _res_ptr = untag_ptr(_res);
18926         CHECK_ACCESS(_res_ptr);
18927         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
18928         FREE(untag_ptr(_res));
18929         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
18930 }
18931
18932 void  CS_LDK_CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(int64_tArray _res) {
18933         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
18934         _res_constr.datalen = _res->arr_len;
18935         if (_res_constr.datalen > 0)
18936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
18937         else
18938                 _res_constr.data = NULL;
18939         int64_t* _res_vals = _res->elems;
18940         for (size_t x = 0; x < _res_constr.datalen; x++) {
18941                 int64_t _res_conv_49 = _res_vals[x];
18942                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18943                 CHECK_ACCESS(_res_conv_49_ptr);
18944                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
18945                 FREE(untag_ptr(_res_conv_49));
18946                 _res_constr.data[x] = _res_conv_49_conv;
18947         }
18948         FREE(_res);
18949         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
18950 }
18951
18952 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_ok(int64_t o) {
18953         LDKInitFeatures o_conv;
18954         o_conv.inner = untag_ptr(o);
18955         o_conv.is_owned = ptr_is_owned(o);
18956         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18957         o_conv = InitFeatures_clone(&o_conv);
18958         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18959         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18960         return tag_ptr(ret_conv, true);
18961 }
18962
18963 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_err(int64_t e) {
18964         void* e_ptr = untag_ptr(e);
18965         CHECK_ACCESS(e_ptr);
18966         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18967         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18968         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18969         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18970         return tag_ptr(ret_conv, true);
18971 }
18972
18973 jboolean  CS_LDK_CResult_InitFeaturesDecodeErrorZ_is_ok(int64_t o) {
18974         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18975         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18976         return ret_conv;
18977 }
18978
18979 void  CS_LDK_CResult_InitFeaturesDecodeErrorZ_free(int64_t _res) {
18980         if (!ptr_is_owned(_res)) return;
18981         void* _res_ptr = untag_ptr(_res);
18982         CHECK_ACCESS(_res_ptr);
18983         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18984         FREE(untag_ptr(_res));
18985         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18986 }
18987
18988 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18989         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18990         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18991         return tag_ptr(ret_conv, true);
18992 }
18993 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
18994         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18995         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18996         return ret_conv;
18997 }
18998
18999 int64_t  CS_LDK_CResult_InitFeaturesDecodeErrorZ_clone(int64_t orig) {
19000         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
19001         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
19002         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
19003         return tag_ptr(ret_conv, true);
19004 }
19005
19006 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_ok(int64_t o) {
19007         LDKChannelFeatures o_conv;
19008         o_conv.inner = untag_ptr(o);
19009         o_conv.is_owned = ptr_is_owned(o);
19010         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19011         o_conv = ChannelFeatures_clone(&o_conv);
19012         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19013         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
19014         return tag_ptr(ret_conv, true);
19015 }
19016
19017 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_err(int64_t e) {
19018         void* e_ptr = untag_ptr(e);
19019         CHECK_ACCESS(e_ptr);
19020         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19021         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19022         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19023         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
19024         return tag_ptr(ret_conv, true);
19025 }
19026
19027 jboolean  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_is_ok(int64_t o) {
19028         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
19029         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
19030         return ret_conv;
19031 }
19032
19033 void  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_free(int64_t _res) {
19034         if (!ptr_is_owned(_res)) return;
19035         void* _res_ptr = untag_ptr(_res);
19036         CHECK_ACCESS(_res_ptr);
19037         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
19038         FREE(untag_ptr(_res));
19039         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
19040 }
19041
19042 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19043         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19044         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
19045         return tag_ptr(ret_conv, true);
19046 }
19047 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19048         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
19049         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19050         return ret_conv;
19051 }
19052
19053 int64_t  CS_LDK_CResult_ChannelFeaturesDecodeErrorZ_clone(int64_t orig) {
19054         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
19055         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
19056         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
19057         return tag_ptr(ret_conv, true);
19058 }
19059
19060 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_ok(int64_t o) {
19061         LDKNodeFeatures o_conv;
19062         o_conv.inner = untag_ptr(o);
19063         o_conv.is_owned = ptr_is_owned(o);
19064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19065         o_conv = NodeFeatures_clone(&o_conv);
19066         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19067         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
19068         return tag_ptr(ret_conv, true);
19069 }
19070
19071 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_err(int64_t e) {
19072         void* e_ptr = untag_ptr(e);
19073         CHECK_ACCESS(e_ptr);
19074         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19075         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19076         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19077         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
19078         return tag_ptr(ret_conv, true);
19079 }
19080
19081 jboolean  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_is_ok(int64_t o) {
19082         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
19083         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
19084         return ret_conv;
19085 }
19086
19087 void  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_free(int64_t _res) {
19088         if (!ptr_is_owned(_res)) return;
19089         void* _res_ptr = untag_ptr(_res);
19090         CHECK_ACCESS(_res_ptr);
19091         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
19092         FREE(untag_ptr(_res));
19093         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
19094 }
19095
19096 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19097         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19098         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
19099         return tag_ptr(ret_conv, true);
19100 }
19101 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19102         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
19103         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19104         return ret_conv;
19105 }
19106
19107 int64_t  CS_LDK_CResult_NodeFeaturesDecodeErrorZ_clone(int64_t orig) {
19108         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
19109         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
19110         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
19111         return tag_ptr(ret_conv, true);
19112 }
19113
19114 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(int64_t o) {
19115         LDKBolt11InvoiceFeatures o_conv;
19116         o_conv.inner = untag_ptr(o);
19117         o_conv.is_owned = ptr_is_owned(o);
19118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19119         o_conv = Bolt11InvoiceFeatures_clone(&o_conv);
19120         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19121         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_ok(o_conv);
19122         return tag_ptr(ret_conv, true);
19123 }
19124
19125 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(int64_t e) {
19126         void* e_ptr = untag_ptr(e);
19127         CHECK_ACCESS(e_ptr);
19128         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19129         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19130         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19131         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_err(e_conv);
19132         return tag_ptr(ret_conv, true);
19133 }
19134
19135 jboolean  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(int64_t o) {
19136         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
19137         jboolean ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
19138         return ret_conv;
19139 }
19140
19141 void  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(int64_t _res) {
19142         if (!ptr_is_owned(_res)) return;
19143         void* _res_ptr = untag_ptr(_res);
19144         CHECK_ACCESS(_res_ptr);
19145         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
19146         FREE(untag_ptr(_res));
19147         CResult_Bolt11InvoiceFeaturesDecodeErrorZ_free(_res_conv);
19148 }
19149
19150 static inline uint64_t CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19151         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19152         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(arg);
19153         return tag_ptr(ret_conv, true);
19154 }
19155 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19156         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
19157         int64_t ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19158         return ret_conv;
19159 }
19160
19161 int64_t  CS_LDK_CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(int64_t orig) {
19162         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
19163         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
19164         *ret_conv = CResult_Bolt11InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
19165         return tag_ptr(ret_conv, true);
19166 }
19167
19168 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(int64_t o) {
19169         LDKBolt12InvoiceFeatures o_conv;
19170         o_conv.inner = untag_ptr(o);
19171         o_conv.is_owned = ptr_is_owned(o);
19172         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19173         o_conv = Bolt12InvoiceFeatures_clone(&o_conv);
19174         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19175         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_ok(o_conv);
19176         return tag_ptr(ret_conv, true);
19177 }
19178
19179 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(int64_t e) {
19180         void* e_ptr = untag_ptr(e);
19181         CHECK_ACCESS(e_ptr);
19182         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19183         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19184         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19185         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_err(e_conv);
19186         return tag_ptr(ret_conv, true);
19187 }
19188
19189 jboolean  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(int64_t o) {
19190         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
19191         jboolean ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
19192         return ret_conv;
19193 }
19194
19195 void  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(int64_t _res) {
19196         if (!ptr_is_owned(_res)) return;
19197         void* _res_ptr = untag_ptr(_res);
19198         CHECK_ACCESS(_res_ptr);
19199         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
19200         FREE(untag_ptr(_res));
19201         CResult_Bolt12InvoiceFeaturesDecodeErrorZ_free(_res_conv);
19202 }
19203
19204 static inline uint64_t CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19205         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19206         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(arg);
19207         return tag_ptr(ret_conv, true);
19208 }
19209 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19210         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
19211         int64_t ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19212         return ret_conv;
19213 }
19214
19215 int64_t  CS_LDK_CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(int64_t orig) {
19216         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
19217         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
19218         *ret_conv = CResult_Bolt12InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
19219         return tag_ptr(ret_conv, true);
19220 }
19221
19222 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_ok(int64_t o) {
19223         LDKBlindedHopFeatures o_conv;
19224         o_conv.inner = untag_ptr(o);
19225         o_conv.is_owned = ptr_is_owned(o);
19226         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19227         o_conv = BlindedHopFeatures_clone(&o_conv);
19228         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19229         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_ok(o_conv);
19230         return tag_ptr(ret_conv, true);
19231 }
19232
19233 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_err(int64_t e) {
19234         void* e_ptr = untag_ptr(e);
19235         CHECK_ACCESS(e_ptr);
19236         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19237         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19238         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19239         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_err(e_conv);
19240         return tag_ptr(ret_conv, true);
19241 }
19242
19243 jboolean  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(int64_t o) {
19244         LDKCResult_BlindedHopFeaturesDecodeErrorZ* o_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(o);
19245         jboolean ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_is_ok(o_conv);
19246         return ret_conv;
19247 }
19248
19249 void  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_free(int64_t _res) {
19250         if (!ptr_is_owned(_res)) return;
19251         void* _res_ptr = untag_ptr(_res);
19252         CHECK_ACCESS(_res_ptr);
19253         LDKCResult_BlindedHopFeaturesDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopFeaturesDecodeErrorZ*)(_res_ptr);
19254         FREE(untag_ptr(_res));
19255         CResult_BlindedHopFeaturesDecodeErrorZ_free(_res_conv);
19256 }
19257
19258 static inline uint64_t CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19259         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19260         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(arg);
19261         return tag_ptr(ret_conv, true);
19262 }
19263 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19264         LDKCResult_BlindedHopFeaturesDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(arg);
19265         int64_t ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19266         return ret_conv;
19267 }
19268
19269 int64_t  CS_LDK_CResult_BlindedHopFeaturesDecodeErrorZ_clone(int64_t orig) {
19270         LDKCResult_BlindedHopFeaturesDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopFeaturesDecodeErrorZ*)untag_ptr(orig);
19271         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
19272         *ret_conv = CResult_BlindedHopFeaturesDecodeErrorZ_clone(orig_conv);
19273         return tag_ptr(ret_conv, true);
19274 }
19275
19276 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(int64_t o) {
19277         LDKChannelTypeFeatures o_conv;
19278         o_conv.inner = untag_ptr(o);
19279         o_conv.is_owned = ptr_is_owned(o);
19280         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19281         o_conv = ChannelTypeFeatures_clone(&o_conv);
19282         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19283         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
19284         return tag_ptr(ret_conv, true);
19285 }
19286
19287 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_err(int64_t e) {
19288         void* e_ptr = untag_ptr(e);
19289         CHECK_ACCESS(e_ptr);
19290         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19291         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19292         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19293         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
19294         return tag_ptr(ret_conv, true);
19295 }
19296
19297 jboolean  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(int64_t o) {
19298         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
19299         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
19300         return ret_conv;
19301 }
19302
19303 void  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_free(int64_t _res) {
19304         if (!ptr_is_owned(_res)) return;
19305         void* _res_ptr = untag_ptr(_res);
19306         CHECK_ACCESS(_res_ptr);
19307         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
19308         FREE(untag_ptr(_res));
19309         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
19310 }
19311
19312 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
19313         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19314         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
19315         return tag_ptr(ret_conv, true);
19316 }
19317 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(int64_t arg) {
19318         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
19319         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
19320         return ret_conv;
19321 }
19322
19323 int64_t  CS_LDK_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(int64_t orig) {
19324         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
19325         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
19326         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
19327         return tag_ptr(ret_conv, true);
19328 }
19329
19330 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_ok(int64_t o) {
19331         LDKOffer o_conv;
19332         o_conv.inner = untag_ptr(o);
19333         o_conv.is_owned = ptr_is_owned(o);
19334         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19335         o_conv = Offer_clone(&o_conv);
19336         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19337         *ret_conv = CResult_OfferBolt12ParseErrorZ_ok(o_conv);
19338         return tag_ptr(ret_conv, true);
19339 }
19340
19341 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_err(int64_t e) {
19342         LDKBolt12ParseError e_conv;
19343         e_conv.inner = untag_ptr(e);
19344         e_conv.is_owned = ptr_is_owned(e);
19345         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19346         e_conv = Bolt12ParseError_clone(&e_conv);
19347         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19348         *ret_conv = CResult_OfferBolt12ParseErrorZ_err(e_conv);
19349         return tag_ptr(ret_conv, true);
19350 }
19351
19352 jboolean  CS_LDK_CResult_OfferBolt12ParseErrorZ_is_ok(int64_t o) {
19353         LDKCResult_OfferBolt12ParseErrorZ* o_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(o);
19354         jboolean ret_conv = CResult_OfferBolt12ParseErrorZ_is_ok(o_conv);
19355         return ret_conv;
19356 }
19357
19358 void  CS_LDK_CResult_OfferBolt12ParseErrorZ_free(int64_t _res) {
19359         if (!ptr_is_owned(_res)) return;
19360         void* _res_ptr = untag_ptr(_res);
19361         CHECK_ACCESS(_res_ptr);
19362         LDKCResult_OfferBolt12ParseErrorZ _res_conv = *(LDKCResult_OfferBolt12ParseErrorZ*)(_res_ptr);
19363         FREE(untag_ptr(_res));
19364         CResult_OfferBolt12ParseErrorZ_free(_res_conv);
19365 }
19366
19367 static inline uint64_t CResult_OfferBolt12ParseErrorZ_clone_ptr(LDKCResult_OfferBolt12ParseErrorZ *NONNULL_PTR arg) {
19368         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19369         *ret_conv = CResult_OfferBolt12ParseErrorZ_clone(arg);
19370         return tag_ptr(ret_conv, true);
19371 }
19372 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_clone_ptr(int64_t arg) {
19373         LDKCResult_OfferBolt12ParseErrorZ* arg_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(arg);
19374         int64_t ret_conv = CResult_OfferBolt12ParseErrorZ_clone_ptr(arg_conv);
19375         return ret_conv;
19376 }
19377
19378 int64_t  CS_LDK_CResult_OfferBolt12ParseErrorZ_clone(int64_t orig) {
19379         LDKCResult_OfferBolt12ParseErrorZ* orig_conv = (LDKCResult_OfferBolt12ParseErrorZ*)untag_ptr(orig);
19380         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
19381         *ret_conv = CResult_OfferBolt12ParseErrorZ_clone(orig_conv);
19382         return tag_ptr(ret_conv, true);
19383 }
19384
19385 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_ok(int8_tArray o) {
19386         LDKPublicKey o_ref;
19387         CHECK(o->arr_len == 33);
19388         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
19389         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19390         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_ok(o_ref);
19391         return tag_ptr(ret_conv, true);
19392 }
19393
19394 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_err(int32_t e) {
19395         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_cs(e);
19396         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19397         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_err(e_conv);
19398         return tag_ptr(ret_conv, true);
19399 }
19400
19401 jboolean  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_is_ok(int64_t o) {
19402         LDKCResult_PublicKeySecp256k1ErrorZ* o_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(o);
19403         jboolean ret_conv = CResult_PublicKeySecp256k1ErrorZ_is_ok(o_conv);
19404         return ret_conv;
19405 }
19406
19407 void  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_free(int64_t _res) {
19408         if (!ptr_is_owned(_res)) return;
19409         void* _res_ptr = untag_ptr(_res);
19410         CHECK_ACCESS(_res_ptr);
19411         LDKCResult_PublicKeySecp256k1ErrorZ _res_conv = *(LDKCResult_PublicKeySecp256k1ErrorZ*)(_res_ptr);
19412         FREE(untag_ptr(_res));
19413         CResult_PublicKeySecp256k1ErrorZ_free(_res_conv);
19414 }
19415
19416 static inline uint64_t CResult_PublicKeySecp256k1ErrorZ_clone_ptr(LDKCResult_PublicKeySecp256k1ErrorZ *NONNULL_PTR arg) {
19417         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19418         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_clone(arg);
19419         return tag_ptr(ret_conv, true);
19420 }
19421 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_clone_ptr(int64_t arg) {
19422         LDKCResult_PublicKeySecp256k1ErrorZ* arg_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(arg);
19423         int64_t ret_conv = CResult_PublicKeySecp256k1ErrorZ_clone_ptr(arg_conv);
19424         return ret_conv;
19425 }
19426
19427 int64_t  CS_LDK_CResult_PublicKeySecp256k1ErrorZ_clone(int64_t orig) {
19428         LDKCResult_PublicKeySecp256k1ErrorZ* orig_conv = (LDKCResult_PublicKeySecp256k1ErrorZ*)untag_ptr(orig);
19429         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
19430         *ret_conv = CResult_PublicKeySecp256k1ErrorZ_clone(orig_conv);
19431         return tag_ptr(ret_conv, true);
19432 }
19433
19434 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_ok(int64_t o) {
19435         LDKNodeId o_conv;
19436         o_conv.inner = untag_ptr(o);
19437         o_conv.is_owned = ptr_is_owned(o);
19438         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19439         o_conv = NodeId_clone(&o_conv);
19440         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19441         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
19442         return tag_ptr(ret_conv, true);
19443 }
19444
19445 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_err(int64_t e) {
19446         void* e_ptr = untag_ptr(e);
19447         CHECK_ACCESS(e_ptr);
19448         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19449         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19450         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19451         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
19452         return tag_ptr(ret_conv, true);
19453 }
19454
19455 jboolean  CS_LDK_CResult_NodeIdDecodeErrorZ_is_ok(int64_t o) {
19456         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
19457         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
19458         return ret_conv;
19459 }
19460
19461 void  CS_LDK_CResult_NodeIdDecodeErrorZ_free(int64_t _res) {
19462         if (!ptr_is_owned(_res)) return;
19463         void* _res_ptr = untag_ptr(_res);
19464         CHECK_ACCESS(_res_ptr);
19465         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
19466         FREE(untag_ptr(_res));
19467         CResult_NodeIdDecodeErrorZ_free(_res_conv);
19468 }
19469
19470 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
19471         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19472         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
19473         return tag_ptr(ret_conv, true);
19474 }
19475 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_clone_ptr(int64_t arg) {
19476         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
19477         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
19478         return ret_conv;
19479 }
19480
19481 int64_t  CS_LDK_CResult_NodeIdDecodeErrorZ_clone(int64_t orig) {
19482         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
19483         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
19484         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
19485         return tag_ptr(ret_conv, true);
19486 }
19487
19488 int64_t  CS_LDK_COption_NetworkUpdateZ_some(int64_t o) {
19489         void* o_ptr = untag_ptr(o);
19490         CHECK_ACCESS(o_ptr);
19491         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
19492         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
19493         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19494         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
19495         int64_t ret_ref = tag_ptr(ret_copy, true);
19496         return ret_ref;
19497 }
19498
19499 int64_t  CS_LDK_COption_NetworkUpdateZ_none() {
19500         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19501         *ret_copy = COption_NetworkUpdateZ_none();
19502         int64_t ret_ref = tag_ptr(ret_copy, true);
19503         return ret_ref;
19504 }
19505
19506 void  CS_LDK_COption_NetworkUpdateZ_free(int64_t _res) {
19507         if (!ptr_is_owned(_res)) return;
19508         void* _res_ptr = untag_ptr(_res);
19509         CHECK_ACCESS(_res_ptr);
19510         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
19511         FREE(untag_ptr(_res));
19512         COption_NetworkUpdateZ_free(_res_conv);
19513 }
19514
19515 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
19516         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19517         *ret_copy = COption_NetworkUpdateZ_clone(arg);
19518         int64_t ret_ref = tag_ptr(ret_copy, true);
19519         return ret_ref;
19520 }
19521 int64_t  CS_LDK_COption_NetworkUpdateZ_clone_ptr(int64_t arg) {
19522         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
19523         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
19524         return ret_conv;
19525 }
19526
19527 int64_t  CS_LDK_COption_NetworkUpdateZ_clone(int64_t orig) {
19528         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
19529         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
19530         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
19531         int64_t ret_ref = tag_ptr(ret_copy, true);
19532         return ret_ref;
19533 }
19534
19535 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(int64_t o) {
19536         void* o_ptr = untag_ptr(o);
19537         CHECK_ACCESS(o_ptr);
19538         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19539         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
19540         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19541         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19542         return tag_ptr(ret_conv, true);
19543 }
19544
19545 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_err(int64_t e) {
19546         void* e_ptr = untag_ptr(e);
19547         CHECK_ACCESS(e_ptr);
19548         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19549         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19550         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19551         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19552         return tag_ptr(ret_conv, true);
19553 }
19554
19555 jboolean  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(int64_t o) {
19556         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
19557         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19558         return ret_conv;
19559 }
19560
19561 void  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_free(int64_t _res) {
19562         if (!ptr_is_owned(_res)) return;
19563         void* _res_ptr = untag_ptr(_res);
19564         CHECK_ACCESS(_res_ptr);
19565         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
19566         FREE(untag_ptr(_res));
19567         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
19568 }
19569
19570 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
19571         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19572         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
19573         return tag_ptr(ret_conv, true);
19574 }
19575 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(int64_t arg) {
19576         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
19577         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
19578         return ret_conv;
19579 }
19580
19581 int64_t  CS_LDK_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(int64_t orig) {
19582         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
19583         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19584         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
19585         return tag_ptr(ret_conv, true);
19586 }
19587
19588 int64_t  CS_LDK_COption_UtxoLookupZ_some(int64_t o) {
19589         void* o_ptr = untag_ptr(o);
19590         CHECK_ACCESS(o_ptr);
19591         LDKUtxoLookup o_conv = *(LDKUtxoLookup*)(o_ptr);
19592         if (o_conv.free == LDKUtxoLookup_JCalls_free) {
19593                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19594                 LDKUtxoLookup_JCalls_cloned(&o_conv);
19595         }
19596         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19597         *ret_copy = COption_UtxoLookupZ_some(o_conv);
19598         int64_t ret_ref = tag_ptr(ret_copy, true);
19599         return ret_ref;
19600 }
19601
19602 int64_t  CS_LDK_COption_UtxoLookupZ_none() {
19603         LDKCOption_UtxoLookupZ *ret_copy = MALLOC(sizeof(LDKCOption_UtxoLookupZ), "LDKCOption_UtxoLookupZ");
19604         *ret_copy = COption_UtxoLookupZ_none();
19605         int64_t ret_ref = tag_ptr(ret_copy, true);
19606         return ret_ref;
19607 }
19608
19609 void  CS_LDK_COption_UtxoLookupZ_free(int64_t _res) {
19610         if (!ptr_is_owned(_res)) return;
19611         void* _res_ptr = untag_ptr(_res);
19612         CHECK_ACCESS(_res_ptr);
19613         LDKCOption_UtxoLookupZ _res_conv = *(LDKCOption_UtxoLookupZ*)(_res_ptr);
19614         FREE(untag_ptr(_res));
19615         COption_UtxoLookupZ_free(_res_conv);
19616 }
19617
19618 int64_t  CS_LDK_CResult_NoneLightningErrorZ_ok() {
19619         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19620         *ret_conv = CResult_NoneLightningErrorZ_ok();
19621         return tag_ptr(ret_conv, true);
19622 }
19623
19624 int64_t  CS_LDK_CResult_NoneLightningErrorZ_err(int64_t e) {
19625         LDKLightningError e_conv;
19626         e_conv.inner = untag_ptr(e);
19627         e_conv.is_owned = ptr_is_owned(e);
19628         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19629         e_conv = LightningError_clone(&e_conv);
19630         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19631         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19632         return tag_ptr(ret_conv, true);
19633 }
19634
19635 jboolean  CS_LDK_CResult_NoneLightningErrorZ_is_ok(int64_t o) {
19636         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
19637         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
19638         return ret_conv;
19639 }
19640
19641 void  CS_LDK_CResult_NoneLightningErrorZ_free(int64_t _res) {
19642         if (!ptr_is_owned(_res)) return;
19643         void* _res_ptr = untag_ptr(_res);
19644         CHECK_ACCESS(_res_ptr);
19645         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19646         FREE(untag_ptr(_res));
19647         CResult_NoneLightningErrorZ_free(_res_conv);
19648 }
19649
19650 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19651         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19652         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19653         return tag_ptr(ret_conv, true);
19654 }
19655 int64_t  CS_LDK_CResult_NoneLightningErrorZ_clone_ptr(int64_t arg) {
19656         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
19657         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19658         return ret_conv;
19659 }
19660
19661 int64_t  CS_LDK_CResult_NoneLightningErrorZ_clone(int64_t orig) {
19662         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
19663         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19664         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19665         return tag_ptr(ret_conv, true);
19666 }
19667
19668 int64_t  CS_LDK_CResult_boolLightningErrorZ_ok(jboolean o) {
19669         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19670         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19671         return tag_ptr(ret_conv, true);
19672 }
19673
19674 int64_t  CS_LDK_CResult_boolLightningErrorZ_err(int64_t e) {
19675         LDKLightningError e_conv;
19676         e_conv.inner = untag_ptr(e);
19677         e_conv.is_owned = ptr_is_owned(e);
19678         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19679         e_conv = LightningError_clone(&e_conv);
19680         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19681         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19682         return tag_ptr(ret_conv, true);
19683 }
19684
19685 jboolean  CS_LDK_CResult_boolLightningErrorZ_is_ok(int64_t o) {
19686         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
19687         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
19688         return ret_conv;
19689 }
19690
19691 void  CS_LDK_CResult_boolLightningErrorZ_free(int64_t _res) {
19692         if (!ptr_is_owned(_res)) return;
19693         void* _res_ptr = untag_ptr(_res);
19694         CHECK_ACCESS(_res_ptr);
19695         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19696         FREE(untag_ptr(_res));
19697         CResult_boolLightningErrorZ_free(_res_conv);
19698 }
19699
19700 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19701         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19702         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19703         return tag_ptr(ret_conv, true);
19704 }
19705 int64_t  CS_LDK_CResult_boolLightningErrorZ_clone_ptr(int64_t arg) {
19706         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
19707         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19708         return ret_conv;
19709 }
19710
19711 int64_t  CS_LDK_CResult_boolLightningErrorZ_clone(int64_t orig) {
19712         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
19713         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19714         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19715         return tag_ptr(ret_conv, true);
19716 }
19717
19718 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19719         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19720         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19721         return tag_ptr(ret_conv, true);
19722 }
19723 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(int64_t arg) {
19724         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
19725         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19726         return ret_conv;
19727 }
19728
19729 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(int64_t orig) {
19730         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
19731         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19732         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19733         return tag_ptr(ret_conv, true);
19734 }
19735
19736 int64_t  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(int64_t a, int64_t b, int64_t c) {
19737         LDKChannelAnnouncement a_conv;
19738         a_conv.inner = untag_ptr(a);
19739         a_conv.is_owned = ptr_is_owned(a);
19740         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19741         a_conv = ChannelAnnouncement_clone(&a_conv);
19742         LDKChannelUpdate b_conv;
19743         b_conv.inner = untag_ptr(b);
19744         b_conv.is_owned = ptr_is_owned(b);
19745         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19746         b_conv = ChannelUpdate_clone(&b_conv);
19747         LDKChannelUpdate c_conv;
19748         c_conv.inner = untag_ptr(c);
19749         c_conv.is_owned = ptr_is_owned(c);
19750         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19751         c_conv = ChannelUpdate_clone(&c_conv);
19752         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19753         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19754         return tag_ptr(ret_conv, true);
19755 }
19756
19757 void  CS_LDK_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(int64_t _res) {
19758         if (!ptr_is_owned(_res)) return;
19759         void* _res_ptr = untag_ptr(_res);
19760         CHECK_ACCESS(_res_ptr);
19761         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19762         FREE(untag_ptr(_res));
19763         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19764 }
19765
19766 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(int64_t o) {
19767         void* o_ptr = untag_ptr(o);
19768         CHECK_ACCESS(o_ptr);
19769         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
19770         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
19771         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19772         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
19773         int64_t ret_ref = tag_ptr(ret_copy, true);
19774         return ret_ref;
19775 }
19776
19777 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none() {
19778         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19779         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
19780         int64_t ret_ref = tag_ptr(ret_copy, true);
19781         return ret_ref;
19782 }
19783
19784 void  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(int64_t _res) {
19785         if (!ptr_is_owned(_res)) return;
19786         void* _res_ptr = untag_ptr(_res);
19787         CHECK_ACCESS(_res_ptr);
19788         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
19789         FREE(untag_ptr(_res));
19790         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
19791 }
19792
19793 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
19794         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19795         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
19796         int64_t ret_ref = tag_ptr(ret_copy, true);
19797         return ret_ref;
19798 }
19799 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(int64_t arg) {
19800         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
19801         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
19802         return ret_conv;
19803 }
19804
19805 int64_t  CS_LDK_COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(int64_t orig) {
19806         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
19807         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19808         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
19809         int64_t ret_ref = tag_ptr(ret_copy, true);
19810         return ret_ref;
19811 }
19812
19813 void  CS_LDK_CVec_MessageSendEventZ_free(int64_tArray _res) {
19814         LDKCVec_MessageSendEventZ _res_constr;
19815         _res_constr.datalen = _res->arr_len;
19816         if (_res_constr.datalen > 0)
19817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
19818         else
19819                 _res_constr.data = NULL;
19820         int64_t* _res_vals = _res->elems;
19821         for (size_t s = 0; s < _res_constr.datalen; s++) {
19822                 int64_t _res_conv_18 = _res_vals[s];
19823                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
19824                 CHECK_ACCESS(_res_conv_18_ptr);
19825                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
19826                 FREE(untag_ptr(_res_conv_18));
19827                 _res_constr.data[s] = _res_conv_18_conv;
19828         }
19829         FREE(_res);
19830         CVec_MessageSendEventZ_free(_res_constr);
19831 }
19832
19833 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_ok(int64_t o) {
19834         LDKChannelUpdateInfo o_conv;
19835         o_conv.inner = untag_ptr(o);
19836         o_conv.is_owned = ptr_is_owned(o);
19837         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19838         o_conv = ChannelUpdateInfo_clone(&o_conv);
19839         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19840         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
19841         return tag_ptr(ret_conv, true);
19842 }
19843
19844 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_err(int64_t e) {
19845         void* e_ptr = untag_ptr(e);
19846         CHECK_ACCESS(e_ptr);
19847         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19848         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19849         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19850         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
19851         return tag_ptr(ret_conv, true);
19852 }
19853
19854 jboolean  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(int64_t o) {
19855         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
19856         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
19857         return ret_conv;
19858 }
19859
19860 void  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_free(int64_t _res) {
19861         if (!ptr_is_owned(_res)) return;
19862         void* _res_ptr = untag_ptr(_res);
19863         CHECK_ACCESS(_res_ptr);
19864         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
19865         FREE(untag_ptr(_res));
19866         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
19867 }
19868
19869 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
19870         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19871         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
19872         return tag_ptr(ret_conv, true);
19873 }
19874 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(int64_t arg) {
19875         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
19876         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
19877         return ret_conv;
19878 }
19879
19880 int64_t  CS_LDK_CResult_ChannelUpdateInfoDecodeErrorZ_clone(int64_t orig) {
19881         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
19882         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19883         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
19884         return tag_ptr(ret_conv, true);
19885 }
19886
19887 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_ok(int64_t o) {
19888         LDKChannelInfo o_conv;
19889         o_conv.inner = untag_ptr(o);
19890         o_conv.is_owned = ptr_is_owned(o);
19891         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19892         o_conv = ChannelInfo_clone(&o_conv);
19893         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19894         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
19895         return tag_ptr(ret_conv, true);
19896 }
19897
19898 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_err(int64_t e) {
19899         void* e_ptr = untag_ptr(e);
19900         CHECK_ACCESS(e_ptr);
19901         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19902         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19903         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19904         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
19905         return tag_ptr(ret_conv, true);
19906 }
19907
19908 jboolean  CS_LDK_CResult_ChannelInfoDecodeErrorZ_is_ok(int64_t o) {
19909         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
19910         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
19911         return ret_conv;
19912 }
19913
19914 void  CS_LDK_CResult_ChannelInfoDecodeErrorZ_free(int64_t _res) {
19915         if (!ptr_is_owned(_res)) return;
19916         void* _res_ptr = untag_ptr(_res);
19917         CHECK_ACCESS(_res_ptr);
19918         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
19919         FREE(untag_ptr(_res));
19920         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
19921 }
19922
19923 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
19924         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19925         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
19926         return tag_ptr(ret_conv, true);
19927 }
19928 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_clone_ptr(int64_t arg) {
19929         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
19930         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
19931         return ret_conv;
19932 }
19933
19934 int64_t  CS_LDK_CResult_ChannelInfoDecodeErrorZ_clone(int64_t orig) {
19935         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
19936         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19937         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
19938         return tag_ptr(ret_conv, true);
19939 }
19940
19941 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_ok(int64_t o) {
19942         LDKRoutingFees o_conv;
19943         o_conv.inner = untag_ptr(o);
19944         o_conv.is_owned = ptr_is_owned(o);
19945         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19946         o_conv = RoutingFees_clone(&o_conv);
19947         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19948         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
19949         return tag_ptr(ret_conv, true);
19950 }
19951
19952 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_err(int64_t e) {
19953         void* e_ptr = untag_ptr(e);
19954         CHECK_ACCESS(e_ptr);
19955         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19956         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19957         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19958         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
19959         return tag_ptr(ret_conv, true);
19960 }
19961
19962 jboolean  CS_LDK_CResult_RoutingFeesDecodeErrorZ_is_ok(int64_t o) {
19963         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
19964         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
19965         return ret_conv;
19966 }
19967
19968 void  CS_LDK_CResult_RoutingFeesDecodeErrorZ_free(int64_t _res) {
19969         if (!ptr_is_owned(_res)) return;
19970         void* _res_ptr = untag_ptr(_res);
19971         CHECK_ACCESS(_res_ptr);
19972         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
19973         FREE(untag_ptr(_res));
19974         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
19975 }
19976
19977 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
19978         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19979         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
19980         return tag_ptr(ret_conv, true);
19981 }
19982 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_clone_ptr(int64_t arg) {
19983         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
19984         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
19985         return ret_conv;
19986 }
19987
19988 int64_t  CS_LDK_CResult_RoutingFeesDecodeErrorZ_clone(int64_t orig) {
19989         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
19990         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19991         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
19992         return tag_ptr(ret_conv, true);
19993 }
19994
19995 void  CS_LDK_CVec_SocketAddressZ_free(int64_tArray _res) {
19996         LDKCVec_SocketAddressZ _res_constr;
19997         _res_constr.datalen = _res->arr_len;
19998         if (_res_constr.datalen > 0)
19999                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
20000         else
20001                 _res_constr.data = NULL;
20002         int64_t* _res_vals = _res->elems;
20003         for (size_t p = 0; p < _res_constr.datalen; p++) {
20004                 int64_t _res_conv_15 = _res_vals[p];
20005                 void* _res_conv_15_ptr = untag_ptr(_res_conv_15);
20006                 CHECK_ACCESS(_res_conv_15_ptr);
20007                 LDKSocketAddress _res_conv_15_conv = *(LDKSocketAddress*)(_res_conv_15_ptr);
20008                 FREE(untag_ptr(_res_conv_15));
20009                 _res_constr.data[p] = _res_conv_15_conv;
20010         }
20011         FREE(_res);
20012         CVec_SocketAddressZ_free(_res_constr);
20013 }
20014
20015 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(int64_t o) {
20016         LDKNodeAnnouncementInfo o_conv;
20017         o_conv.inner = untag_ptr(o);
20018         o_conv.is_owned = ptr_is_owned(o);
20019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20020         o_conv = NodeAnnouncementInfo_clone(&o_conv);
20021         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20022         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
20023         return tag_ptr(ret_conv, true);
20024 }
20025
20026 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_err(int64_t e) {
20027         void* e_ptr = untag_ptr(e);
20028         CHECK_ACCESS(e_ptr);
20029         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20030         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20031         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20032         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
20033         return tag_ptr(ret_conv, true);
20034 }
20035
20036 jboolean  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(int64_t o) {
20037         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
20038         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
20039         return ret_conv;
20040 }
20041
20042 void  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_free(int64_t _res) {
20043         if (!ptr_is_owned(_res)) return;
20044         void* _res_ptr = untag_ptr(_res);
20045         CHECK_ACCESS(_res_ptr);
20046         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
20047         FREE(untag_ptr(_res));
20048         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
20049 }
20050
20051 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
20052         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20053         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
20054         return tag_ptr(ret_conv, true);
20055 }
20056 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(int64_t arg) {
20057         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
20058         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
20059         return ret_conv;
20060 }
20061
20062 int64_t  CS_LDK_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(int64_t orig) {
20063         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
20064         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
20065         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
20066         return tag_ptr(ret_conv, true);
20067 }
20068
20069 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_ok(int64_t o) {
20070         LDKNodeAlias o_conv;
20071         o_conv.inner = untag_ptr(o);
20072         o_conv.is_owned = ptr_is_owned(o);
20073         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20074         o_conv = NodeAlias_clone(&o_conv);
20075         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20076         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
20077         return tag_ptr(ret_conv, true);
20078 }
20079
20080 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_err(int64_t e) {
20081         void* e_ptr = untag_ptr(e);
20082         CHECK_ACCESS(e_ptr);
20083         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20084         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20085         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20086         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
20087         return tag_ptr(ret_conv, true);
20088 }
20089
20090 jboolean  CS_LDK_CResult_NodeAliasDecodeErrorZ_is_ok(int64_t o) {
20091         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
20092         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
20093         return ret_conv;
20094 }
20095
20096 void  CS_LDK_CResult_NodeAliasDecodeErrorZ_free(int64_t _res) {
20097         if (!ptr_is_owned(_res)) return;
20098         void* _res_ptr = untag_ptr(_res);
20099         CHECK_ACCESS(_res_ptr);
20100         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
20101         FREE(untag_ptr(_res));
20102         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
20103 }
20104
20105 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
20106         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20107         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
20108         return tag_ptr(ret_conv, true);
20109 }
20110 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_clone_ptr(int64_t arg) {
20111         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
20112         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
20113         return ret_conv;
20114 }
20115
20116 int64_t  CS_LDK_CResult_NodeAliasDecodeErrorZ_clone(int64_t orig) {
20117         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
20118         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
20119         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
20120         return tag_ptr(ret_conv, true);
20121 }
20122
20123 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_ok(int64_t o) {
20124         LDKNodeInfo o_conv;
20125         o_conv.inner = untag_ptr(o);
20126         o_conv.is_owned = ptr_is_owned(o);
20127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20128         o_conv = NodeInfo_clone(&o_conv);
20129         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20130         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
20131         return tag_ptr(ret_conv, true);
20132 }
20133
20134 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_err(int64_t e) {
20135         void* e_ptr = untag_ptr(e);
20136         CHECK_ACCESS(e_ptr);
20137         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20138         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20139         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20140         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
20141         return tag_ptr(ret_conv, true);
20142 }
20143
20144 jboolean  CS_LDK_CResult_NodeInfoDecodeErrorZ_is_ok(int64_t o) {
20145         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
20146         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
20147         return ret_conv;
20148 }
20149
20150 void  CS_LDK_CResult_NodeInfoDecodeErrorZ_free(int64_t _res) {
20151         if (!ptr_is_owned(_res)) return;
20152         void* _res_ptr = untag_ptr(_res);
20153         CHECK_ACCESS(_res_ptr);
20154         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
20155         FREE(untag_ptr(_res));
20156         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
20157 }
20158
20159 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
20160         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20161         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
20162         return tag_ptr(ret_conv, true);
20163 }
20164 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_clone_ptr(int64_t arg) {
20165         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
20166         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
20167         return ret_conv;
20168 }
20169
20170 int64_t  CS_LDK_CResult_NodeInfoDecodeErrorZ_clone(int64_t orig) {
20171         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
20172         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
20173         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
20174         return tag_ptr(ret_conv, true);
20175 }
20176
20177 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_ok(int64_t o) {
20178         LDKNetworkGraph o_conv;
20179         o_conv.inner = untag_ptr(o);
20180         o_conv.is_owned = ptr_is_owned(o);
20181         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20182         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
20183         
20184         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20185         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
20186         return tag_ptr(ret_conv, true);
20187 }
20188
20189 int64_t  CS_LDK_CResult_NetworkGraphDecodeErrorZ_err(int64_t e) {
20190         void* e_ptr = untag_ptr(e);
20191         CHECK_ACCESS(e_ptr);
20192         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20193         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20194         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
20195         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
20196         return tag_ptr(ret_conv, true);
20197 }
20198
20199 jboolean  CS_LDK_CResult_NetworkGraphDecodeErrorZ_is_ok(int64_t o) {
20200         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
20201         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
20202         return ret_conv;
20203 }
20204
20205 void  CS_LDK_CResult_NetworkGraphDecodeErrorZ_free(int64_t _res) {
20206         if (!ptr_is_owned(_res)) return;
20207         void* _res_ptr = untag_ptr(_res);
20208         CHECK_ACCESS(_res_ptr);
20209         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
20210         FREE(untag_ptr(_res));
20211         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
20212 }
20213
20214 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_some(int64_tArray o) {
20215         LDKCVec_SocketAddressZ o_constr;
20216         o_constr.datalen = o->arr_len;
20217         if (o_constr.datalen > 0)
20218                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
20219         else
20220                 o_constr.data = NULL;
20221         int64_t* o_vals = o->elems;
20222         for (size_t p = 0; p < o_constr.datalen; p++) {
20223                 int64_t o_conv_15 = o_vals[p];
20224                 void* o_conv_15_ptr = untag_ptr(o_conv_15);
20225                 CHECK_ACCESS(o_conv_15_ptr);
20226                 LDKSocketAddress o_conv_15_conv = *(LDKSocketAddress*)(o_conv_15_ptr);
20227                 o_conv_15_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o_conv_15));
20228                 o_constr.data[p] = o_conv_15_conv;
20229         }
20230         FREE(o);
20231         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20232         *ret_copy = COption_CVec_SocketAddressZZ_some(o_constr);
20233         int64_t ret_ref = tag_ptr(ret_copy, true);
20234         return ret_ref;
20235 }
20236
20237 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_none() {
20238         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20239         *ret_copy = COption_CVec_SocketAddressZZ_none();
20240         int64_t ret_ref = tag_ptr(ret_copy, true);
20241         return ret_ref;
20242 }
20243
20244 void  CS_LDK_COption_CVec_SocketAddressZZ_free(int64_t _res) {
20245         if (!ptr_is_owned(_res)) return;
20246         void* _res_ptr = untag_ptr(_res);
20247         CHECK_ACCESS(_res_ptr);
20248         LDKCOption_CVec_SocketAddressZZ _res_conv = *(LDKCOption_CVec_SocketAddressZZ*)(_res_ptr);
20249         FREE(untag_ptr(_res));
20250         COption_CVec_SocketAddressZZ_free(_res_conv);
20251 }
20252
20253 static inline uint64_t COption_CVec_SocketAddressZZ_clone_ptr(LDKCOption_CVec_SocketAddressZZ *NONNULL_PTR arg) {
20254         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20255         *ret_copy = COption_CVec_SocketAddressZZ_clone(arg);
20256         int64_t ret_ref = tag_ptr(ret_copy, true);
20257         return ret_ref;
20258 }
20259 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_clone_ptr(int64_t arg) {
20260         LDKCOption_CVec_SocketAddressZZ* arg_conv = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(arg);
20261         int64_t ret_conv = COption_CVec_SocketAddressZZ_clone_ptr(arg_conv);
20262         return ret_conv;
20263 }
20264
20265 int64_t  CS_LDK_COption_CVec_SocketAddressZZ_clone(int64_t orig) {
20266         LDKCOption_CVec_SocketAddressZZ* orig_conv = (LDKCOption_CVec_SocketAddressZZ*)untag_ptr(orig);
20267         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
20268         *ret_copy = COption_CVec_SocketAddressZZ_clone(orig_conv);
20269         int64_t ret_ref = tag_ptr(ret_copy, true);
20270         return ret_ref;
20271 }
20272
20273 void  CS_LDK_CVec_HTLCOutputInCommitmentZ_free(int64_tArray _res) {
20274         LDKCVec_HTLCOutputInCommitmentZ _res_constr;
20275         _res_constr.datalen = _res->arr_len;
20276         if (_res_constr.datalen > 0)
20277                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
20278         else
20279                 _res_constr.data = NULL;
20280         int64_t* _res_vals = _res->elems;
20281         for (size_t y = 0; y < _res_constr.datalen; y++) {
20282                 int64_t _res_conv_24 = _res_vals[y];
20283                 LDKHTLCOutputInCommitment _res_conv_24_conv;
20284                 _res_conv_24_conv.inner = untag_ptr(_res_conv_24);
20285                 _res_conv_24_conv.is_owned = ptr_is_owned(_res_conv_24);
20286                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_24_conv);
20287                 _res_constr.data[y] = _res_conv_24_conv;
20288         }
20289         FREE(_res);
20290         CVec_HTLCOutputInCommitmentZ_free(_res_constr);
20291 }
20292
20293 void  CS_LDK_CVec_HTLCDescriptorZ_free(int64_tArray _res) {
20294         LDKCVec_HTLCDescriptorZ _res_constr;
20295         _res_constr.datalen = _res->arr_len;
20296         if (_res_constr.datalen > 0)
20297                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKHTLCDescriptor), "LDKCVec_HTLCDescriptorZ Elements");
20298         else
20299                 _res_constr.data = NULL;
20300         int64_t* _res_vals = _res->elems;
20301         for (size_t q = 0; q < _res_constr.datalen; q++) {
20302                 int64_t _res_conv_16 = _res_vals[q];
20303                 LDKHTLCDescriptor _res_conv_16_conv;
20304                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
20305                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
20306                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20307                 _res_constr.data[q] = _res_conv_16_conv;
20308         }
20309         FREE(_res);
20310         CVec_HTLCDescriptorZ_free(_res_constr);
20311 }
20312
20313 void  CS_LDK_CVec_UtxoZ_free(int64_tArray _res) {
20314         LDKCVec_UtxoZ _res_constr;
20315         _res_constr.datalen = _res->arr_len;
20316         if (_res_constr.datalen > 0)
20317                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
20318         else
20319                 _res_constr.data = NULL;
20320         int64_t* _res_vals = _res->elems;
20321         for (size_t g = 0; g < _res_constr.datalen; g++) {
20322                 int64_t _res_conv_6 = _res_vals[g];
20323                 LDKUtxo _res_conv_6_conv;
20324                 _res_conv_6_conv.inner = untag_ptr(_res_conv_6);
20325                 _res_conv_6_conv.is_owned = ptr_is_owned(_res_conv_6);
20326                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_6_conv);
20327                 _res_constr.data[g] = _res_conv_6_conv;
20328         }
20329         FREE(_res);
20330         CVec_UtxoZ_free(_res_constr);
20331 }
20332
20333 int64_t  CS_LDK_COption_TxOutZ_some(int64_t o) {
20334         void* o_ptr = untag_ptr(o);
20335         CHECK_ACCESS(o_ptr);
20336         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
20337         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
20338         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20339         *ret_copy = COption_TxOutZ_some(o_conv);
20340         int64_t ret_ref = tag_ptr(ret_copy, true);
20341         return ret_ref;
20342 }
20343
20344 int64_t  CS_LDK_COption_TxOutZ_none() {
20345         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20346         *ret_copy = COption_TxOutZ_none();
20347         int64_t ret_ref = tag_ptr(ret_copy, true);
20348         return ret_ref;
20349 }
20350
20351 void  CS_LDK_COption_TxOutZ_free(int64_t _res) {
20352         if (!ptr_is_owned(_res)) return;
20353         void* _res_ptr = untag_ptr(_res);
20354         CHECK_ACCESS(_res_ptr);
20355         LDKCOption_TxOutZ _res_conv = *(LDKCOption_TxOutZ*)(_res_ptr);
20356         FREE(untag_ptr(_res));
20357         COption_TxOutZ_free(_res_conv);
20358 }
20359
20360 static inline uint64_t COption_TxOutZ_clone_ptr(LDKCOption_TxOutZ *NONNULL_PTR arg) {
20361         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20362         *ret_copy = COption_TxOutZ_clone(arg);
20363         int64_t ret_ref = tag_ptr(ret_copy, true);
20364         return ret_ref;
20365 }
20366 int64_t  CS_LDK_COption_TxOutZ_clone_ptr(int64_t arg) {
20367         LDKCOption_TxOutZ* arg_conv = (LDKCOption_TxOutZ*)untag_ptr(arg);
20368         int64_t ret_conv = COption_TxOutZ_clone_ptr(arg_conv);
20369         return ret_conv;
20370 }
20371
20372 int64_t  CS_LDK_COption_TxOutZ_clone(int64_t orig) {
20373         LDKCOption_TxOutZ* orig_conv = (LDKCOption_TxOutZ*)untag_ptr(orig);
20374         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
20375         *ret_copy = COption_TxOutZ_clone(orig_conv);
20376         int64_t ret_ref = tag_ptr(ret_copy, true);
20377         return ret_ref;
20378 }
20379
20380 void  CS_LDK_CVec_InputZ_free(int64_tArray _res) {
20381         LDKCVec_InputZ _res_constr;
20382         _res_constr.datalen = _res->arr_len;
20383         if (_res_constr.datalen > 0)
20384                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKInput), "LDKCVec_InputZ Elements");
20385         else
20386                 _res_constr.data = NULL;
20387         int64_t* _res_vals = _res->elems;
20388         for (size_t h = 0; h < _res_constr.datalen; h++) {
20389                 int64_t _res_conv_7 = _res_vals[h];
20390                 LDKInput _res_conv_7_conv;
20391                 _res_conv_7_conv.inner = untag_ptr(_res_conv_7);
20392                 _res_conv_7_conv.is_owned = ptr_is_owned(_res_conv_7);
20393                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_7_conv);
20394                 _res_constr.data[h] = _res_conv_7_conv;
20395         }
20396         FREE(_res);
20397         CVec_InputZ_free(_res_constr);
20398 }
20399
20400 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_ok(int64_t o) {
20401         LDKCoinSelection o_conv;
20402         o_conv.inner = untag_ptr(o);
20403         o_conv.is_owned = ptr_is_owned(o);
20404         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20405         o_conv = CoinSelection_clone(&o_conv);
20406         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20407         *ret_conv = CResult_CoinSelectionNoneZ_ok(o_conv);
20408         return tag_ptr(ret_conv, true);
20409 }
20410
20411 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_err() {
20412         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20413         *ret_conv = CResult_CoinSelectionNoneZ_err();
20414         return tag_ptr(ret_conv, true);
20415 }
20416
20417 jboolean  CS_LDK_CResult_CoinSelectionNoneZ_is_ok(int64_t o) {
20418         LDKCResult_CoinSelectionNoneZ* o_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(o);
20419         jboolean ret_conv = CResult_CoinSelectionNoneZ_is_ok(o_conv);
20420         return ret_conv;
20421 }
20422
20423 void  CS_LDK_CResult_CoinSelectionNoneZ_free(int64_t _res) {
20424         if (!ptr_is_owned(_res)) return;
20425         void* _res_ptr = untag_ptr(_res);
20426         CHECK_ACCESS(_res_ptr);
20427         LDKCResult_CoinSelectionNoneZ _res_conv = *(LDKCResult_CoinSelectionNoneZ*)(_res_ptr);
20428         FREE(untag_ptr(_res));
20429         CResult_CoinSelectionNoneZ_free(_res_conv);
20430 }
20431
20432 static inline uint64_t CResult_CoinSelectionNoneZ_clone_ptr(LDKCResult_CoinSelectionNoneZ *NONNULL_PTR arg) {
20433         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20434         *ret_conv = CResult_CoinSelectionNoneZ_clone(arg);
20435         return tag_ptr(ret_conv, true);
20436 }
20437 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_clone_ptr(int64_t arg) {
20438         LDKCResult_CoinSelectionNoneZ* arg_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(arg);
20439         int64_t ret_conv = CResult_CoinSelectionNoneZ_clone_ptr(arg_conv);
20440         return ret_conv;
20441 }
20442
20443 int64_t  CS_LDK_CResult_CoinSelectionNoneZ_clone(int64_t orig) {
20444         LDKCResult_CoinSelectionNoneZ* orig_conv = (LDKCResult_CoinSelectionNoneZ*)untag_ptr(orig);
20445         LDKCResult_CoinSelectionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CoinSelectionNoneZ), "LDKCResult_CoinSelectionNoneZ");
20446         *ret_conv = CResult_CoinSelectionNoneZ_clone(orig_conv);
20447         return tag_ptr(ret_conv, true);
20448 }
20449
20450 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_ok(int64_tArray o) {
20451         LDKCVec_UtxoZ o_constr;
20452         o_constr.datalen = o->arr_len;
20453         if (o_constr.datalen > 0)
20454                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
20455         else
20456                 o_constr.data = NULL;
20457         int64_t* o_vals = o->elems;
20458         for (size_t g = 0; g < o_constr.datalen; g++) {
20459                 int64_t o_conv_6 = o_vals[g];
20460                 LDKUtxo o_conv_6_conv;
20461                 o_conv_6_conv.inner = untag_ptr(o_conv_6);
20462                 o_conv_6_conv.is_owned = ptr_is_owned(o_conv_6);
20463                 CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv_6_conv);
20464                 o_conv_6_conv = Utxo_clone(&o_conv_6_conv);
20465                 o_constr.data[g] = o_conv_6_conv;
20466         }
20467         FREE(o);
20468         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20469         *ret_conv = CResult_CVec_UtxoZNoneZ_ok(o_constr);
20470         return tag_ptr(ret_conv, true);
20471 }
20472
20473 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_err() {
20474         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20475         *ret_conv = CResult_CVec_UtxoZNoneZ_err();
20476         return tag_ptr(ret_conv, true);
20477 }
20478
20479 jboolean  CS_LDK_CResult_CVec_UtxoZNoneZ_is_ok(int64_t o) {
20480         LDKCResult_CVec_UtxoZNoneZ* o_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(o);
20481         jboolean ret_conv = CResult_CVec_UtxoZNoneZ_is_ok(o_conv);
20482         return ret_conv;
20483 }
20484
20485 void  CS_LDK_CResult_CVec_UtxoZNoneZ_free(int64_t _res) {
20486         if (!ptr_is_owned(_res)) return;
20487         void* _res_ptr = untag_ptr(_res);
20488         CHECK_ACCESS(_res_ptr);
20489         LDKCResult_CVec_UtxoZNoneZ _res_conv = *(LDKCResult_CVec_UtxoZNoneZ*)(_res_ptr);
20490         FREE(untag_ptr(_res));
20491         CResult_CVec_UtxoZNoneZ_free(_res_conv);
20492 }
20493
20494 static inline uint64_t CResult_CVec_UtxoZNoneZ_clone_ptr(LDKCResult_CVec_UtxoZNoneZ *NONNULL_PTR arg) {
20495         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20496         *ret_conv = CResult_CVec_UtxoZNoneZ_clone(arg);
20497         return tag_ptr(ret_conv, true);
20498 }
20499 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_clone_ptr(int64_t arg) {
20500         LDKCResult_CVec_UtxoZNoneZ* arg_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(arg);
20501         int64_t ret_conv = CResult_CVec_UtxoZNoneZ_clone_ptr(arg_conv);
20502         return ret_conv;
20503 }
20504
20505 int64_t  CS_LDK_CResult_CVec_UtxoZNoneZ_clone(int64_t orig) {
20506         LDKCResult_CVec_UtxoZNoneZ* orig_conv = (LDKCResult_CVec_UtxoZNoneZ*)untag_ptr(orig);
20507         LDKCResult_CVec_UtxoZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_UtxoZNoneZ), "LDKCResult_CVec_UtxoZNoneZ");
20508         *ret_conv = CResult_CVec_UtxoZNoneZ_clone(orig_conv);
20509         return tag_ptr(ret_conv, true);
20510 }
20511
20512 static inline uint64_t C2Tuple_u64u16Z_clone_ptr(LDKC2Tuple_u64u16Z *NONNULL_PTR arg) {
20513         LDKC2Tuple_u64u16Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
20514         *ret_conv = C2Tuple_u64u16Z_clone(arg);
20515         return tag_ptr(ret_conv, true);
20516 }
20517 int64_t  CS_LDK_C2Tuple_u64u16Z_clone_ptr(int64_t arg) {
20518         LDKC2Tuple_u64u16Z* arg_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(arg);
20519         int64_t ret_conv = C2Tuple_u64u16Z_clone_ptr(arg_conv);
20520         return ret_conv;
20521 }
20522
20523 int64_t  CS_LDK_C2Tuple_u64u16Z_clone(int64_t orig) {
20524         LDKC2Tuple_u64u16Z* orig_conv = (LDKC2Tuple_u64u16Z*)untag_ptr(orig);
20525         LDKC2Tuple_u64u16Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
20526         *ret_conv = C2Tuple_u64u16Z_clone(orig_conv);
20527         return tag_ptr(ret_conv, true);
20528 }
20529
20530 int64_t  CS_LDK_C2Tuple_u64u16Z_new(int64_t a, int16_t b) {
20531         LDKC2Tuple_u64u16Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u16Z), "LDKC2Tuple_u64u16Z");
20532         *ret_conv = C2Tuple_u64u16Z_new(a, b);
20533         return tag_ptr(ret_conv, true);
20534 }
20535
20536 void  CS_LDK_C2Tuple_u64u16Z_free(int64_t _res) {
20537         if (!ptr_is_owned(_res)) return;
20538         void* _res_ptr = untag_ptr(_res);
20539         CHECK_ACCESS(_res_ptr);
20540         LDKC2Tuple_u64u16Z _res_conv = *(LDKC2Tuple_u64u16Z*)(_res_ptr);
20541         FREE(untag_ptr(_res));
20542         C2Tuple_u64u16Z_free(_res_conv);
20543 }
20544
20545 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_some(int64_t o) {
20546         void* o_ptr = untag_ptr(o);
20547         CHECK_ACCESS(o_ptr);
20548         LDKC2Tuple_u64u16Z o_conv = *(LDKC2Tuple_u64u16Z*)(o_ptr);
20549         o_conv = C2Tuple_u64u16Z_clone((LDKC2Tuple_u64u16Z*)untag_ptr(o));
20550         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20551         *ret_copy = COption_C2Tuple_u64u16ZZ_some(o_conv);
20552         int64_t ret_ref = tag_ptr(ret_copy, true);
20553         return ret_ref;
20554 }
20555
20556 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_none() {
20557         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20558         *ret_copy = COption_C2Tuple_u64u16ZZ_none();
20559         int64_t ret_ref = tag_ptr(ret_copy, true);
20560         return ret_ref;
20561 }
20562
20563 void  CS_LDK_COption_C2Tuple_u64u16ZZ_free(int64_t _res) {
20564         if (!ptr_is_owned(_res)) return;
20565         void* _res_ptr = untag_ptr(_res);
20566         CHECK_ACCESS(_res_ptr);
20567         LDKCOption_C2Tuple_u64u16ZZ _res_conv = *(LDKCOption_C2Tuple_u64u16ZZ*)(_res_ptr);
20568         FREE(untag_ptr(_res));
20569         COption_C2Tuple_u64u16ZZ_free(_res_conv);
20570 }
20571
20572 static inline uint64_t COption_C2Tuple_u64u16ZZ_clone_ptr(LDKCOption_C2Tuple_u64u16ZZ *NONNULL_PTR arg) {
20573         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20574         *ret_copy = COption_C2Tuple_u64u16ZZ_clone(arg);
20575         int64_t ret_ref = tag_ptr(ret_copy, true);
20576         return ret_ref;
20577 }
20578 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_clone_ptr(int64_t arg) {
20579         LDKCOption_C2Tuple_u64u16ZZ* arg_conv = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(arg);
20580         int64_t ret_conv = COption_C2Tuple_u64u16ZZ_clone_ptr(arg_conv);
20581         return ret_conv;
20582 }
20583
20584 int64_t  CS_LDK_COption_C2Tuple_u64u16ZZ_clone(int64_t orig) {
20585         LDKCOption_C2Tuple_u64u16ZZ* orig_conv = (LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(orig);
20586         LDKCOption_C2Tuple_u64u16ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u16ZZ), "LDKCOption_C2Tuple_u64u16ZZ");
20587         *ret_copy = COption_C2Tuple_u64u16ZZ_clone(orig_conv);
20588         int64_t ret_ref = tag_ptr(ret_copy, true);
20589         return ret_ref;
20590 }
20591
20592 int64_t  CS_LDK_COption_ChannelShutdownStateZ_some(int32_t o) {
20593         LDKChannelShutdownState o_conv = LDKChannelShutdownState_from_cs(o);
20594         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20595         *ret_copy = COption_ChannelShutdownStateZ_some(o_conv);
20596         int64_t ret_ref = tag_ptr(ret_copy, true);
20597         return ret_ref;
20598 }
20599
20600 int64_t  CS_LDK_COption_ChannelShutdownStateZ_none() {
20601         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20602         *ret_copy = COption_ChannelShutdownStateZ_none();
20603         int64_t ret_ref = tag_ptr(ret_copy, true);
20604         return ret_ref;
20605 }
20606
20607 void  CS_LDK_COption_ChannelShutdownStateZ_free(int64_t _res) {
20608         if (!ptr_is_owned(_res)) return;
20609         void* _res_ptr = untag_ptr(_res);
20610         CHECK_ACCESS(_res_ptr);
20611         LDKCOption_ChannelShutdownStateZ _res_conv = *(LDKCOption_ChannelShutdownStateZ*)(_res_ptr);
20612         FREE(untag_ptr(_res));
20613         COption_ChannelShutdownStateZ_free(_res_conv);
20614 }
20615
20616 static inline uint64_t COption_ChannelShutdownStateZ_clone_ptr(LDKCOption_ChannelShutdownStateZ *NONNULL_PTR arg) {
20617         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20618         *ret_copy = COption_ChannelShutdownStateZ_clone(arg);
20619         int64_t ret_ref = tag_ptr(ret_copy, true);
20620         return ret_ref;
20621 }
20622 int64_t  CS_LDK_COption_ChannelShutdownStateZ_clone_ptr(int64_t arg) {
20623         LDKCOption_ChannelShutdownStateZ* arg_conv = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(arg);
20624         int64_t ret_conv = COption_ChannelShutdownStateZ_clone_ptr(arg_conv);
20625         return ret_conv;
20626 }
20627
20628 int64_t  CS_LDK_COption_ChannelShutdownStateZ_clone(int64_t orig) {
20629         LDKCOption_ChannelShutdownStateZ* orig_conv = (LDKCOption_ChannelShutdownStateZ*)untag_ptr(orig);
20630         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
20631         *ret_copy = COption_ChannelShutdownStateZ_clone(orig_conv);
20632         int64_t ret_ref = tag_ptr(ret_copy, true);
20633         return ret_ref;
20634 }
20635
20636 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_ok(int8_tArray o) {
20637         LDKThirtyTwoBytes o_ref;
20638         CHECK(o->arr_len == 32);
20639         memcpy(o_ref.data, o->elems, 32); FREE(o);
20640         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20641         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_ok(o_ref);
20642         return tag_ptr(ret_conv, true);
20643 }
20644
20645 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_err(int64_t e) {
20646         void* e_ptr = untag_ptr(e);
20647         CHECK_ACCESS(e_ptr);
20648         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20649         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20650         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20651         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_err(e_conv);
20652         return tag_ptr(ret_conv, true);
20653 }
20654
20655 jboolean  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_is_ok(int64_t o) {
20656         LDKCResult_ThirtyTwoBytesAPIErrorZ* o_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(o);
20657         jboolean ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_is_ok(o_conv);
20658         return ret_conv;
20659 }
20660
20661 void  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_free(int64_t _res) {
20662         if (!ptr_is_owned(_res)) return;
20663         void* _res_ptr = untag_ptr(_res);
20664         CHECK_ACCESS(_res_ptr);
20665         LDKCResult_ThirtyTwoBytesAPIErrorZ _res_conv = *(LDKCResult_ThirtyTwoBytesAPIErrorZ*)(_res_ptr);
20666         FREE(untag_ptr(_res));
20667         CResult_ThirtyTwoBytesAPIErrorZ_free(_res_conv);
20668 }
20669
20670 static inline uint64_t CResult_ThirtyTwoBytesAPIErrorZ_clone_ptr(LDKCResult_ThirtyTwoBytesAPIErrorZ *NONNULL_PTR arg) {
20671         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20672         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_clone(arg);
20673         return tag_ptr(ret_conv, true);
20674 }
20675 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_clone_ptr(int64_t arg) {
20676         LDKCResult_ThirtyTwoBytesAPIErrorZ* arg_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(arg);
20677         int64_t ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_clone_ptr(arg_conv);
20678         return ret_conv;
20679 }
20680
20681 int64_t  CS_LDK_CResult_ThirtyTwoBytesAPIErrorZ_clone(int64_t orig) {
20682         LDKCResult_ThirtyTwoBytesAPIErrorZ* orig_conv = (LDKCResult_ThirtyTwoBytesAPIErrorZ*)untag_ptr(orig);
20683         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
20684         *ret_conv = CResult_ThirtyTwoBytesAPIErrorZ_clone(orig_conv);
20685         return tag_ptr(ret_conv, true);
20686 }
20687
20688 void  CS_LDK_CVec_RecentPaymentDetailsZ_free(int64_tArray _res) {
20689         LDKCVec_RecentPaymentDetailsZ _res_constr;
20690         _res_constr.datalen = _res->arr_len;
20691         if (_res_constr.datalen > 0)
20692                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRecentPaymentDetails), "LDKCVec_RecentPaymentDetailsZ Elements");
20693         else
20694                 _res_constr.data = NULL;
20695         int64_t* _res_vals = _res->elems;
20696         for (size_t w = 0; w < _res_constr.datalen; w++) {
20697                 int64_t _res_conv_22 = _res_vals[w];
20698                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
20699                 CHECK_ACCESS(_res_conv_22_ptr);
20700                 LDKRecentPaymentDetails _res_conv_22_conv = *(LDKRecentPaymentDetails*)(_res_conv_22_ptr);
20701                 FREE(untag_ptr(_res_conv_22));
20702                 _res_constr.data[w] = _res_conv_22_conv;
20703         }
20704         FREE(_res);
20705         CVec_RecentPaymentDetailsZ_free(_res_constr);
20706 }
20707
20708 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_ok() {
20709         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20710         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20711         return tag_ptr(ret_conv, true);
20712 }
20713
20714 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_err(int64_t e) {
20715         void* e_ptr = untag_ptr(e);
20716         CHECK_ACCESS(e_ptr);
20717         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20718         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20719         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20720         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20721         return tag_ptr(ret_conv, true);
20722 }
20723
20724 jboolean  CS_LDK_CResult_NonePaymentSendFailureZ_is_ok(int64_t o) {
20725         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20726         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20727         return ret_conv;
20728 }
20729
20730 void  CS_LDK_CResult_NonePaymentSendFailureZ_free(int64_t _res) {
20731         if (!ptr_is_owned(_res)) return;
20732         void* _res_ptr = untag_ptr(_res);
20733         CHECK_ACCESS(_res_ptr);
20734         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20735         FREE(untag_ptr(_res));
20736         CResult_NonePaymentSendFailureZ_free(_res_conv);
20737 }
20738
20739 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20740         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20741         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20742         return tag_ptr(ret_conv, true);
20743 }
20744 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_clone_ptr(int64_t arg) {
20745         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20746         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20747         return ret_conv;
20748 }
20749
20750 int64_t  CS_LDK_CResult_NonePaymentSendFailureZ_clone(int64_t orig) {
20751         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20752         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20753         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20754         return tag_ptr(ret_conv, true);
20755 }
20756
20757 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_ok() {
20758         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20759         *ret_conv = CResult_NoneRetryableSendFailureZ_ok();
20760         return tag_ptr(ret_conv, true);
20761 }
20762
20763 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_err(int32_t e) {
20764         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_cs(e);
20765         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20766         *ret_conv = CResult_NoneRetryableSendFailureZ_err(e_conv);
20767         return tag_ptr(ret_conv, true);
20768 }
20769
20770 jboolean  CS_LDK_CResult_NoneRetryableSendFailureZ_is_ok(int64_t o) {
20771         LDKCResult_NoneRetryableSendFailureZ* o_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(o);
20772         jboolean ret_conv = CResult_NoneRetryableSendFailureZ_is_ok(o_conv);
20773         return ret_conv;
20774 }
20775
20776 void  CS_LDK_CResult_NoneRetryableSendFailureZ_free(int64_t _res) {
20777         if (!ptr_is_owned(_res)) return;
20778         void* _res_ptr = untag_ptr(_res);
20779         CHECK_ACCESS(_res_ptr);
20780         LDKCResult_NoneRetryableSendFailureZ _res_conv = *(LDKCResult_NoneRetryableSendFailureZ*)(_res_ptr);
20781         FREE(untag_ptr(_res));
20782         CResult_NoneRetryableSendFailureZ_free(_res_conv);
20783 }
20784
20785 static inline uint64_t CResult_NoneRetryableSendFailureZ_clone_ptr(LDKCResult_NoneRetryableSendFailureZ *NONNULL_PTR arg) {
20786         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20787         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(arg);
20788         return tag_ptr(ret_conv, true);
20789 }
20790 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_clone_ptr(int64_t arg) {
20791         LDKCResult_NoneRetryableSendFailureZ* arg_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(arg);
20792         int64_t ret_conv = CResult_NoneRetryableSendFailureZ_clone_ptr(arg_conv);
20793         return ret_conv;
20794 }
20795
20796 int64_t  CS_LDK_CResult_NoneRetryableSendFailureZ_clone(int64_t orig) {
20797         LDKCResult_NoneRetryableSendFailureZ* orig_conv = (LDKCResult_NoneRetryableSendFailureZ*)untag_ptr(orig);
20798         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
20799         *ret_conv = CResult_NoneRetryableSendFailureZ_clone(orig_conv);
20800         return tag_ptr(ret_conv, true);
20801 }
20802
20803 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_ok(int8_tArray o) {
20804         LDKThirtyTwoBytes o_ref;
20805         CHECK(o->arr_len == 32);
20806         memcpy(o_ref.data, o->elems, 32); FREE(o);
20807         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20808         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_ok(o_ref);
20809         return tag_ptr(ret_conv, true);
20810 }
20811
20812 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_err(int64_t e) {
20813         void* e_ptr = untag_ptr(e);
20814         CHECK_ACCESS(e_ptr);
20815         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20816         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20817         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20818         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_err(e_conv);
20819         return tag_ptr(ret_conv, true);
20820 }
20821
20822 jboolean  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_is_ok(int64_t o) {
20823         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* o_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(o);
20824         jboolean ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_is_ok(o_conv);
20825         return ret_conv;
20826 }
20827
20828 void  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_free(int64_t _res) {
20829         if (!ptr_is_owned(_res)) return;
20830         void* _res_ptr = untag_ptr(_res);
20831         CHECK_ACCESS(_res_ptr);
20832         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ _res_conv = *(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)(_res_ptr);
20833         FREE(untag_ptr(_res));
20834         CResult_ThirtyTwoBytesPaymentSendFailureZ_free(_res_conv);
20835 }
20836
20837 static inline uint64_t CResult_ThirtyTwoBytesPaymentSendFailureZ_clone_ptr(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ *NONNULL_PTR arg) {
20838         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20839         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(arg);
20840         return tag_ptr(ret_conv, true);
20841 }
20842 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_clone_ptr(int64_t arg) {
20843         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* arg_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(arg);
20844         int64_t ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_clone_ptr(arg_conv);
20845         return ret_conv;
20846 }
20847
20848 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(int64_t orig) {
20849         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* orig_conv = (LDKCResult_ThirtyTwoBytesPaymentSendFailureZ*)untag_ptr(orig);
20850         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
20851         *ret_conv = CResult_ThirtyTwoBytesPaymentSendFailureZ_clone(orig_conv);
20852         return tag_ptr(ret_conv, true);
20853 }
20854
20855 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_ok(int8_tArray o) {
20856         LDKThirtyTwoBytes o_ref;
20857         CHECK(o->arr_len == 32);
20858         memcpy(o_ref.data, o->elems, 32); FREE(o);
20859         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20860         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_ok(o_ref);
20861         return tag_ptr(ret_conv, true);
20862 }
20863
20864 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_err(int32_t e) {
20865         LDKRetryableSendFailure e_conv = LDKRetryableSendFailure_from_cs(e);
20866         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20867         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_err(e_conv);
20868         return tag_ptr(ret_conv, true);
20869 }
20870
20871 jboolean  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_is_ok(int64_t o) {
20872         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* o_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(o);
20873         jboolean ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_is_ok(o_conv);
20874         return ret_conv;
20875 }
20876
20877 void  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_free(int64_t _res) {
20878         if (!ptr_is_owned(_res)) return;
20879         void* _res_ptr = untag_ptr(_res);
20880         CHECK_ACCESS(_res_ptr);
20881         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ _res_conv = *(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)(_res_ptr);
20882         FREE(untag_ptr(_res));
20883         CResult_ThirtyTwoBytesRetryableSendFailureZ_free(_res_conv);
20884 }
20885
20886 static inline uint64_t CResult_ThirtyTwoBytesRetryableSendFailureZ_clone_ptr(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ *NONNULL_PTR arg) {
20887         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20888         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(arg);
20889         return tag_ptr(ret_conv, true);
20890 }
20891 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_clone_ptr(int64_t arg) {
20892         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* arg_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(arg);
20893         int64_t ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_clone_ptr(arg_conv);
20894         return ret_conv;
20895 }
20896
20897 int64_t  CS_LDK_CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(int64_t orig) {
20898         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* orig_conv = (LDKCResult_ThirtyTwoBytesRetryableSendFailureZ*)untag_ptr(orig);
20899         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
20900         *ret_conv = CResult_ThirtyTwoBytesRetryableSendFailureZ_clone(orig_conv);
20901         return tag_ptr(ret_conv, true);
20902 }
20903
20904 static inline uint64_t C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ *NONNULL_PTR arg) {
20905         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
20906         *ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(arg);
20907         return tag_ptr(ret_conv, true);
20908 }
20909 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone_ptr(int64_t arg) {
20910         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(arg);
20911         int64_t ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone_ptr(arg_conv);
20912         return ret_conv;
20913 }
20914
20915 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(int64_t orig) {
20916         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(orig);
20917         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
20918         *ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone(orig_conv);
20919         return tag_ptr(ret_conv, true);
20920 }
20921
20922 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_new(int8_tArray a, int8_tArray b) {
20923         LDKThirtyTwoBytes a_ref;
20924         CHECK(a->arr_len == 32);
20925         memcpy(a_ref.data, a->elems, 32); FREE(a);
20926         LDKThirtyTwoBytes b_ref;
20927         CHECK(b->arr_len == 32);
20928         memcpy(b_ref.data, b->elems, 32); FREE(b);
20929         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ");
20930         *ret_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_new(a_ref, b_ref);
20931         return tag_ptr(ret_conv, true);
20932 }
20933
20934 void  CS_LDK_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_free(int64_t _res) {
20935         if (!ptr_is_owned(_res)) return;
20936         void* _res_ptr = untag_ptr(_res);
20937         CHECK_ACCESS(_res_ptr);
20938         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(_res_ptr);
20939         FREE(untag_ptr(_res));
20940         C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_free(_res_conv);
20941 }
20942
20943 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_ok(int64_t o) {
20944         void* o_ptr = untag_ptr(o);
20945         CHECK_ACCESS(o_ptr);
20946         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_ptr);
20947         o_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o));
20948         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20949         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_ok(o_conv);
20950         return tag_ptr(ret_conv, true);
20951 }
20952
20953 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_err(int64_t e) {
20954         void* e_ptr = untag_ptr(e);
20955         CHECK_ACCESS(e_ptr);
20956         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20957         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20958         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20959         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_err(e_conv);
20960         return tag_ptr(ret_conv, true);
20961 }
20962
20963 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_is_ok(int64_t o) {
20964         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(o);
20965         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_is_ok(o_conv);
20966         return ret_conv;
20967 }
20968
20969 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_free(int64_t _res) {
20970         if (!ptr_is_owned(_res)) return;
20971         void* _res_ptr = untag_ptr(_res);
20972         CHECK_ACCESS(_res_ptr);
20973         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)(_res_ptr);
20974         FREE(untag_ptr(_res));
20975         CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_free(_res_conv);
20976 }
20977
20978 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ *NONNULL_PTR arg) {
20979         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20980         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(arg);
20981         return tag_ptr(ret_conv, true);
20982 }
20983 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone_ptr(int64_t arg) {
20984         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(arg);
20985         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone_ptr(arg_conv);
20986         return ret_conv;
20987 }
20988
20989 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(int64_t orig) {
20990         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ*)untag_ptr(orig);
20991         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
20992         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ_clone(orig_conv);
20993         return tag_ptr(ret_conv, true);
20994 }
20995
20996 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_free(int64_tArray _res) {
20997         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ _res_constr;
20998         _res_constr.datalen = _res->arr_len;
20999         if (_res_constr.datalen > 0)
21000                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ Elements");
21001         else
21002                 _res_constr.data = NULL;
21003         int64_t* _res_vals = _res->elems;
21004         for (size_t o = 0; o < _res_constr.datalen; o++) {
21005                 int64_t _res_conv_40 = _res_vals[o];
21006                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
21007                 CHECK_ACCESS(_res_conv_40_ptr);
21008                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ _res_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(_res_conv_40_ptr);
21009                 FREE(untag_ptr(_res_conv_40));
21010                 _res_constr.data[o] = _res_conv_40_conv;
21011         }
21012         FREE(_res);
21013         CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ_free(_res_constr);
21014 }
21015
21016 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_ok(int64_tArray o) {
21017         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ o_constr;
21018         o_constr.datalen = o->arr_len;
21019         if (o_constr.datalen > 0)
21020                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ Elements");
21021         else
21022                 o_constr.data = NULL;
21023         int64_t* o_vals = o->elems;
21024         for (size_t o = 0; o < o_constr.datalen; o++) {
21025                 int64_t o_conv_40 = o_vals[o];
21026                 void* o_conv_40_ptr = untag_ptr(o_conv_40);
21027                 CHECK_ACCESS(o_conv_40_ptr);
21028                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_conv_40_ptr);
21029                 o_conv_40_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o_conv_40));
21030                 o_constr.data[o] = o_conv_40_conv;
21031         }
21032         FREE(o);
21033         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21034         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_ok(o_constr);
21035         return tag_ptr(ret_conv, true);
21036 }
21037
21038 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_err(int64_t e) {
21039         void* e_ptr = untag_ptr(e);
21040         CHECK_ACCESS(e_ptr);
21041         LDKProbeSendFailure e_conv = *(LDKProbeSendFailure*)(e_ptr);
21042         e_conv = ProbeSendFailure_clone((LDKProbeSendFailure*)untag_ptr(e));
21043         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21044         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_err(e_conv);
21045         return tag_ptr(ret_conv, true);
21046 }
21047
21048 jboolean  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_is_ok(int64_t o) {
21049         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* o_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(o);
21050         jboolean ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_is_ok(o_conv);
21051         return ret_conv;
21052 }
21053
21054 void  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_free(int64_t _res) {
21055         if (!ptr_is_owned(_res)) return;
21056         void* _res_ptr = untag_ptr(_res);
21057         CHECK_ACCESS(_res_ptr);
21058         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ _res_conv = *(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)(_res_ptr);
21059         FREE(untag_ptr(_res));
21060         CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_free(_res_conv);
21061 }
21062
21063 static inline uint64_t CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone_ptr(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ *NONNULL_PTR arg) {
21064         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21065         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(arg);
21066         return tag_ptr(ret_conv, true);
21067 }
21068 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone_ptr(int64_t arg) {
21069         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* arg_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(arg);
21070         int64_t ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone_ptr(arg_conv);
21071         return ret_conv;
21072 }
21073
21074 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(int64_t orig) {
21075         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* orig_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ*)untag_ptr(orig);
21076         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
21077         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ_clone(orig_conv);
21078         return tag_ptr(ret_conv, true);
21079 }
21080
21081 static inline uint64_t C2Tuple_ThirtyTwoBytesPublicKeyZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ *NONNULL_PTR arg) {
21082         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKC2Tuple_ThirtyTwoBytesPublicKeyZ");
21083         *ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(arg);
21084         return tag_ptr(ret_conv, true);
21085 }
21086 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_clone_ptr(int64_t arg) {
21087         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(arg);
21088         int64_t ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone_ptr(arg_conv);
21089         return ret_conv;
21090 }
21091
21092 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(int64_t orig) {
21093         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(orig);
21094         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKC2Tuple_ThirtyTwoBytesPublicKeyZ");
21095         *ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone(orig_conv);
21096         return tag_ptr(ret_conv, true);
21097 }
21098
21099 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_new(int8_tArray a, int8_tArray b) {
21100         LDKThirtyTwoBytes a_ref;
21101         CHECK(a->arr_len == 32);
21102         memcpy(a_ref.data, a->elems, 32); FREE(a);
21103         LDKPublicKey b_ref;
21104         CHECK(b->arr_len == 33);
21105         memcpy(b_ref.compressed_form, b->elems, 33); FREE(b);
21106         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKC2Tuple_ThirtyTwoBytesPublicKeyZ");
21107         *ret_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_new(a_ref, b_ref);
21108         return tag_ptr(ret_conv, true);
21109 }
21110
21111 void  CS_LDK_C2Tuple_ThirtyTwoBytesPublicKeyZ_free(int64_t _res) {
21112         if (!ptr_is_owned(_res)) return;
21113         void* _res_ptr = untag_ptr(_res);
21114         CHECK_ACCESS(_res_ptr);
21115         LDKC2Tuple_ThirtyTwoBytesPublicKeyZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)(_res_ptr);
21116         FREE(untag_ptr(_res));
21117         C2Tuple_ThirtyTwoBytesPublicKeyZ_free(_res_conv);
21118 }
21119
21120 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(int64_tArray _res) {
21121         LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ _res_constr;
21122         _res_constr.datalen = _res->arr_len;
21123         if (_res_constr.datalen > 0)
21124                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ Elements");
21125         else
21126                 _res_constr.data = NULL;
21127         int64_t* _res_vals = _res->elems;
21128         for (size_t j = 0; j < _res_constr.datalen; j++) {
21129                 int64_t _res_conv_35 = _res_vals[j];
21130                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
21131                 CHECK_ACCESS(_res_conv_35_ptr);
21132                 LDKC2Tuple_ThirtyTwoBytesPublicKeyZ _res_conv_35_conv = *(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)(_res_conv_35_ptr);
21133                 FREE(untag_ptr(_res_conv_35));
21134                 _res_constr.data[j] = _res_conv_35_conv;
21135         }
21136         FREE(_res);
21137         CVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ_free(_res_constr);
21138 }
21139
21140 int64_t  CS_LDK_COption_StrZ_some(jstring o) {
21141         LDKStr o_conv = str_ref_to_owned_c(o);
21142         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21143         *ret_copy = COption_StrZ_some(o_conv);
21144         int64_t ret_ref = tag_ptr(ret_copy, true);
21145         return ret_ref;
21146 }
21147
21148 int64_t  CS_LDK_COption_StrZ_none() {
21149         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21150         *ret_copy = COption_StrZ_none();
21151         int64_t ret_ref = tag_ptr(ret_copy, true);
21152         return ret_ref;
21153 }
21154
21155 void  CS_LDK_COption_StrZ_free(int64_t _res) {
21156         if (!ptr_is_owned(_res)) return;
21157         void* _res_ptr = untag_ptr(_res);
21158         CHECK_ACCESS(_res_ptr);
21159         LDKCOption_StrZ _res_conv = *(LDKCOption_StrZ*)(_res_ptr);
21160         FREE(untag_ptr(_res));
21161         COption_StrZ_free(_res_conv);
21162 }
21163
21164 static inline uint64_t COption_StrZ_clone_ptr(LDKCOption_StrZ *NONNULL_PTR arg) {
21165         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21166         *ret_copy = COption_StrZ_clone(arg);
21167         int64_t ret_ref = tag_ptr(ret_copy, true);
21168         return ret_ref;
21169 }
21170 int64_t  CS_LDK_COption_StrZ_clone_ptr(int64_t arg) {
21171         LDKCOption_StrZ* arg_conv = (LDKCOption_StrZ*)untag_ptr(arg);
21172         int64_t ret_conv = COption_StrZ_clone_ptr(arg_conv);
21173         return ret_conv;
21174 }
21175
21176 int64_t  CS_LDK_COption_StrZ_clone(int64_t orig) {
21177         LDKCOption_StrZ* orig_conv = (LDKCOption_StrZ*)untag_ptr(orig);
21178         LDKCOption_StrZ *ret_copy = MALLOC(sizeof(LDKCOption_StrZ), "LDKCOption_StrZ");
21179         *ret_copy = COption_StrZ_clone(orig_conv);
21180         int64_t ret_ref = tag_ptr(ret_copy, true);
21181         return ret_ref;
21182 }
21183
21184 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_ok() {
21185         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21186         *ret_conv = CResult_NoneBolt12SemanticErrorZ_ok();
21187         return tag_ptr(ret_conv, true);
21188 }
21189
21190 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_err(int32_t e) {
21191         LDKBolt12SemanticError e_conv = LDKBolt12SemanticError_from_cs(e);
21192         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21193         *ret_conv = CResult_NoneBolt12SemanticErrorZ_err(e_conv);
21194         return tag_ptr(ret_conv, true);
21195 }
21196
21197 jboolean  CS_LDK_CResult_NoneBolt12SemanticErrorZ_is_ok(int64_t o) {
21198         LDKCResult_NoneBolt12SemanticErrorZ* o_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(o);
21199         jboolean ret_conv = CResult_NoneBolt12SemanticErrorZ_is_ok(o_conv);
21200         return ret_conv;
21201 }
21202
21203 void  CS_LDK_CResult_NoneBolt12SemanticErrorZ_free(int64_t _res) {
21204         if (!ptr_is_owned(_res)) return;
21205         void* _res_ptr = untag_ptr(_res);
21206         CHECK_ACCESS(_res_ptr);
21207         LDKCResult_NoneBolt12SemanticErrorZ _res_conv = *(LDKCResult_NoneBolt12SemanticErrorZ*)(_res_ptr);
21208         FREE(untag_ptr(_res));
21209         CResult_NoneBolt12SemanticErrorZ_free(_res_conv);
21210 }
21211
21212 static inline uint64_t CResult_NoneBolt12SemanticErrorZ_clone_ptr(LDKCResult_NoneBolt12SemanticErrorZ *NONNULL_PTR arg) {
21213         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21214         *ret_conv = CResult_NoneBolt12SemanticErrorZ_clone(arg);
21215         return tag_ptr(ret_conv, true);
21216 }
21217 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_clone_ptr(int64_t arg) {
21218         LDKCResult_NoneBolt12SemanticErrorZ* arg_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(arg);
21219         int64_t ret_conv = CResult_NoneBolt12SemanticErrorZ_clone_ptr(arg_conv);
21220         return ret_conv;
21221 }
21222
21223 int64_t  CS_LDK_CResult_NoneBolt12SemanticErrorZ_clone(int64_t orig) {
21224         LDKCResult_NoneBolt12SemanticErrorZ* orig_conv = (LDKCResult_NoneBolt12SemanticErrorZ*)untag_ptr(orig);
21225         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
21226         *ret_conv = CResult_NoneBolt12SemanticErrorZ_clone(orig_conv);
21227         return tag_ptr(ret_conv, true);
21228 }
21229
21230 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(int64_t o) {
21231         void* o_ptr = untag_ptr(o);
21232         CHECK_ACCESS(o_ptr);
21233         LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_ptr);
21234         o_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o));
21235         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21236         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_ok(o_conv);
21237         return tag_ptr(ret_conv, true);
21238 }
21239
21240 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err() {
21241         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21242         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_err();
21243         return tag_ptr(ret_conv, true);
21244 }
21245
21246 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(int64_t o) {
21247         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(o);
21248         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_is_ok(o_conv);
21249         return ret_conv;
21250 }
21251
21252 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(int64_t _res) {
21253         if (!ptr_is_owned(_res)) return;
21254         void* _res_ptr = untag_ptr(_res);
21255         CHECK_ACCESS(_res_ptr);
21256         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)(_res_ptr);
21257         FREE(untag_ptr(_res));
21258         CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_free(_res_conv);
21259 }
21260
21261 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ *NONNULL_PTR arg) {
21262         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21263         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(arg);
21264         return tag_ptr(ret_conv, true);
21265 }
21266 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone_ptr(int64_t arg) {
21267         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(arg);
21268         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone_ptr(arg_conv);
21269         return ret_conv;
21270 }
21271
21272 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(int64_t orig) {
21273         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ*)untag_ptr(orig);
21274         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
21275         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ_clone(orig_conv);
21276         return tag_ptr(ret_conv, true);
21277 }
21278
21279 int64_t  CS_LDK_COption_OffersMessageZ_some(int64_t o) {
21280         void* o_ptr = untag_ptr(o);
21281         CHECK_ACCESS(o_ptr);
21282         LDKOffersMessage o_conv = *(LDKOffersMessage*)(o_ptr);
21283         o_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(o));
21284         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21285         *ret_copy = COption_OffersMessageZ_some(o_conv);
21286         int64_t ret_ref = tag_ptr(ret_copy, true);
21287         return ret_ref;
21288 }
21289
21290 int64_t  CS_LDK_COption_OffersMessageZ_none() {
21291         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21292         *ret_copy = COption_OffersMessageZ_none();
21293         int64_t ret_ref = tag_ptr(ret_copy, true);
21294         return ret_ref;
21295 }
21296
21297 void  CS_LDK_COption_OffersMessageZ_free(int64_t _res) {
21298         if (!ptr_is_owned(_res)) return;
21299         void* _res_ptr = untag_ptr(_res);
21300         CHECK_ACCESS(_res_ptr);
21301         LDKCOption_OffersMessageZ _res_conv = *(LDKCOption_OffersMessageZ*)(_res_ptr);
21302         FREE(untag_ptr(_res));
21303         COption_OffersMessageZ_free(_res_conv);
21304 }
21305
21306 static inline uint64_t COption_OffersMessageZ_clone_ptr(LDKCOption_OffersMessageZ *NONNULL_PTR arg) {
21307         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21308         *ret_copy = COption_OffersMessageZ_clone(arg);
21309         int64_t ret_ref = tag_ptr(ret_copy, true);
21310         return ret_ref;
21311 }
21312 int64_t  CS_LDK_COption_OffersMessageZ_clone_ptr(int64_t arg) {
21313         LDKCOption_OffersMessageZ* arg_conv = (LDKCOption_OffersMessageZ*)untag_ptr(arg);
21314         int64_t ret_conv = COption_OffersMessageZ_clone_ptr(arg_conv);
21315         return ret_conv;
21316 }
21317
21318 int64_t  CS_LDK_COption_OffersMessageZ_clone(int64_t orig) {
21319         LDKCOption_OffersMessageZ* orig_conv = (LDKCOption_OffersMessageZ*)untag_ptr(orig);
21320         LDKCOption_OffersMessageZ *ret_copy = MALLOC(sizeof(LDKCOption_OffersMessageZ), "LDKCOption_OffersMessageZ");
21321         *ret_copy = COption_OffersMessageZ_clone(orig_conv);
21322         int64_t ret_ref = tag_ptr(ret_copy, true);
21323         return ret_ref;
21324 }
21325
21326 static inline uint64_t C3Tuple_OffersMessageDestinationBlindedPathZ_clone_ptr(LDKC3Tuple_OffersMessageDestinationBlindedPathZ *NONNULL_PTR arg) {
21327         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
21328         *ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_clone(arg);
21329         return tag_ptr(ret_conv, true);
21330 }
21331 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_clone_ptr(int64_t arg) {
21332         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* arg_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(arg);
21333         int64_t ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_clone_ptr(arg_conv);
21334         return ret_conv;
21335 }
21336
21337 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_clone(int64_t orig) {
21338         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* orig_conv = (LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)untag_ptr(orig);
21339         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
21340         *ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_clone(orig_conv);
21341         return tag_ptr(ret_conv, true);
21342 }
21343
21344 int64_t  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_new(int64_t a, int64_t b, int64_t c) {
21345         void* a_ptr = untag_ptr(a);
21346         CHECK_ACCESS(a_ptr);
21347         LDKOffersMessage a_conv = *(LDKOffersMessage*)(a_ptr);
21348         a_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(a));
21349         void* b_ptr = untag_ptr(b);
21350         CHECK_ACCESS(b_ptr);
21351         LDKDestination b_conv = *(LDKDestination*)(b_ptr);
21352         b_conv = Destination_clone((LDKDestination*)untag_ptr(b));
21353         LDKBlindedPath c_conv;
21354         c_conv.inner = untag_ptr(c);
21355         c_conv.is_owned = ptr_is_owned(c);
21356         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
21357         c_conv = BlindedPath_clone(&c_conv);
21358         LDKC3Tuple_OffersMessageDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKC3Tuple_OffersMessageDestinationBlindedPathZ");
21359         *ret_conv = C3Tuple_OffersMessageDestinationBlindedPathZ_new(a_conv, b_conv, c_conv);
21360         return tag_ptr(ret_conv, true);
21361 }
21362
21363 void  CS_LDK_C3Tuple_OffersMessageDestinationBlindedPathZ_free(int64_t _res) {
21364         if (!ptr_is_owned(_res)) return;
21365         void* _res_ptr = untag_ptr(_res);
21366         CHECK_ACCESS(_res_ptr);
21367         LDKC3Tuple_OffersMessageDestinationBlindedPathZ _res_conv = *(LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)(_res_ptr);
21368         FREE(untag_ptr(_res));
21369         C3Tuple_OffersMessageDestinationBlindedPathZ_free(_res_conv);
21370 }
21371
21372 void  CS_LDK_CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(int64_tArray _res) {
21373         LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ _res_constr;
21374         _res_constr.datalen = _res->arr_len;
21375         if (_res_constr.datalen > 0)
21376                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OffersMessageDestinationBlindedPathZ), "LDKCVec_C3Tuple_OffersMessageDestinationBlindedPathZZ Elements");
21377         else
21378                 _res_constr.data = NULL;
21379         int64_t* _res_vals = _res->elems;
21380         for (size_t x = 0; x < _res_constr.datalen; x++) {
21381                 int64_t _res_conv_49 = _res_vals[x];
21382                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
21383                 CHECK_ACCESS(_res_conv_49_ptr);
21384                 LDKC3Tuple_OffersMessageDestinationBlindedPathZ _res_conv_49_conv = *(LDKC3Tuple_OffersMessageDestinationBlindedPathZ*)(_res_conv_49_ptr);
21385                 FREE(untag_ptr(_res_conv_49));
21386                 _res_constr.data[x] = _res_conv_49_conv;
21387         }
21388         FREE(_res);
21389         CVec_C3Tuple_OffersMessageDestinationBlindedPathZZ_free(_res_constr);
21390 }
21391
21392 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(int64_t o) {
21393         LDKCounterpartyForwardingInfo o_conv;
21394         o_conv.inner = untag_ptr(o);
21395         o_conv.is_owned = ptr_is_owned(o);
21396         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21397         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
21398         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21399         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
21400         return tag_ptr(ret_conv, true);
21401 }
21402
21403 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(int64_t e) {
21404         void* e_ptr = untag_ptr(e);
21405         CHECK_ACCESS(e_ptr);
21406         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21407         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21408         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21409         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
21410         return tag_ptr(ret_conv, true);
21411 }
21412
21413 jboolean  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(int64_t o) {
21414         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
21415         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
21416         return ret_conv;
21417 }
21418
21419 void  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(int64_t _res) {
21420         if (!ptr_is_owned(_res)) return;
21421         void* _res_ptr = untag_ptr(_res);
21422         CHECK_ACCESS(_res_ptr);
21423         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
21424         FREE(untag_ptr(_res));
21425         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
21426 }
21427
21428 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
21429         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21430         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
21431         return tag_ptr(ret_conv, true);
21432 }
21433 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(int64_t arg) {
21434         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
21435         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
21436         return ret_conv;
21437 }
21438
21439 int64_t  CS_LDK_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(int64_t orig) {
21440         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
21441         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21442         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
21443         return tag_ptr(ret_conv, true);
21444 }
21445
21446 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_ok(int64_t o) {
21447         LDKChannelCounterparty o_conv;
21448         o_conv.inner = untag_ptr(o);
21449         o_conv.is_owned = ptr_is_owned(o);
21450         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21451         o_conv = ChannelCounterparty_clone(&o_conv);
21452         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21453         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
21454         return tag_ptr(ret_conv, true);
21455 }
21456
21457 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_err(int64_t e) {
21458         void* e_ptr = untag_ptr(e);
21459         CHECK_ACCESS(e_ptr);
21460         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21461         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21462         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21463         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
21464         return tag_ptr(ret_conv, true);
21465 }
21466
21467 jboolean  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(int64_t o) {
21468         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
21469         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
21470         return ret_conv;
21471 }
21472
21473 void  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_free(int64_t _res) {
21474         if (!ptr_is_owned(_res)) return;
21475         void* _res_ptr = untag_ptr(_res);
21476         CHECK_ACCESS(_res_ptr);
21477         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
21478         FREE(untag_ptr(_res));
21479         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
21480 }
21481
21482 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
21483         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21484         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
21485         return tag_ptr(ret_conv, true);
21486 }
21487 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(int64_t arg) {
21488         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
21489         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
21490         return ret_conv;
21491 }
21492
21493 int64_t  CS_LDK_CResult_ChannelCounterpartyDecodeErrorZ_clone(int64_t orig) {
21494         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
21495         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21496         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
21497         return tag_ptr(ret_conv, true);
21498 }
21499
21500 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_ok(int64_t o) {
21501         LDKChannelDetails o_conv;
21502         o_conv.inner = untag_ptr(o);
21503         o_conv.is_owned = ptr_is_owned(o);
21504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21505         o_conv = ChannelDetails_clone(&o_conv);
21506         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21507         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
21508         return tag_ptr(ret_conv, true);
21509 }
21510
21511 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_err(int64_t e) {
21512         void* e_ptr = untag_ptr(e);
21513         CHECK_ACCESS(e_ptr);
21514         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21515         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21516         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21517         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
21518         return tag_ptr(ret_conv, true);
21519 }
21520
21521 jboolean  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_is_ok(int64_t o) {
21522         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
21523         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
21524         return ret_conv;
21525 }
21526
21527 void  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_free(int64_t _res) {
21528         if (!ptr_is_owned(_res)) return;
21529         void* _res_ptr = untag_ptr(_res);
21530         CHECK_ACCESS(_res_ptr);
21531         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
21532         FREE(untag_ptr(_res));
21533         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
21534 }
21535
21536 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
21537         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21538         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
21539         return tag_ptr(ret_conv, true);
21540 }
21541 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(int64_t arg) {
21542         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
21543         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
21544         return ret_conv;
21545 }
21546
21547 int64_t  CS_LDK_CResult_ChannelDetailsDecodeErrorZ_clone(int64_t orig) {
21548         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
21549         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21550         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
21551         return tag_ptr(ret_conv, true);
21552 }
21553
21554 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_ok(int64_t o) {
21555         LDKPhantomRouteHints o_conv;
21556         o_conv.inner = untag_ptr(o);
21557         o_conv.is_owned = ptr_is_owned(o);
21558         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21559         o_conv = PhantomRouteHints_clone(&o_conv);
21560         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21561         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
21562         return tag_ptr(ret_conv, true);
21563 }
21564
21565 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_err(int64_t e) {
21566         void* e_ptr = untag_ptr(e);
21567         CHECK_ACCESS(e_ptr);
21568         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21569         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21570         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21571         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
21572         return tag_ptr(ret_conv, true);
21573 }
21574
21575 jboolean  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(int64_t o) {
21576         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
21577         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
21578         return ret_conv;
21579 }
21580
21581 void  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_free(int64_t _res) {
21582         if (!ptr_is_owned(_res)) return;
21583         void* _res_ptr = untag_ptr(_res);
21584         CHECK_ACCESS(_res_ptr);
21585         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
21586         FREE(untag_ptr(_res));
21587         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
21588 }
21589
21590 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
21591         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21592         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
21593         return tag_ptr(ret_conv, true);
21594 }
21595 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(int64_t arg) {
21596         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
21597         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
21598         return ret_conv;
21599 }
21600
21601 int64_t  CS_LDK_CResult_PhantomRouteHintsDecodeErrorZ_clone(int64_t orig) {
21602         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
21603         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21604         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
21605         return tag_ptr(ret_conv, true);
21606 }
21607
21608 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_ok(int32_t o) {
21609         LDKChannelShutdownState o_conv = LDKChannelShutdownState_from_cs(o);
21610         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21611         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_ok(o_conv);
21612         return tag_ptr(ret_conv, true);
21613 }
21614
21615 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_err(int64_t e) {
21616         void* e_ptr = untag_ptr(e);
21617         CHECK_ACCESS(e_ptr);
21618         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21619         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21620         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21621         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_err(e_conv);
21622         return tag_ptr(ret_conv, true);
21623 }
21624
21625 jboolean  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_is_ok(int64_t o) {
21626         LDKCResult_ChannelShutdownStateDecodeErrorZ* o_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(o);
21627         jboolean ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_is_ok(o_conv);
21628         return ret_conv;
21629 }
21630
21631 void  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_free(int64_t _res) {
21632         if (!ptr_is_owned(_res)) return;
21633         void* _res_ptr = untag_ptr(_res);
21634         CHECK_ACCESS(_res_ptr);
21635         LDKCResult_ChannelShutdownStateDecodeErrorZ _res_conv = *(LDKCResult_ChannelShutdownStateDecodeErrorZ*)(_res_ptr);
21636         FREE(untag_ptr(_res));
21637         CResult_ChannelShutdownStateDecodeErrorZ_free(_res_conv);
21638 }
21639
21640 static inline uint64_t CResult_ChannelShutdownStateDecodeErrorZ_clone_ptr(LDKCResult_ChannelShutdownStateDecodeErrorZ *NONNULL_PTR arg) {
21641         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21642         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_clone(arg);
21643         return tag_ptr(ret_conv, true);
21644 }
21645 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_clone_ptr(int64_t arg) {
21646         LDKCResult_ChannelShutdownStateDecodeErrorZ* arg_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(arg);
21647         int64_t ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_clone_ptr(arg_conv);
21648         return ret_conv;
21649 }
21650
21651 int64_t  CS_LDK_CResult_ChannelShutdownStateDecodeErrorZ_clone(int64_t orig) {
21652         LDKCResult_ChannelShutdownStateDecodeErrorZ* orig_conv = (LDKCResult_ChannelShutdownStateDecodeErrorZ*)untag_ptr(orig);
21653         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
21654         *ret_conv = CResult_ChannelShutdownStateDecodeErrorZ_clone(orig_conv);
21655         return tag_ptr(ret_conv, true);
21656 }
21657
21658 void  CS_LDK_CVec_ChannelMonitorZ_free(int64_tArray _res) {
21659         LDKCVec_ChannelMonitorZ _res_constr;
21660         _res_constr.datalen = _res->arr_len;
21661         if (_res_constr.datalen > 0)
21662                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21663         else
21664                 _res_constr.data = NULL;
21665         int64_t* _res_vals = _res->elems;
21666         for (size_t q = 0; q < _res_constr.datalen; q++) {
21667                 int64_t _res_conv_16 = _res_vals[q];
21668                 LDKChannelMonitor _res_conv_16_conv;
21669                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
21670                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
21671                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21672                 _res_constr.data[q] = _res_conv_16_conv;
21673         }
21674         FREE(_res);
21675         CVec_ChannelMonitorZ_free(_res_constr);
21676 }
21677
21678 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_new(int8_tArray a, int64_t b) {
21679         LDKThirtyTwoBytes a_ref;
21680         CHECK(a->arr_len == 32);
21681         memcpy(a_ref.data, a->elems, 32); FREE(a);
21682         LDKChannelManager b_conv;
21683         b_conv.inner = untag_ptr(b);
21684         b_conv.is_owned = ptr_is_owned(b);
21685         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21686         // WARNING: we need a move here but no clone is available for LDKChannelManager
21687         
21688         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ), "LDKC2Tuple_ThirtyTwoBytesChannelManagerZ");
21689         *ret_conv = C2Tuple_ThirtyTwoBytesChannelManagerZ_new(a_ref, b_conv);
21690         return tag_ptr(ret_conv, true);
21691 }
21692
21693 void  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_free(int64_t _res) {
21694         if (!ptr_is_owned(_res)) return;
21695         void* _res_ptr = untag_ptr(_res);
21696         CHECK_ACCESS(_res_ptr);
21697         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)(_res_ptr);
21698         FREE(untag_ptr(_res));
21699         C2Tuple_ThirtyTwoBytesChannelManagerZ_free(_res_conv);
21700 }
21701
21702 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_ok(int64_t o) {
21703         void* o_ptr = untag_ptr(o);
21704         CHECK_ACCESS(o_ptr);
21705         LDKC2Tuple_ThirtyTwoBytesChannelManagerZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelManagerZ*)(o_ptr);
21706         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_ThirtyTwoBytesChannelManagerZ
21707         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ");
21708         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_ok(o_conv);
21709         return tag_ptr(ret_conv, true);
21710 }
21711
21712 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_err(int64_t e) {
21713         void* e_ptr = untag_ptr(e);
21714         CHECK_ACCESS(e_ptr);
21715         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21716         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21717         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ");
21718         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_err(e_conv);
21719         return tag_ptr(ret_conv, true);
21720 }
21721
21722 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_is_ok(int64_t o) {
21723         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)untag_ptr(o);
21724         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_is_ok(o_conv);
21725         return ret_conv;
21726 }
21727
21728 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_free(int64_t _res) {
21729         if (!ptr_is_owned(_res)) return;
21730         void* _res_ptr = untag_ptr(_res);
21731         CHECK_ACCESS(_res_ptr);
21732         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ*)(_res_ptr);
21733         FREE(untag_ptr(_res));
21734         CResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_free(_res_conv);
21735 }
21736
21737 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_ok(int64_t o) {
21738         void* o_ptr = untag_ptr(o);
21739         CHECK_ACCESS(o_ptr);
21740         LDKMaxDustHTLCExposure o_conv = *(LDKMaxDustHTLCExposure*)(o_ptr);
21741         o_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(o));
21742         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21743         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_ok(o_conv);
21744         return tag_ptr(ret_conv, true);
21745 }
21746
21747 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_err(int64_t e) {
21748         void* e_ptr = untag_ptr(e);
21749         CHECK_ACCESS(e_ptr);
21750         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21751         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21752         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21753         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_err(e_conv);
21754         return tag_ptr(ret_conv, true);
21755 }
21756
21757 jboolean  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(int64_t o) {
21758         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* o_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(o);
21759         jboolean ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_is_ok(o_conv);
21760         return ret_conv;
21761 }
21762
21763 void  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_free(int64_t _res) {
21764         if (!ptr_is_owned(_res)) return;
21765         void* _res_ptr = untag_ptr(_res);
21766         CHECK_ACCESS(_res_ptr);
21767         LDKCResult_MaxDustHTLCExposureDecodeErrorZ _res_conv = *(LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)(_res_ptr);
21768         FREE(untag_ptr(_res));
21769         CResult_MaxDustHTLCExposureDecodeErrorZ_free(_res_conv);
21770 }
21771
21772 static inline uint64_t CResult_MaxDustHTLCExposureDecodeErrorZ_clone_ptr(LDKCResult_MaxDustHTLCExposureDecodeErrorZ *NONNULL_PTR arg) {
21773         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21774         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_clone(arg);
21775         return tag_ptr(ret_conv, true);
21776 }
21777 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_clone_ptr(int64_t arg) {
21778         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* arg_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(arg);
21779         int64_t ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_clone_ptr(arg_conv);
21780         return ret_conv;
21781 }
21782
21783 int64_t  CS_LDK_CResult_MaxDustHTLCExposureDecodeErrorZ_clone(int64_t orig) {
21784         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* orig_conv = (LDKCResult_MaxDustHTLCExposureDecodeErrorZ*)untag_ptr(orig);
21785         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
21786         *ret_conv = CResult_MaxDustHTLCExposureDecodeErrorZ_clone(orig_conv);
21787         return tag_ptr(ret_conv, true);
21788 }
21789
21790 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_ok(int64_t o) {
21791         LDKChannelConfig o_conv;
21792         o_conv.inner = untag_ptr(o);
21793         o_conv.is_owned = ptr_is_owned(o);
21794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21795         o_conv = ChannelConfig_clone(&o_conv);
21796         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21797         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
21798         return tag_ptr(ret_conv, true);
21799 }
21800
21801 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_err(int64_t e) {
21802         void* e_ptr = untag_ptr(e);
21803         CHECK_ACCESS(e_ptr);
21804         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21805         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21806         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21807         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
21808         return tag_ptr(ret_conv, true);
21809 }
21810
21811 jboolean  CS_LDK_CResult_ChannelConfigDecodeErrorZ_is_ok(int64_t o) {
21812         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
21813         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
21814         return ret_conv;
21815 }
21816
21817 void  CS_LDK_CResult_ChannelConfigDecodeErrorZ_free(int64_t _res) {
21818         if (!ptr_is_owned(_res)) return;
21819         void* _res_ptr = untag_ptr(_res);
21820         CHECK_ACCESS(_res_ptr);
21821         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
21822         FREE(untag_ptr(_res));
21823         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
21824 }
21825
21826 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
21827         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21828         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
21829         return tag_ptr(ret_conv, true);
21830 }
21831 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_clone_ptr(int64_t arg) {
21832         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
21833         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
21834         return ret_conv;
21835 }
21836
21837 int64_t  CS_LDK_CResult_ChannelConfigDecodeErrorZ_clone(int64_t orig) {
21838         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
21839         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21840         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
21841         return tag_ptr(ret_conv, true);
21842 }
21843
21844 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_some(int64_t o) {
21845         void* o_ptr = untag_ptr(o);
21846         CHECK_ACCESS(o_ptr);
21847         LDKMaxDustHTLCExposure o_conv = *(LDKMaxDustHTLCExposure*)(o_ptr);
21848         o_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(o));
21849         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21850         *ret_copy = COption_MaxDustHTLCExposureZ_some(o_conv);
21851         int64_t ret_ref = tag_ptr(ret_copy, true);
21852         return ret_ref;
21853 }
21854
21855 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_none() {
21856         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21857         *ret_copy = COption_MaxDustHTLCExposureZ_none();
21858         int64_t ret_ref = tag_ptr(ret_copy, true);
21859         return ret_ref;
21860 }
21861
21862 void  CS_LDK_COption_MaxDustHTLCExposureZ_free(int64_t _res) {
21863         if (!ptr_is_owned(_res)) return;
21864         void* _res_ptr = untag_ptr(_res);
21865         CHECK_ACCESS(_res_ptr);
21866         LDKCOption_MaxDustHTLCExposureZ _res_conv = *(LDKCOption_MaxDustHTLCExposureZ*)(_res_ptr);
21867         FREE(untag_ptr(_res));
21868         COption_MaxDustHTLCExposureZ_free(_res_conv);
21869 }
21870
21871 static inline uint64_t COption_MaxDustHTLCExposureZ_clone_ptr(LDKCOption_MaxDustHTLCExposureZ *NONNULL_PTR arg) {
21872         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21873         *ret_copy = COption_MaxDustHTLCExposureZ_clone(arg);
21874         int64_t ret_ref = tag_ptr(ret_copy, true);
21875         return ret_ref;
21876 }
21877 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_clone_ptr(int64_t arg) {
21878         LDKCOption_MaxDustHTLCExposureZ* arg_conv = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(arg);
21879         int64_t ret_conv = COption_MaxDustHTLCExposureZ_clone_ptr(arg_conv);
21880         return ret_conv;
21881 }
21882
21883 int64_t  CS_LDK_COption_MaxDustHTLCExposureZ_clone(int64_t orig) {
21884         LDKCOption_MaxDustHTLCExposureZ* orig_conv = (LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(orig);
21885         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
21886         *ret_copy = COption_MaxDustHTLCExposureZ_clone(orig_conv);
21887         int64_t ret_ref = tag_ptr(ret_copy, true);
21888         return ret_ref;
21889 }
21890
21891 int64_t  CS_LDK_COption_APIErrorZ_some(int64_t o) {
21892         void* o_ptr = untag_ptr(o);
21893         CHECK_ACCESS(o_ptr);
21894         LDKAPIError o_conv = *(LDKAPIError*)(o_ptr);
21895         o_conv = APIError_clone((LDKAPIError*)untag_ptr(o));
21896         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21897         *ret_copy = COption_APIErrorZ_some(o_conv);
21898         int64_t ret_ref = tag_ptr(ret_copy, true);
21899         return ret_ref;
21900 }
21901
21902 int64_t  CS_LDK_COption_APIErrorZ_none() {
21903         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21904         *ret_copy = COption_APIErrorZ_none();
21905         int64_t ret_ref = tag_ptr(ret_copy, true);
21906         return ret_ref;
21907 }
21908
21909 void  CS_LDK_COption_APIErrorZ_free(int64_t _res) {
21910         if (!ptr_is_owned(_res)) return;
21911         void* _res_ptr = untag_ptr(_res);
21912         CHECK_ACCESS(_res_ptr);
21913         LDKCOption_APIErrorZ _res_conv = *(LDKCOption_APIErrorZ*)(_res_ptr);
21914         FREE(untag_ptr(_res));
21915         COption_APIErrorZ_free(_res_conv);
21916 }
21917
21918 static inline uint64_t COption_APIErrorZ_clone_ptr(LDKCOption_APIErrorZ *NONNULL_PTR arg) {
21919         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21920         *ret_copy = COption_APIErrorZ_clone(arg);
21921         int64_t ret_ref = tag_ptr(ret_copy, true);
21922         return ret_ref;
21923 }
21924 int64_t  CS_LDK_COption_APIErrorZ_clone_ptr(int64_t arg) {
21925         LDKCOption_APIErrorZ* arg_conv = (LDKCOption_APIErrorZ*)untag_ptr(arg);
21926         int64_t ret_conv = COption_APIErrorZ_clone_ptr(arg_conv);
21927         return ret_conv;
21928 }
21929
21930 int64_t  CS_LDK_COption_APIErrorZ_clone(int64_t orig) {
21931         LDKCOption_APIErrorZ* orig_conv = (LDKCOption_APIErrorZ*)untag_ptr(orig);
21932         LDKCOption_APIErrorZ *ret_copy = MALLOC(sizeof(LDKCOption_APIErrorZ), "LDKCOption_APIErrorZ");
21933         *ret_copy = COption_APIErrorZ_clone(orig_conv);
21934         int64_t ret_ref = tag_ptr(ret_copy, true);
21935         return ret_ref;
21936 }
21937
21938 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_ok(int64_t o) {
21939         void* o_ptr = untag_ptr(o);
21940         CHECK_ACCESS(o_ptr);
21941         LDKCOption_APIErrorZ o_conv = *(LDKCOption_APIErrorZ*)(o_ptr);
21942         o_conv = COption_APIErrorZ_clone((LDKCOption_APIErrorZ*)untag_ptr(o));
21943         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21944         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_ok(o_conv);
21945         return tag_ptr(ret_conv, true);
21946 }
21947
21948 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_err(int64_t e) {
21949         void* e_ptr = untag_ptr(e);
21950         CHECK_ACCESS(e_ptr);
21951         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21952         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21953         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21954         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_err(e_conv);
21955         return tag_ptr(ret_conv, true);
21956 }
21957
21958 jboolean  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_is_ok(int64_t o) {
21959         LDKCResult_COption_APIErrorZDecodeErrorZ* o_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(o);
21960         jboolean ret_conv = CResult_COption_APIErrorZDecodeErrorZ_is_ok(o_conv);
21961         return ret_conv;
21962 }
21963
21964 void  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_free(int64_t _res) {
21965         if (!ptr_is_owned(_res)) return;
21966         void* _res_ptr = untag_ptr(_res);
21967         CHECK_ACCESS(_res_ptr);
21968         LDKCResult_COption_APIErrorZDecodeErrorZ _res_conv = *(LDKCResult_COption_APIErrorZDecodeErrorZ*)(_res_ptr);
21969         FREE(untag_ptr(_res));
21970         CResult_COption_APIErrorZDecodeErrorZ_free(_res_conv);
21971 }
21972
21973 static inline uint64_t CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(LDKCResult_COption_APIErrorZDecodeErrorZ *NONNULL_PTR arg) {
21974         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21975         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(arg);
21976         return tag_ptr(ret_conv, true);
21977 }
21978 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(int64_t arg) {
21979         LDKCResult_COption_APIErrorZDecodeErrorZ* arg_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(arg);
21980         int64_t ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone_ptr(arg_conv);
21981         return ret_conv;
21982 }
21983
21984 int64_t  CS_LDK_CResult_COption_APIErrorZDecodeErrorZ_clone(int64_t orig) {
21985         LDKCResult_COption_APIErrorZDecodeErrorZ* orig_conv = (LDKCResult_COption_APIErrorZDecodeErrorZ*)untag_ptr(orig);
21986         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
21987         *ret_conv = CResult_COption_APIErrorZDecodeErrorZ_clone(orig_conv);
21988         return tag_ptr(ret_conv, true);
21989 }
21990
21991 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(int64_t o) {
21992         LDKChannelMonitorUpdate o_conv;
21993         o_conv.inner = untag_ptr(o);
21994         o_conv.is_owned = ptr_is_owned(o);
21995         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21996         o_conv = ChannelMonitorUpdate_clone(&o_conv);
21997         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21998         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
21999         return tag_ptr(ret_conv, true);
22000 }
22001
22002 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_err(int64_t e) {
22003         void* e_ptr = untag_ptr(e);
22004         CHECK_ACCESS(e_ptr);
22005         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22006         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22007         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22008         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22009         return tag_ptr(ret_conv, true);
22010 }
22011
22012 jboolean  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(int64_t o) {
22013         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22014         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22015         return ret_conv;
22016 }
22017
22018 void  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_free(int64_t _res) {
22019         if (!ptr_is_owned(_res)) return;
22020         void* _res_ptr = untag_ptr(_res);
22021         CHECK_ACCESS(_res_ptr);
22022         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22023         FREE(untag_ptr(_res));
22024         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22025 }
22026
22027 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
22028         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22029         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22030         return tag_ptr(ret_conv, true);
22031 }
22032 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
22033         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22034         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22035         return ret_conv;
22036 }
22037
22038 int64_t  CS_LDK_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(int64_t orig) {
22039         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22040         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22041         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22042         return tag_ptr(ret_conv, true);
22043 }
22044
22045 int64_t  CS_LDK_COption_MonitorEventZ_some(int64_t o) {
22046         void* o_ptr = untag_ptr(o);
22047         CHECK_ACCESS(o_ptr);
22048         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
22049         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
22050         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22051         *ret_copy = COption_MonitorEventZ_some(o_conv);
22052         int64_t ret_ref = tag_ptr(ret_copy, true);
22053         return ret_ref;
22054 }
22055
22056 int64_t  CS_LDK_COption_MonitorEventZ_none() {
22057         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22058         *ret_copy = COption_MonitorEventZ_none();
22059         int64_t ret_ref = tag_ptr(ret_copy, true);
22060         return ret_ref;
22061 }
22062
22063 void  CS_LDK_COption_MonitorEventZ_free(int64_t _res) {
22064         if (!ptr_is_owned(_res)) return;
22065         void* _res_ptr = untag_ptr(_res);
22066         CHECK_ACCESS(_res_ptr);
22067         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
22068         FREE(untag_ptr(_res));
22069         COption_MonitorEventZ_free(_res_conv);
22070 }
22071
22072 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
22073         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22074         *ret_copy = COption_MonitorEventZ_clone(arg);
22075         int64_t ret_ref = tag_ptr(ret_copy, true);
22076         return ret_ref;
22077 }
22078 int64_t  CS_LDK_COption_MonitorEventZ_clone_ptr(int64_t arg) {
22079         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
22080         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
22081         return ret_conv;
22082 }
22083
22084 int64_t  CS_LDK_COption_MonitorEventZ_clone(int64_t orig) {
22085         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
22086         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22087         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
22088         int64_t ret_ref = tag_ptr(ret_copy, true);
22089         return ret_ref;
22090 }
22091
22092 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_ok(int64_t o) {
22093         void* o_ptr = untag_ptr(o);
22094         CHECK_ACCESS(o_ptr);
22095         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
22096         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
22097         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22098         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
22099         return tag_ptr(ret_conv, true);
22100 }
22101
22102 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_err(int64_t e) {
22103         void* e_ptr = untag_ptr(e);
22104         CHECK_ACCESS(e_ptr);
22105         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22106         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22107         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22108         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
22109         return tag_ptr(ret_conv, true);
22110 }
22111
22112 jboolean  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(int64_t o) {
22113         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
22114         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
22115         return ret_conv;
22116 }
22117
22118 void  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_free(int64_t _res) {
22119         if (!ptr_is_owned(_res)) return;
22120         void* _res_ptr = untag_ptr(_res);
22121         CHECK_ACCESS(_res_ptr);
22122         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
22123         FREE(untag_ptr(_res));
22124         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
22125 }
22126
22127 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
22128         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22129         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
22130         return tag_ptr(ret_conv, true);
22131 }
22132 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(int64_t arg) {
22133         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
22134         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
22135         return ret_conv;
22136 }
22137
22138 int64_t  CS_LDK_CResult_COption_MonitorEventZDecodeErrorZ_clone(int64_t orig) {
22139         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
22140         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22141         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
22142         return tag_ptr(ret_conv, true);
22143 }
22144
22145 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_ok(int64_t o) {
22146         LDKHTLCUpdate o_conv;
22147         o_conv.inner = untag_ptr(o);
22148         o_conv.is_owned = ptr_is_owned(o);
22149         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22150         o_conv = HTLCUpdate_clone(&o_conv);
22151         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22152         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
22153         return tag_ptr(ret_conv, true);
22154 }
22155
22156 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_err(int64_t e) {
22157         void* e_ptr = untag_ptr(e);
22158         CHECK_ACCESS(e_ptr);
22159         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22160         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22161         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22162         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
22163         return tag_ptr(ret_conv, true);
22164 }
22165
22166 jboolean  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_is_ok(int64_t o) {
22167         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
22168         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
22169         return ret_conv;
22170 }
22171
22172 void  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_free(int64_t _res) {
22173         if (!ptr_is_owned(_res)) return;
22174         void* _res_ptr = untag_ptr(_res);
22175         CHECK_ACCESS(_res_ptr);
22176         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
22177         FREE(untag_ptr(_res));
22178         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
22179 }
22180
22181 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
22182         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22183         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
22184         return tag_ptr(ret_conv, true);
22185 }
22186 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
22187         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
22188         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
22189         return ret_conv;
22190 }
22191
22192 int64_t  CS_LDK_CResult_HTLCUpdateDecodeErrorZ_clone(int64_t orig) {
22193         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
22194         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22195         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
22196         return tag_ptr(ret_conv, true);
22197 }
22198
22199 static inline uint64_t C2Tuple_OutPointCVec_u8ZZ_clone_ptr(LDKC2Tuple_OutPointCVec_u8ZZ *NONNULL_PTR arg) {
22200         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
22201         *ret_conv = C2Tuple_OutPointCVec_u8ZZ_clone(arg);
22202         return tag_ptr(ret_conv, true);
22203 }
22204 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_clone_ptr(int64_t arg) {
22205         LDKC2Tuple_OutPointCVec_u8ZZ* arg_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(arg);
22206         int64_t ret_conv = C2Tuple_OutPointCVec_u8ZZ_clone_ptr(arg_conv);
22207         return ret_conv;
22208 }
22209
22210 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_clone(int64_t orig) {
22211         LDKC2Tuple_OutPointCVec_u8ZZ* orig_conv = (LDKC2Tuple_OutPointCVec_u8ZZ*)untag_ptr(orig);
22212         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
22213         *ret_conv = C2Tuple_OutPointCVec_u8ZZ_clone(orig_conv);
22214         return tag_ptr(ret_conv, true);
22215 }
22216
22217 int64_t  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_new(int64_t a, int8_tArray b) {
22218         LDKOutPoint a_conv;
22219         a_conv.inner = untag_ptr(a);
22220         a_conv.is_owned = ptr_is_owned(a);
22221         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22222         a_conv = OutPoint_clone(&a_conv);
22223         LDKCVec_u8Z b_ref;
22224         b_ref.datalen = b->arr_len;
22225         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22226         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
22227         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
22228         *ret_conv = C2Tuple_OutPointCVec_u8ZZ_new(a_conv, b_ref);
22229         return tag_ptr(ret_conv, true);
22230 }
22231
22232 void  CS_LDK_C2Tuple_OutPointCVec_u8ZZ_free(int64_t _res) {
22233         if (!ptr_is_owned(_res)) return;
22234         void* _res_ptr = untag_ptr(_res);
22235         CHECK_ACCESS(_res_ptr);
22236         LDKC2Tuple_OutPointCVec_u8ZZ _res_conv = *(LDKC2Tuple_OutPointCVec_u8ZZ*)(_res_ptr);
22237         FREE(untag_ptr(_res));
22238         C2Tuple_OutPointCVec_u8ZZ_free(_res_conv);
22239 }
22240
22241 static inline uint64_t C2Tuple_u32CVec_u8ZZ_clone_ptr(LDKC2Tuple_u32CVec_u8ZZ *NONNULL_PTR arg) {
22242         LDKC2Tuple_u32CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
22243         *ret_conv = C2Tuple_u32CVec_u8ZZ_clone(arg);
22244         return tag_ptr(ret_conv, true);
22245 }
22246 int64_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_clone_ptr(int64_t arg) {
22247         LDKC2Tuple_u32CVec_u8ZZ* arg_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(arg);
22248         int64_t ret_conv = C2Tuple_u32CVec_u8ZZ_clone_ptr(arg_conv);
22249         return ret_conv;
22250 }
22251
22252 int64_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_clone(int64_t orig) {
22253         LDKC2Tuple_u32CVec_u8ZZ* orig_conv = (LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(orig);
22254         LDKC2Tuple_u32CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
22255         *ret_conv = C2Tuple_u32CVec_u8ZZ_clone(orig_conv);
22256         return tag_ptr(ret_conv, true);
22257 }
22258
22259 int64_t  CS_LDK_C2Tuple_u32CVec_u8ZZ_new(int32_t a, int8_tArray b) {
22260         LDKCVec_u8Z b_ref;
22261         b_ref.datalen = b->arr_len;
22262         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22263         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
22264         LDKC2Tuple_u32CVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKC2Tuple_u32CVec_u8ZZ");
22265         *ret_conv = C2Tuple_u32CVec_u8ZZ_new(a, b_ref);
22266         return tag_ptr(ret_conv, true);
22267 }
22268
22269 void  CS_LDK_C2Tuple_u32CVec_u8ZZ_free(int64_t _res) {
22270         if (!ptr_is_owned(_res)) return;
22271         void* _res_ptr = untag_ptr(_res);
22272         CHECK_ACCESS(_res_ptr);
22273         LDKC2Tuple_u32CVec_u8ZZ _res_conv = *(LDKC2Tuple_u32CVec_u8ZZ*)(_res_ptr);
22274         FREE(untag_ptr(_res));
22275         C2Tuple_u32CVec_u8ZZ_free(_res_conv);
22276 }
22277
22278 void  CS_LDK_CVec_C2Tuple_u32CVec_u8ZZZ_free(int64_tArray _res) {
22279         LDKCVec_C2Tuple_u32CVec_u8ZZZ _res_constr;
22280         _res_constr.datalen = _res->arr_len;
22281         if (_res_constr.datalen > 0)
22282                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKCVec_C2Tuple_u32CVec_u8ZZZ Elements");
22283         else
22284                 _res_constr.data = NULL;
22285         int64_t* _res_vals = _res->elems;
22286         for (size_t x = 0; x < _res_constr.datalen; x++) {
22287                 int64_t _res_conv_23 = _res_vals[x];
22288                 void* _res_conv_23_ptr = untag_ptr(_res_conv_23);
22289                 CHECK_ACCESS(_res_conv_23_ptr);
22290                 LDKC2Tuple_u32CVec_u8ZZ _res_conv_23_conv = *(LDKC2Tuple_u32CVec_u8ZZ*)(_res_conv_23_ptr);
22291                 FREE(untag_ptr(_res_conv_23));
22292                 _res_constr.data[x] = _res_conv_23_conv;
22293         }
22294         FREE(_res);
22295         CVec_C2Tuple_u32CVec_u8ZZZ_free(_res_constr);
22296 }
22297
22298 static inline uint64_t C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ *NONNULL_PTR arg) {
22299         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
22300         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(arg);
22301         return tag_ptr(ret_conv, true);
22302 }
22303 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone_ptr(int64_t arg) {
22304         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(arg);
22305         int64_t ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone_ptr(arg_conv);
22306         return ret_conv;
22307 }
22308
22309 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(int64_t orig) {
22310         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)untag_ptr(orig);
22311         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
22312         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_clone(orig_conv);
22313         return tag_ptr(ret_conv, true);
22314 }
22315
22316 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_new(int8_tArray a, int64_tArray b) {
22317         LDKThirtyTwoBytes a_ref;
22318         CHECK(a->arr_len == 32);
22319         memcpy(a_ref.data, a->elems, 32); FREE(a);
22320         LDKCVec_C2Tuple_u32CVec_u8ZZZ b_constr;
22321         b_constr.datalen = b->arr_len;
22322         if (b_constr.datalen > 0)
22323                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32CVec_u8ZZ), "LDKCVec_C2Tuple_u32CVec_u8ZZZ Elements");
22324         else
22325                 b_constr.data = NULL;
22326         int64_t* b_vals = b->elems;
22327         for (size_t x = 0; x < b_constr.datalen; x++) {
22328                 int64_t b_conv_23 = b_vals[x];
22329                 void* b_conv_23_ptr = untag_ptr(b_conv_23);
22330                 CHECK_ACCESS(b_conv_23_ptr);
22331                 LDKC2Tuple_u32CVec_u8ZZ b_conv_23_conv = *(LDKC2Tuple_u32CVec_u8ZZ*)(b_conv_23_ptr);
22332                 b_conv_23_conv = C2Tuple_u32CVec_u8ZZ_clone((LDKC2Tuple_u32CVec_u8ZZ*)untag_ptr(b_conv_23));
22333                 b_constr.data[x] = b_conv_23_conv;
22334         }
22335         FREE(b);
22336         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
22337         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_new(a_ref, b_constr);
22338         return tag_ptr(ret_conv, true);
22339 }
22340
22341 void  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(int64_t _res) {
22342         if (!ptr_is_owned(_res)) return;
22343         void* _res_ptr = untag_ptr(_res);
22344         CHECK_ACCESS(_res_ptr);
22345         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)(_res_ptr);
22346         FREE(untag_ptr(_res));
22347         C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ_free(_res_conv);
22348 }
22349
22350 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(int64_tArray _res) {
22351         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ _res_constr;
22352         _res_constr.datalen = _res->arr_len;
22353         if (_res_constr.datalen > 0)
22354                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ Elements");
22355         else
22356                 _res_constr.data = NULL;
22357         int64_t* _res_vals = _res->elems;
22358         for (size_t a = 0; a < _res_constr.datalen; a++) {
22359                 int64_t _res_conv_52 = _res_vals[a];
22360                 void* _res_conv_52_ptr = untag_ptr(_res_conv_52);
22361                 CHECK_ACCESS(_res_conv_52_ptr);
22362                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ _res_conv_52_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ*)(_res_conv_52_ptr);
22363                 FREE(untag_ptr(_res_conv_52));
22364                 _res_constr.data[a] = _res_conv_52_conv;
22365         }
22366         FREE(_res);
22367         CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ_free(_res_constr);
22368 }
22369
22370 void  CS_LDK_CVec_CommitmentTransactionZ_free(int64_tArray _res) {
22371         LDKCVec_CommitmentTransactionZ _res_constr;
22372         _res_constr.datalen = _res->arr_len;
22373         if (_res_constr.datalen > 0)
22374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCommitmentTransaction), "LDKCVec_CommitmentTransactionZ Elements");
22375         else
22376                 _res_constr.data = NULL;
22377         int64_t* _res_vals = _res->elems;
22378         for (size_t x = 0; x < _res_constr.datalen; x++) {
22379                 int64_t _res_conv_23 = _res_vals[x];
22380                 LDKCommitmentTransaction _res_conv_23_conv;
22381                 _res_conv_23_conv.inner = untag_ptr(_res_conv_23);
22382                 _res_conv_23_conv.is_owned = ptr_is_owned(_res_conv_23);
22383                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_23_conv);
22384                 _res_constr.data[x] = _res_conv_23_conv;
22385         }
22386         FREE(_res);
22387         CVec_CommitmentTransactionZ_free(_res_constr);
22388 }
22389
22390 void  CS_LDK_CVec_TransactionZ_free(ptrArray _res) {
22391         LDKCVec_TransactionZ _res_constr;
22392         _res_constr.datalen = _res->arr_len;
22393         if (_res_constr.datalen > 0)
22394                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22395         else
22396                 _res_constr.data = NULL;
22397         int8_tArray* _res_vals = (void*) _res->elems;
22398         for (size_t i = 0; i < _res_constr.datalen; i++) {
22399                 int8_tArray _res_conv_8 = _res_vals[i];
22400                 LDKTransaction _res_conv_8_ref;
22401                 _res_conv_8_ref.datalen = _res_conv_8->arr_len;
22402                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22403                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, _res_conv_8_ref.datalen); FREE(_res_conv_8);
22404                 _res_conv_8_ref.data_is_owned = true;
22405                 _res_constr.data[i] = _res_conv_8_ref;
22406         }
22407         FREE(_res);
22408         CVec_TransactionZ_free(_res_constr);
22409 }
22410
22411 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22412         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22413         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22414         return tag_ptr(ret_conv, true);
22415 }
22416 int64_t  CS_LDK_C2Tuple_u32TxOutZ_clone_ptr(int64_t arg) {
22417         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22418         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22419         return ret_conv;
22420 }
22421
22422 int64_t  CS_LDK_C2Tuple_u32TxOutZ_clone(int64_t orig) {
22423         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22424         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22425         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22426         return tag_ptr(ret_conv, true);
22427 }
22428
22429 int64_t  CS_LDK_C2Tuple_u32TxOutZ_new(int32_t a, int64_t b) {
22430         void* b_ptr = untag_ptr(b);
22431         CHECK_ACCESS(b_ptr);
22432         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22433         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22434         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22435         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22436         return tag_ptr(ret_conv, true);
22437 }
22438
22439 void  CS_LDK_C2Tuple_u32TxOutZ_free(int64_t _res) {
22440         if (!ptr_is_owned(_res)) return;
22441         void* _res_ptr = untag_ptr(_res);
22442         CHECK_ACCESS(_res_ptr);
22443         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22444         FREE(untag_ptr(_res));
22445         C2Tuple_u32TxOutZ_free(_res_conv);
22446 }
22447
22448 void  CS_LDK_CVec_C2Tuple_u32TxOutZZ_free(int64_tArray _res) {
22449         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22450         _res_constr.datalen = _res->arr_len;
22451         if (_res_constr.datalen > 0)
22452                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22453         else
22454                 _res_constr.data = NULL;
22455         int64_t* _res_vals = _res->elems;
22456         for (size_t u = 0; u < _res_constr.datalen; u++) {
22457                 int64_t _res_conv_20 = _res_vals[u];
22458                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22459                 CHECK_ACCESS(_res_conv_20_ptr);
22460                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22461                 FREE(untag_ptr(_res_conv_20));
22462                 _res_constr.data[u] = _res_conv_20_conv;
22463         }
22464         FREE(_res);
22465         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22466 }
22467
22468 static inline uint64_t C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22469         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
22470         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22471         return tag_ptr(ret_conv, true);
22472 }
22473 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone_ptr(int64_t arg) {
22474         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22475         int64_t ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22476         return ret_conv;
22477 }
22478
22479 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(int64_t orig) {
22480         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22481         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
22482         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22483         return tag_ptr(ret_conv, true);
22484 }
22485
22486 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, int64_tArray b) {
22487         LDKThirtyTwoBytes a_ref;
22488         CHECK(a->arr_len == 32);
22489         memcpy(a_ref.data, a->elems, 32); FREE(a);
22490         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22491         b_constr.datalen = b->arr_len;
22492         if (b_constr.datalen > 0)
22493                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22494         else
22495                 b_constr.data = NULL;
22496         int64_t* b_vals = b->elems;
22497         for (size_t u = 0; u < b_constr.datalen; u++) {
22498                 int64_t b_conv_20 = b_vals[u];
22499                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22500                 CHECK_ACCESS(b_conv_20_ptr);
22501                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22502                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22503                 b_constr.data[u] = b_conv_20_conv;
22504         }
22505         FREE(b);
22506         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
22507         *ret_conv = C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22508         return tag_ptr(ret_conv, true);
22509 }
22510
22511 void  CS_LDK_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_free(int64_t _res) {
22512         if (!ptr_is_owned(_res)) return;
22513         void* _res_ptr = untag_ptr(_res);
22514         CHECK_ACCESS(_res_ptr);
22515         LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22516         FREE(untag_ptr(_res));
22517         C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22518 }
22519
22520 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_free(int64_tArray _res) {
22521         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22522         _res_constr.datalen = _res->arr_len;
22523         if (_res_constr.datalen > 0)
22524                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ Elements");
22525         else
22526                 _res_constr.data = NULL;
22527         int64_t* _res_vals = _res->elems;
22528         for (size_t x = 0; x < _res_constr.datalen; x++) {
22529                 int64_t _res_conv_49 = _res_vals[x];
22530                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
22531                 CHECK_ACCESS(_res_conv_49_ptr);
22532                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ _res_conv_49_conv = *(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_49_ptr);
22533                 FREE(untag_ptr(_res_conv_49));
22534                 _res_constr.data[x] = _res_conv_49_conv;
22535         }
22536         FREE(_res);
22537         CVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22538 }
22539
22540 void  CS_LDK_CVec_BalanceZ_free(int64_tArray _res) {
22541         LDKCVec_BalanceZ _res_constr;
22542         _res_constr.datalen = _res->arr_len;
22543         if (_res_constr.datalen > 0)
22544                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22545         else
22546                 _res_constr.data = NULL;
22547         int64_t* _res_vals = _res->elems;
22548         for (size_t j = 0; j < _res_constr.datalen; j++) {
22549                 int64_t _res_conv_9 = _res_vals[j];
22550                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22551                 CHECK_ACCESS(_res_conv_9_ptr);
22552                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22553                 FREE(untag_ptr(_res_conv_9));
22554                 _res_constr.data[j] = _res_conv_9_conv;
22555         }
22556         FREE(_res);
22557         CVec_BalanceZ_free(_res_constr);
22558 }
22559
22560 static inline uint64_t C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone_ptr(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ *NONNULL_PTR arg) {
22561         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
22562         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(arg);
22563         return tag_ptr(ret_conv, true);
22564 }
22565 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone_ptr(int64_t arg) {
22566         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* arg_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(arg);
22567         int64_t ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone_ptr(arg_conv);
22568         return ret_conv;
22569 }
22570
22571 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(int64_t orig) {
22572         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* orig_conv = (LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(orig);
22573         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
22574         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone(orig_conv);
22575         return tag_ptr(ret_conv, true);
22576 }
22577
22578 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_new(int8_tArray a, int64_t b) {
22579         LDKThirtyTwoBytes a_ref;
22580         CHECK(a->arr_len == 32);
22581         memcpy(a_ref.data, a->elems, 32); FREE(a);
22582         LDKChannelMonitor b_conv;
22583         b_conv.inner = untag_ptr(b);
22584         b_conv.is_owned = ptr_is_owned(b);
22585         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22586         b_conv = ChannelMonitor_clone(&b_conv);
22587         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ");
22588         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_new(a_ref, b_conv);
22589         return tag_ptr(ret_conv, true);
22590 }
22591
22592 void  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_free(int64_t _res) {
22593         if (!ptr_is_owned(_res)) return;
22594         void* _res_ptr = untag_ptr(_res);
22595         CHECK_ACCESS(_res_ptr);
22596         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ _res_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(_res_ptr);
22597         FREE(untag_ptr(_res));
22598         C2Tuple_ThirtyTwoBytesChannelMonitorZ_free(_res_conv);
22599 }
22600
22601 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_ok(int64_t o) {
22602         void* o_ptr = untag_ptr(o);
22603         CHECK_ACCESS(o_ptr);
22604         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(o_ptr);
22605         o_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone((LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(o));
22606         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22607         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_ok(o_conv);
22608         return tag_ptr(ret_conv, true);
22609 }
22610
22611 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_err(int64_t e) {
22612         void* e_ptr = untag_ptr(e);
22613         CHECK_ACCESS(e_ptr);
22614         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22615         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22616         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22617         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_err(e_conv);
22618         return tag_ptr(ret_conv, true);
22619 }
22620
22621 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_is_ok(int64_t o) {
22622         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22623         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22624         return ret_conv;
22625 }
22626
22627 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_free(int64_t _res) {
22628         if (!ptr_is_owned(_res)) return;
22629         void* _res_ptr = untag_ptr(_res);
22630         CHECK_ACCESS(_res_ptr);
22631         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)(_res_ptr);
22632         FREE(untag_ptr(_res));
22633         CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_free(_res_conv);
22634 }
22635
22636 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22637         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22638         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(arg);
22639         return tag_ptr(ret_conv, true);
22640 }
22641 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone_ptr(int64_t arg) {
22642         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22643         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22644         return ret_conv;
22645 }
22646
22647 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(int64_t orig) {
22648         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22649         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
22650         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_clone(orig_conv);
22651         return tag_ptr(ret_conv, true);
22652 }
22653
22654 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22655         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22656         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22657         return tag_ptr(ret_conv, true);
22658 }
22659 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_clone_ptr(int64_t arg) {
22660         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22661         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22662         return ret_conv;
22663 }
22664
22665 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_clone(int64_t orig) {
22666         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22667         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22668         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22669         return tag_ptr(ret_conv, true);
22670 }
22671
22672 int64_t  CS_LDK_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, int64_t b) {
22673         LDKPublicKey a_ref;
22674         CHECK(a->arr_len == 33);
22675         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
22676         void* b_ptr = untag_ptr(b);
22677         CHECK_ACCESS(b_ptr);
22678         LDKType b_conv = *(LDKType*)(b_ptr);
22679         if (b_conv.free == LDKType_JCalls_free) {
22680                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22681                 LDKType_JCalls_cloned(&b_conv);
22682         }
22683         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22684         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22685         return tag_ptr(ret_conv, true);
22686 }
22687
22688 void  CS_LDK_C2Tuple_PublicKeyTypeZ_free(int64_t _res) {
22689         if (!ptr_is_owned(_res)) return;
22690         void* _res_ptr = untag_ptr(_res);
22691         CHECK_ACCESS(_res_ptr);
22692         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22693         FREE(untag_ptr(_res));
22694         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22695 }
22696
22697 void  CS_LDK_CVec_C2Tuple_PublicKeyTypeZZ_free(int64_tArray _res) {
22698         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22699         _res_constr.datalen = _res->arr_len;
22700         if (_res_constr.datalen > 0)
22701                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22702         else
22703                 _res_constr.data = NULL;
22704         int64_t* _res_vals = _res->elems;
22705         for (size_t z = 0; z < _res_constr.datalen; z++) {
22706                 int64_t _res_conv_25 = _res_vals[z];
22707                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22708                 CHECK_ACCESS(_res_conv_25_ptr);
22709                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22710                 FREE(untag_ptr(_res_conv_25));
22711                 _res_constr.data[z] = _res_conv_25_conv;
22712         }
22713         FREE(_res);
22714         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22715 }
22716
22717 int64_t  CS_LDK_COption_OnionMessageContentsZ_some(int64_t o) {
22718         void* o_ptr = untag_ptr(o);
22719         CHECK_ACCESS(o_ptr);
22720         LDKOnionMessageContents o_conv = *(LDKOnionMessageContents*)(o_ptr);
22721         if (o_conv.free == LDKOnionMessageContents_JCalls_free) {
22722                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22723                 LDKOnionMessageContents_JCalls_cloned(&o_conv);
22724         }
22725         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22726         *ret_copy = COption_OnionMessageContentsZ_some(o_conv);
22727         int64_t ret_ref = tag_ptr(ret_copy, true);
22728         return ret_ref;
22729 }
22730
22731 int64_t  CS_LDK_COption_OnionMessageContentsZ_none() {
22732         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22733         *ret_copy = COption_OnionMessageContentsZ_none();
22734         int64_t ret_ref = tag_ptr(ret_copy, true);
22735         return ret_ref;
22736 }
22737
22738 void  CS_LDK_COption_OnionMessageContentsZ_free(int64_t _res) {
22739         if (!ptr_is_owned(_res)) return;
22740         void* _res_ptr = untag_ptr(_res);
22741         CHECK_ACCESS(_res_ptr);
22742         LDKCOption_OnionMessageContentsZ _res_conv = *(LDKCOption_OnionMessageContentsZ*)(_res_ptr);
22743         FREE(untag_ptr(_res));
22744         COption_OnionMessageContentsZ_free(_res_conv);
22745 }
22746
22747 static inline uint64_t COption_OnionMessageContentsZ_clone_ptr(LDKCOption_OnionMessageContentsZ *NONNULL_PTR arg) {
22748         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22749         *ret_copy = COption_OnionMessageContentsZ_clone(arg);
22750         int64_t ret_ref = tag_ptr(ret_copy, true);
22751         return ret_ref;
22752 }
22753 int64_t  CS_LDK_COption_OnionMessageContentsZ_clone_ptr(int64_t arg) {
22754         LDKCOption_OnionMessageContentsZ* arg_conv = (LDKCOption_OnionMessageContentsZ*)untag_ptr(arg);
22755         int64_t ret_conv = COption_OnionMessageContentsZ_clone_ptr(arg_conv);
22756         return ret_conv;
22757 }
22758
22759 int64_t  CS_LDK_COption_OnionMessageContentsZ_clone(int64_t orig) {
22760         LDKCOption_OnionMessageContentsZ* orig_conv = (LDKCOption_OnionMessageContentsZ*)untag_ptr(orig);
22761         LDKCOption_OnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_OnionMessageContentsZ), "LDKCOption_OnionMessageContentsZ");
22762         *ret_copy = COption_OnionMessageContentsZ_clone(orig_conv);
22763         int64_t ret_ref = tag_ptr(ret_copy, true);
22764         return ret_ref;
22765 }
22766
22767 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_ok(int64_t o) {
22768         void* o_ptr = untag_ptr(o);
22769         CHECK_ACCESS(o_ptr);
22770         LDKCOption_OnionMessageContentsZ o_conv = *(LDKCOption_OnionMessageContentsZ*)(o_ptr);
22771         o_conv = COption_OnionMessageContentsZ_clone((LDKCOption_OnionMessageContentsZ*)untag_ptr(o));
22772         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22773         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_ok(o_conv);
22774         return tag_ptr(ret_conv, true);
22775 }
22776
22777 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_err(int64_t e) {
22778         void* e_ptr = untag_ptr(e);
22779         CHECK_ACCESS(e_ptr);
22780         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22781         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22782         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22783         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_err(e_conv);
22784         return tag_ptr(ret_conv, true);
22785 }
22786
22787 jboolean  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_is_ok(int64_t o) {
22788         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
22789         jboolean ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
22790         return ret_conv;
22791 }
22792
22793 void  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_free(int64_t _res) {
22794         if (!ptr_is_owned(_res)) return;
22795         void* _res_ptr = untag_ptr(_res);
22796         CHECK_ACCESS(_res_ptr);
22797         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)(_res_ptr);
22798         FREE(untag_ptr(_res));
22799         CResult_COption_OnionMessageContentsZDecodeErrorZ_free(_res_conv);
22800 }
22801
22802 static inline uint64_t CResult_COption_OnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
22803         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22804         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(arg);
22805         return tag_ptr(ret_conv, true);
22806 }
22807 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_clone_ptr(int64_t arg) {
22808         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
22809         int64_t ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
22810         return ret_conv;
22811 }
22812
22813 int64_t  CS_LDK_CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(int64_t orig) {
22814         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_OnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
22815         LDKCResult_COption_OnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_OnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_OnionMessageContentsZDecodeErrorZ");
22816         *ret_conv = CResult_COption_OnionMessageContentsZDecodeErrorZ_clone(orig_conv);
22817         return tag_ptr(ret_conv, true);
22818 }
22819
22820 static inline uint64_t C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone_ptr(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ *NONNULL_PTR arg) {
22821         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
22822         *ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(arg);
22823         return tag_ptr(ret_conv, true);
22824 }
22825 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone_ptr(int64_t arg) {
22826         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* arg_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(arg);
22827         int64_t ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone_ptr(arg_conv);
22828         return ret_conv;
22829 }
22830
22831 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(int64_t orig) {
22832         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* orig_conv = (LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)untag_ptr(orig);
22833         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
22834         *ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_clone(orig_conv);
22835         return tag_ptr(ret_conv, true);
22836 }
22837
22838 int64_t  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(int64_t a, int64_t b, int64_t c) {
22839         void* a_ptr = untag_ptr(a);
22840         CHECK_ACCESS(a_ptr);
22841         LDKOnionMessageContents a_conv = *(LDKOnionMessageContents*)(a_ptr);
22842         if (a_conv.free == LDKOnionMessageContents_JCalls_free) {
22843                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22844                 LDKOnionMessageContents_JCalls_cloned(&a_conv);
22845         }
22846         void* b_ptr = untag_ptr(b);
22847         CHECK_ACCESS(b_ptr);
22848         LDKDestination b_conv = *(LDKDestination*)(b_ptr);
22849         b_conv = Destination_clone((LDKDestination*)untag_ptr(b));
22850         LDKBlindedPath c_conv;
22851         c_conv.inner = untag_ptr(c);
22852         c_conv.is_owned = ptr_is_owned(c);
22853         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
22854         c_conv = BlindedPath_clone(&c_conv);
22855         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ");
22856         *ret_conv = C3Tuple_OnionMessageContentsDestinationBlindedPathZ_new(a_conv, b_conv, c_conv);
22857         return tag_ptr(ret_conv, true);
22858 }
22859
22860 void  CS_LDK_C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(int64_t _res) {
22861         if (!ptr_is_owned(_res)) return;
22862         void* _res_ptr = untag_ptr(_res);
22863         CHECK_ACCESS(_res_ptr);
22864         LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ _res_conv = *(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)(_res_ptr);
22865         FREE(untag_ptr(_res));
22866         C3Tuple_OnionMessageContentsDestinationBlindedPathZ_free(_res_conv);
22867 }
22868
22869 void  CS_LDK_CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(int64_tArray _res) {
22870         LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ _res_constr;
22871         _res_constr.datalen = _res->arr_len;
22872         if (_res_constr.datalen > 0)
22873                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ), "LDKCVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ Elements");
22874         else
22875                 _res_constr.data = NULL;
22876         int64_t* _res_vals = _res->elems;
22877         for (size_t e = 0; e < _res_constr.datalen; e++) {
22878                 int64_t _res_conv_56 = _res_vals[e];
22879                 void* _res_conv_56_ptr = untag_ptr(_res_conv_56);
22880                 CHECK_ACCESS(_res_conv_56_ptr);
22881                 LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ _res_conv_56_conv = *(LDKC3Tuple_OnionMessageContentsDestinationBlindedPathZ*)(_res_conv_56_ptr);
22882                 FREE(untag_ptr(_res_conv_56));
22883                 _res_constr.data[e] = _res_conv_56_conv;
22884         }
22885         FREE(_res);
22886         CVec_C3Tuple_OnionMessageContentsDestinationBlindedPathZZ_free(_res_constr);
22887 }
22888
22889 int64_t  CS_LDK_COption_TypeZ_some(int64_t o) {
22890         void* o_ptr = untag_ptr(o);
22891         CHECK_ACCESS(o_ptr);
22892         LDKType o_conv = *(LDKType*)(o_ptr);
22893         if (o_conv.free == LDKType_JCalls_free) {
22894                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22895                 LDKType_JCalls_cloned(&o_conv);
22896         }
22897         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22898         *ret_copy = COption_TypeZ_some(o_conv);
22899         int64_t ret_ref = tag_ptr(ret_copy, true);
22900         return ret_ref;
22901 }
22902
22903 int64_t  CS_LDK_COption_TypeZ_none() {
22904         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22905         *ret_copy = COption_TypeZ_none();
22906         int64_t ret_ref = tag_ptr(ret_copy, true);
22907         return ret_ref;
22908 }
22909
22910 void  CS_LDK_COption_TypeZ_free(int64_t _res) {
22911         if (!ptr_is_owned(_res)) return;
22912         void* _res_ptr = untag_ptr(_res);
22913         CHECK_ACCESS(_res_ptr);
22914         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
22915         FREE(untag_ptr(_res));
22916         COption_TypeZ_free(_res_conv);
22917 }
22918
22919 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
22920         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22921         *ret_copy = COption_TypeZ_clone(arg);
22922         int64_t ret_ref = tag_ptr(ret_copy, true);
22923         return ret_ref;
22924 }
22925 int64_t  CS_LDK_COption_TypeZ_clone_ptr(int64_t arg) {
22926         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
22927         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
22928         return ret_conv;
22929 }
22930
22931 int64_t  CS_LDK_COption_TypeZ_clone(int64_t orig) {
22932         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
22933         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
22934         *ret_copy = COption_TypeZ_clone(orig_conv);
22935         int64_t ret_ref = tag_ptr(ret_copy, true);
22936         return ret_ref;
22937 }
22938
22939 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_ok(int64_t o) {
22940         void* o_ptr = untag_ptr(o);
22941         CHECK_ACCESS(o_ptr);
22942         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
22943         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
22944         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22945         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
22946         return tag_ptr(ret_conv, true);
22947 }
22948
22949 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_err(int64_t e) {
22950         void* e_ptr = untag_ptr(e);
22951         CHECK_ACCESS(e_ptr);
22952         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22953         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22954         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22955         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
22956         return tag_ptr(ret_conv, true);
22957 }
22958
22959 jboolean  CS_LDK_CResult_COption_TypeZDecodeErrorZ_is_ok(int64_t o) {
22960         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
22961         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
22962         return ret_conv;
22963 }
22964
22965 void  CS_LDK_CResult_COption_TypeZDecodeErrorZ_free(int64_t _res) {
22966         if (!ptr_is_owned(_res)) return;
22967         void* _res_ptr = untag_ptr(_res);
22968         CHECK_ACCESS(_res_ptr);
22969         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
22970         FREE(untag_ptr(_res));
22971         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
22972 }
22973
22974 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
22975         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22976         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
22977         return tag_ptr(ret_conv, true);
22978 }
22979 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_clone_ptr(int64_t arg) {
22980         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
22981         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
22982         return ret_conv;
22983 }
22984
22985 int64_t  CS_LDK_CResult_COption_TypeZDecodeErrorZ_clone(int64_t orig) {
22986         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
22987         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
22988         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
22989         return tag_ptr(ret_conv, true);
22990 }
22991
22992 int64_t  CS_LDK_COption_SocketAddressZ_some(int64_t o) {
22993         void* o_ptr = untag_ptr(o);
22994         CHECK_ACCESS(o_ptr);
22995         LDKSocketAddress o_conv = *(LDKSocketAddress*)(o_ptr);
22996         o_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o));
22997         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
22998         *ret_copy = COption_SocketAddressZ_some(o_conv);
22999         int64_t ret_ref = tag_ptr(ret_copy, true);
23000         return ret_ref;
23001 }
23002
23003 int64_t  CS_LDK_COption_SocketAddressZ_none() {
23004         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
23005         *ret_copy = COption_SocketAddressZ_none();
23006         int64_t ret_ref = tag_ptr(ret_copy, true);
23007         return ret_ref;
23008 }
23009
23010 void  CS_LDK_COption_SocketAddressZ_free(int64_t _res) {
23011         if (!ptr_is_owned(_res)) return;
23012         void* _res_ptr = untag_ptr(_res);
23013         CHECK_ACCESS(_res_ptr);
23014         LDKCOption_SocketAddressZ _res_conv = *(LDKCOption_SocketAddressZ*)(_res_ptr);
23015         FREE(untag_ptr(_res));
23016         COption_SocketAddressZ_free(_res_conv);
23017 }
23018
23019 static inline uint64_t COption_SocketAddressZ_clone_ptr(LDKCOption_SocketAddressZ *NONNULL_PTR arg) {
23020         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
23021         *ret_copy = COption_SocketAddressZ_clone(arg);
23022         int64_t ret_ref = tag_ptr(ret_copy, true);
23023         return ret_ref;
23024 }
23025 int64_t  CS_LDK_COption_SocketAddressZ_clone_ptr(int64_t arg) {
23026         LDKCOption_SocketAddressZ* arg_conv = (LDKCOption_SocketAddressZ*)untag_ptr(arg);
23027         int64_t ret_conv = COption_SocketAddressZ_clone_ptr(arg_conv);
23028         return ret_conv;
23029 }
23030
23031 int64_t  CS_LDK_COption_SocketAddressZ_clone(int64_t orig) {
23032         LDKCOption_SocketAddressZ* orig_conv = (LDKCOption_SocketAddressZ*)untag_ptr(orig);
23033         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
23034         *ret_copy = COption_SocketAddressZ_clone(orig_conv);
23035         int64_t ret_ref = tag_ptr(ret_copy, true);
23036         return ret_ref;
23037 }
23038
23039 static inline uint64_t C2Tuple_PublicKeyCOption_SocketAddressZZ_clone_ptr(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ *NONNULL_PTR arg) {
23040         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
23041         *ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(arg);
23042         return tag_ptr(ret_conv, true);
23043 }
23044 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_clone_ptr(int64_t arg) {
23045         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* arg_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(arg);
23046         int64_t ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone_ptr(arg_conv);
23047         return ret_conv;
23048 }
23049
23050 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(int64_t orig) {
23051         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* orig_conv = (LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)untag_ptr(orig);
23052         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
23053         *ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_clone(orig_conv);
23054         return tag_ptr(ret_conv, true);
23055 }
23056
23057 int64_t  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_new(int8_tArray a, int64_t b) {
23058         LDKPublicKey a_ref;
23059         CHECK(a->arr_len == 33);
23060         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
23061         void* b_ptr = untag_ptr(b);
23062         CHECK_ACCESS(b_ptr);
23063         LDKCOption_SocketAddressZ b_conv = *(LDKCOption_SocketAddressZ*)(b_ptr);
23064         b_conv = COption_SocketAddressZ_clone((LDKCOption_SocketAddressZ*)untag_ptr(b));
23065         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
23066         *ret_conv = C2Tuple_PublicKeyCOption_SocketAddressZZ_new(a_ref, b_conv);
23067         return tag_ptr(ret_conv, true);
23068 }
23069
23070 void  CS_LDK_C2Tuple_PublicKeyCOption_SocketAddressZZ_free(int64_t _res) {
23071         if (!ptr_is_owned(_res)) return;
23072         void* _res_ptr = untag_ptr(_res);
23073         CHECK_ACCESS(_res_ptr);
23074         LDKC2Tuple_PublicKeyCOption_SocketAddressZZ _res_conv = *(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)(_res_ptr);
23075         FREE(untag_ptr(_res));
23076         C2Tuple_PublicKeyCOption_SocketAddressZZ_free(_res_conv);
23077 }
23078
23079 void  CS_LDK_CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(int64_tArray _res) {
23080         LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ _res_constr;
23081         _res_constr.datalen = _res->arr_len;
23082         if (_res_constr.datalen > 0)
23083                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ Elements");
23084         else
23085                 _res_constr.data = NULL;
23086         int64_t* _res_vals = _res->elems;
23087         for (size_t r = 0; r < _res_constr.datalen; r++) {
23088                 int64_t _res_conv_43 = _res_vals[r];
23089                 void* _res_conv_43_ptr = untag_ptr(_res_conv_43);
23090                 CHECK_ACCESS(_res_conv_43_ptr);
23091                 LDKC2Tuple_PublicKeyCOption_SocketAddressZZ _res_conv_43_conv = *(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ*)(_res_conv_43_ptr);
23092                 FREE(untag_ptr(_res_conv_43));
23093                 _res_constr.data[r] = _res_conv_43_conv;
23094         }
23095         FREE(_res);
23096         CVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ_free(_res_constr);
23097 }
23098
23099 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
23100         LDKCVec_u8Z o_ref;
23101         o_ref.datalen = o->arr_len;
23102         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23103         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
23104         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23105         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
23106         return tag_ptr(ret_conv, true);
23107 }
23108
23109 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_err(int64_t e) {
23110         LDKPeerHandleError e_conv;
23111         e_conv.inner = untag_ptr(e);
23112         e_conv.is_owned = ptr_is_owned(e);
23113         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23114         e_conv = PeerHandleError_clone(&e_conv);
23115         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23116         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
23117         return tag_ptr(ret_conv, true);
23118 }
23119
23120 jboolean  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(int64_t o) {
23121         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23122         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23123         return ret_conv;
23124 }
23125
23126 void  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_free(int64_t _res) {
23127         if (!ptr_is_owned(_res)) return;
23128         void* _res_ptr = untag_ptr(_res);
23129         CHECK_ACCESS(_res_ptr);
23130         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23131         FREE(untag_ptr(_res));
23132         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23133 }
23134
23135 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23136         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23137         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23138         return tag_ptr(ret_conv, true);
23139 }
23140 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(int64_t arg) {
23141         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23142         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23143         return ret_conv;
23144 }
23145
23146 int64_t  CS_LDK_CResult_CVec_u8ZPeerHandleErrorZ_clone(int64_t orig) {
23147         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23148         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23149         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23150         return tag_ptr(ret_conv, true);
23151 }
23152
23153 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_ok() {
23154         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23155         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23156         return tag_ptr(ret_conv, true);
23157 }
23158
23159 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_err(int64_t e) {
23160         LDKPeerHandleError e_conv;
23161         e_conv.inner = untag_ptr(e);
23162         e_conv.is_owned = ptr_is_owned(e);
23163         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23164         e_conv = PeerHandleError_clone(&e_conv);
23165         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23166         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23167         return tag_ptr(ret_conv, true);
23168 }
23169
23170 jboolean  CS_LDK_CResult_NonePeerHandleErrorZ_is_ok(int64_t o) {
23171         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23172         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23173         return ret_conv;
23174 }
23175
23176 void  CS_LDK_CResult_NonePeerHandleErrorZ_free(int64_t _res) {
23177         if (!ptr_is_owned(_res)) return;
23178         void* _res_ptr = untag_ptr(_res);
23179         CHECK_ACCESS(_res_ptr);
23180         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23181         FREE(untag_ptr(_res));
23182         CResult_NonePeerHandleErrorZ_free(_res_conv);
23183 }
23184
23185 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23186         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23187         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23188         return tag_ptr(ret_conv, true);
23189 }
23190 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_clone_ptr(int64_t arg) {
23191         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23192         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23193         return ret_conv;
23194 }
23195
23196 int64_t  CS_LDK_CResult_NonePeerHandleErrorZ_clone(int64_t orig) {
23197         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23198         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23199         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23200         return tag_ptr(ret_conv, true);
23201 }
23202
23203 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
23204         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23205         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23206         return tag_ptr(ret_conv, true);
23207 }
23208
23209 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_err(int64_t e) {
23210         LDKPeerHandleError e_conv;
23211         e_conv.inner = untag_ptr(e);
23212         e_conv.is_owned = ptr_is_owned(e);
23213         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23214         e_conv = PeerHandleError_clone(&e_conv);
23215         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23216         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23217         return tag_ptr(ret_conv, true);
23218 }
23219
23220 jboolean  CS_LDK_CResult_boolPeerHandleErrorZ_is_ok(int64_t o) {
23221         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23222         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23223         return ret_conv;
23224 }
23225
23226 void  CS_LDK_CResult_boolPeerHandleErrorZ_free(int64_t _res) {
23227         if (!ptr_is_owned(_res)) return;
23228         void* _res_ptr = untag_ptr(_res);
23229         CHECK_ACCESS(_res_ptr);
23230         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23231         FREE(untag_ptr(_res));
23232         CResult_boolPeerHandleErrorZ_free(_res_conv);
23233 }
23234
23235 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23236         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23237         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23238         return tag_ptr(ret_conv, true);
23239 }
23240 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_clone_ptr(int64_t arg) {
23241         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
23242         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
23243         return ret_conv;
23244 }
23245
23246 int64_t  CS_LDK_CResult_boolPeerHandleErrorZ_clone(int64_t orig) {
23247         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
23248         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23249         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
23250         return tag_ptr(ret_conv, true);
23251 }
23252
23253 int64_t  CS_LDK_CResult_u32GraphSyncErrorZ_ok(int32_t o) {
23254         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23255         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
23256         return tag_ptr(ret_conv, true);
23257 }
23258
23259 int64_t  CS_LDK_CResult_u32GraphSyncErrorZ_err(int64_t e) {
23260         void* e_ptr = untag_ptr(e);
23261         CHECK_ACCESS(e_ptr);
23262         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
23263         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
23264         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23265         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
23266         return tag_ptr(ret_conv, true);
23267 }
23268
23269 jboolean  CS_LDK_CResult_u32GraphSyncErrorZ_is_ok(int64_t o) {
23270         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
23271         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
23272         return ret_conv;
23273 }
23274
23275 void  CS_LDK_CResult_u32GraphSyncErrorZ_free(int64_t _res) {
23276         if (!ptr_is_owned(_res)) return;
23277         void* _res_ptr = untag_ptr(_res);
23278         CHECK_ACCESS(_res_ptr);
23279         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
23280         FREE(untag_ptr(_res));
23281         CResult_u32GraphSyncErrorZ_free(_res_conv);
23282 }
23283
23284 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_ok(int8_tArray o) {
23285         LDKCVec_u8Z o_ref;
23286         o_ref.datalen = o->arr_len;
23287         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
23288         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
23289         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23290         *ret_conv = CResult_CVec_u8ZIOErrorZ_ok(o_ref);
23291         return tag_ptr(ret_conv, true);
23292 }
23293
23294 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_err(int32_t e) {
23295         LDKIOError e_conv = LDKIOError_from_cs(e);
23296         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23297         *ret_conv = CResult_CVec_u8ZIOErrorZ_err(e_conv);
23298         return tag_ptr(ret_conv, true);
23299 }
23300
23301 jboolean  CS_LDK_CResult_CVec_u8ZIOErrorZ_is_ok(int64_t o) {
23302         LDKCResult_CVec_u8ZIOErrorZ* o_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(o);
23303         jboolean ret_conv = CResult_CVec_u8ZIOErrorZ_is_ok(o_conv);
23304         return ret_conv;
23305 }
23306
23307 void  CS_LDK_CResult_CVec_u8ZIOErrorZ_free(int64_t _res) {
23308         if (!ptr_is_owned(_res)) return;
23309         void* _res_ptr = untag_ptr(_res);
23310         CHECK_ACCESS(_res_ptr);
23311         LDKCResult_CVec_u8ZIOErrorZ _res_conv = *(LDKCResult_CVec_u8ZIOErrorZ*)(_res_ptr);
23312         FREE(untag_ptr(_res));
23313         CResult_CVec_u8ZIOErrorZ_free(_res_conv);
23314 }
23315
23316 static inline uint64_t CResult_CVec_u8ZIOErrorZ_clone_ptr(LDKCResult_CVec_u8ZIOErrorZ *NONNULL_PTR arg) {
23317         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23318         *ret_conv = CResult_CVec_u8ZIOErrorZ_clone(arg);
23319         return tag_ptr(ret_conv, true);
23320 }
23321 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_clone_ptr(int64_t arg) {
23322         LDKCResult_CVec_u8ZIOErrorZ* arg_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(arg);
23323         int64_t ret_conv = CResult_CVec_u8ZIOErrorZ_clone_ptr(arg_conv);
23324         return ret_conv;
23325 }
23326
23327 int64_t  CS_LDK_CResult_CVec_u8ZIOErrorZ_clone(int64_t orig) {
23328         LDKCResult_CVec_u8ZIOErrorZ* orig_conv = (LDKCResult_CVec_u8ZIOErrorZ*)untag_ptr(orig);
23329         LDKCResult_CVec_u8ZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZIOErrorZ), "LDKCResult_CVec_u8ZIOErrorZ");
23330         *ret_conv = CResult_CVec_u8ZIOErrorZ_clone(orig_conv);
23331         return tag_ptr(ret_conv, true);
23332 }
23333
23334 void  CS_LDK_CVec_StrZ_free(ptrArray _res) {
23335         LDKCVec_StrZ _res_constr;
23336         _res_constr.datalen = _res->arr_len;
23337         if (_res_constr.datalen > 0)
23338                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKStr), "LDKCVec_StrZ Elements");
23339         else
23340                 _res_constr.data = NULL;
23341         jstring* _res_vals = (void*) _res->elems;
23342         for (size_t i = 0; i < _res_constr.datalen; i++) {
23343                 jstring _res_conv_8 = _res_vals[i];
23344                 LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
23345                 _res_constr.data[i] = dummy;
23346         }
23347         FREE(_res);
23348         CVec_StrZ_free(_res_constr);
23349 }
23350
23351 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_ok(ptrArray o) {
23352         LDKCVec_StrZ o_constr;
23353         o_constr.datalen = o->arr_len;
23354         if (o_constr.datalen > 0)
23355                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKStr), "LDKCVec_StrZ Elements");
23356         else
23357                 o_constr.data = NULL;
23358         jstring* o_vals = (void*) o->elems;
23359         for (size_t i = 0; i < o_constr.datalen; i++) {
23360                 jstring o_conv_8 = o_vals[i];
23361                 LDKStr o_conv_8_conv = str_ref_to_owned_c(o_conv_8);
23362                 o_constr.data[i] = o_conv_8_conv;
23363         }
23364         FREE(o);
23365         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23366         *ret_conv = CResult_CVec_StrZIOErrorZ_ok(o_constr);
23367         return tag_ptr(ret_conv, true);
23368 }
23369
23370 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_err(int32_t e) {
23371         LDKIOError e_conv = LDKIOError_from_cs(e);
23372         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23373         *ret_conv = CResult_CVec_StrZIOErrorZ_err(e_conv);
23374         return tag_ptr(ret_conv, true);
23375 }
23376
23377 jboolean  CS_LDK_CResult_CVec_StrZIOErrorZ_is_ok(int64_t o) {
23378         LDKCResult_CVec_StrZIOErrorZ* o_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(o);
23379         jboolean ret_conv = CResult_CVec_StrZIOErrorZ_is_ok(o_conv);
23380         return ret_conv;
23381 }
23382
23383 void  CS_LDK_CResult_CVec_StrZIOErrorZ_free(int64_t _res) {
23384         if (!ptr_is_owned(_res)) return;
23385         void* _res_ptr = untag_ptr(_res);
23386         CHECK_ACCESS(_res_ptr);
23387         LDKCResult_CVec_StrZIOErrorZ _res_conv = *(LDKCResult_CVec_StrZIOErrorZ*)(_res_ptr);
23388         FREE(untag_ptr(_res));
23389         CResult_CVec_StrZIOErrorZ_free(_res_conv);
23390 }
23391
23392 static inline uint64_t CResult_CVec_StrZIOErrorZ_clone_ptr(LDKCResult_CVec_StrZIOErrorZ *NONNULL_PTR arg) {
23393         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23394         *ret_conv = CResult_CVec_StrZIOErrorZ_clone(arg);
23395         return tag_ptr(ret_conv, true);
23396 }
23397 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_clone_ptr(int64_t arg) {
23398         LDKCResult_CVec_StrZIOErrorZ* arg_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(arg);
23399         int64_t ret_conv = CResult_CVec_StrZIOErrorZ_clone_ptr(arg_conv);
23400         return ret_conv;
23401 }
23402
23403 int64_t  CS_LDK_CResult_CVec_StrZIOErrorZ_clone(int64_t orig) {
23404         LDKCResult_CVec_StrZIOErrorZ* orig_conv = (LDKCResult_CVec_StrZIOErrorZ*)untag_ptr(orig);
23405         LDKCResult_CVec_StrZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_StrZIOErrorZ), "LDKCResult_CVec_StrZIOErrorZ");
23406         *ret_conv = CResult_CVec_StrZIOErrorZ_clone(orig_conv);
23407         return tag_ptr(ret_conv, true);
23408 }
23409
23410 void  CS_LDK_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_free(int64_tArray _res) {
23411         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ _res_constr;
23412         _res_constr.datalen = _res->arr_len;
23413         if (_res_constr.datalen > 0)
23414                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ Elements");
23415         else
23416                 _res_constr.data = NULL;
23417         int64_t* _res_vals = _res->elems;
23418         for (size_t o = 0; o < _res_constr.datalen; o++) {
23419                 int64_t _res_conv_40 = _res_vals[o];
23420                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
23421                 CHECK_ACCESS(_res_conv_40_ptr);
23422                 LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ _res_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(_res_conv_40_ptr);
23423                 FREE(untag_ptr(_res_conv_40));
23424                 _res_constr.data[o] = _res_conv_40_conv;
23425         }
23426         FREE(_res);
23427         CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ_free(_res_constr);
23428 }
23429
23430 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_ok(int64_tArray o) {
23431         LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ o_constr;
23432         o_constr.datalen = o->arr_len;
23433         if (o_constr.datalen > 0)
23434                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ), "LDKCVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ Elements");
23435         else
23436                 o_constr.data = NULL;
23437         int64_t* o_vals = o->elems;
23438         for (size_t o = 0; o < o_constr.datalen; o++) {
23439                 int64_t o_conv_40 = o_vals[o];
23440                 void* o_conv_40_ptr = untag_ptr(o_conv_40);
23441                 CHECK_ACCESS(o_conv_40_ptr);
23442                 LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ o_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(o_conv_40_ptr);
23443                 o_conv_40_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone((LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(o_conv_40));
23444                 o_constr.data[o] = o_conv_40_conv;
23445         }
23446         FREE(o);
23447         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23448         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_ok(o_constr);
23449         return tag_ptr(ret_conv, true);
23450 }
23451
23452 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_err(int32_t e) {
23453         LDKIOError e_conv = LDKIOError_from_cs(e);
23454         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23455         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_err(e_conv);
23456         return tag_ptr(ret_conv, true);
23457 }
23458
23459 jboolean  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_is_ok(int64_t o) {
23460         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(o);
23461         jboolean ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_is_ok(o_conv);
23462         return ret_conv;
23463 }
23464
23465 void  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_free(int64_t _res) {
23466         if (!ptr_is_owned(_res)) return;
23467         void* _res_ptr = untag_ptr(_res);
23468         CHECK_ACCESS(_res_ptr);
23469         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)(_res_ptr);
23470         FREE(untag_ptr(_res));
23471         CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_free(_res_conv);
23472 }
23473
23474 static inline uint64_t CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ *NONNULL_PTR arg) {
23475         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23476         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(arg);
23477         return tag_ptr(ret_conv, true);
23478 }
23479 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone_ptr(int64_t arg) {
23480         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(arg);
23481         int64_t ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone_ptr(arg_conv);
23482         return ret_conv;
23483 }
23484
23485 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(int64_t orig) {
23486         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ*)untag_ptr(orig);
23487         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
23488         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ_clone(orig_conv);
23489         return tag_ptr(ret_conv, true);
23490 }
23491
23492 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_ok(int64_t o) {
23493         void* o_ptr = untag_ptr(o);
23494         CHECK_ACCESS(o_ptr);
23495         LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ o_conv = *(LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)(o_ptr);
23496         o_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_clone((LDKC2Tuple_ThirtyTwoBytesChannelMonitorZ*)untag_ptr(o));
23497         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23498         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_ok(o_conv);
23499         return tag_ptr(ret_conv, true);
23500 }
23501
23502 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_err(int32_t e) {
23503         LDKIOError e_conv = LDKIOError_from_cs(e);
23504         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23505         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_err(e_conv);
23506         return tag_ptr(ret_conv, true);
23507 }
23508
23509 jboolean  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_is_ok(int64_t o) {
23510         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* o_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(o);
23511         jboolean ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_is_ok(o_conv);
23512         return ret_conv;
23513 }
23514
23515 void  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_free(int64_t _res) {
23516         if (!ptr_is_owned(_res)) return;
23517         void* _res_ptr = untag_ptr(_res);
23518         CHECK_ACCESS(_res_ptr);
23519         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ _res_conv = *(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)(_res_ptr);
23520         FREE(untag_ptr(_res));
23521         CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_free(_res_conv);
23522 }
23523
23524 static inline uint64_t CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone_ptr(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ *NONNULL_PTR arg) {
23525         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23526         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(arg);
23527         return tag_ptr(ret_conv, true);
23528 }
23529 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone_ptr(int64_t arg) {
23530         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* arg_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(arg);
23531         int64_t ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone_ptr(arg_conv);
23532         return ret_conv;
23533 }
23534
23535 int64_t  CS_LDK_CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(int64_t orig) {
23536         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* orig_conv = (LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ*)untag_ptr(orig);
23537         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
23538         *ret_conv = CResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ_clone(orig_conv);
23539         return tag_ptr(ret_conv, true);
23540 }
23541
23542 int64_t  CS_LDK_COption_SecretKeyZ_some(int8_tArray o) {
23543         LDKSecretKey o_ref;
23544         CHECK(o->arr_len == 32);
23545         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
23546         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23547         *ret_copy = COption_SecretKeyZ_some(o_ref);
23548         int64_t ret_ref = tag_ptr(ret_copy, true);
23549         return ret_ref;
23550 }
23551
23552 int64_t  CS_LDK_COption_SecretKeyZ_none() {
23553         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23554         *ret_copy = COption_SecretKeyZ_none();
23555         int64_t ret_ref = tag_ptr(ret_copy, true);
23556         return ret_ref;
23557 }
23558
23559 void  CS_LDK_COption_SecretKeyZ_free(int64_t _res) {
23560         if (!ptr_is_owned(_res)) return;
23561         void* _res_ptr = untag_ptr(_res);
23562         CHECK_ACCESS(_res_ptr);
23563         LDKCOption_SecretKeyZ _res_conv = *(LDKCOption_SecretKeyZ*)(_res_ptr);
23564         FREE(untag_ptr(_res));
23565         COption_SecretKeyZ_free(_res_conv);
23566 }
23567
23568 static inline uint64_t COption_SecretKeyZ_clone_ptr(LDKCOption_SecretKeyZ *NONNULL_PTR arg) {
23569         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23570         *ret_copy = COption_SecretKeyZ_clone(arg);
23571         int64_t ret_ref = tag_ptr(ret_copy, true);
23572         return ret_ref;
23573 }
23574 int64_t  CS_LDK_COption_SecretKeyZ_clone_ptr(int64_t arg) {
23575         LDKCOption_SecretKeyZ* arg_conv = (LDKCOption_SecretKeyZ*)untag_ptr(arg);
23576         int64_t ret_conv = COption_SecretKeyZ_clone_ptr(arg_conv);
23577         return ret_conv;
23578 }
23579
23580 int64_t  CS_LDK_COption_SecretKeyZ_clone(int64_t orig) {
23581         LDKCOption_SecretKeyZ* orig_conv = (LDKCOption_SecretKeyZ*)untag_ptr(orig);
23582         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
23583         *ret_copy = COption_SecretKeyZ_clone(orig_conv);
23584         int64_t ret_ref = tag_ptr(ret_copy, true);
23585         return ret_ref;
23586 }
23587
23588 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_ok(int64_t o) {
23589         LDKVerifiedInvoiceRequest o_conv;
23590         o_conv.inner = untag_ptr(o);
23591         o_conv.is_owned = ptr_is_owned(o);
23592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23593         o_conv = VerifiedInvoiceRequest_clone(&o_conv);
23594         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23595         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_ok(o_conv);
23596         return tag_ptr(ret_conv, true);
23597 }
23598
23599 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_err() {
23600         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23601         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_err();
23602         return tag_ptr(ret_conv, true);
23603 }
23604
23605 jboolean  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_is_ok(int64_t o) {
23606         LDKCResult_VerifiedInvoiceRequestNoneZ* o_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(o);
23607         jboolean ret_conv = CResult_VerifiedInvoiceRequestNoneZ_is_ok(o_conv);
23608         return ret_conv;
23609 }
23610
23611 void  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_free(int64_t _res) {
23612         if (!ptr_is_owned(_res)) return;
23613         void* _res_ptr = untag_ptr(_res);
23614         CHECK_ACCESS(_res_ptr);
23615         LDKCResult_VerifiedInvoiceRequestNoneZ _res_conv = *(LDKCResult_VerifiedInvoiceRequestNoneZ*)(_res_ptr);
23616         FREE(untag_ptr(_res));
23617         CResult_VerifiedInvoiceRequestNoneZ_free(_res_conv);
23618 }
23619
23620 static inline uint64_t CResult_VerifiedInvoiceRequestNoneZ_clone_ptr(LDKCResult_VerifiedInvoiceRequestNoneZ *NONNULL_PTR arg) {
23621         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23622         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_clone(arg);
23623         return tag_ptr(ret_conv, true);
23624 }
23625 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_clone_ptr(int64_t arg) {
23626         LDKCResult_VerifiedInvoiceRequestNoneZ* arg_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(arg);
23627         int64_t ret_conv = CResult_VerifiedInvoiceRequestNoneZ_clone_ptr(arg_conv);
23628         return ret_conv;
23629 }
23630
23631 int64_t  CS_LDK_CResult_VerifiedInvoiceRequestNoneZ_clone(int64_t orig) {
23632         LDKCResult_VerifiedInvoiceRequestNoneZ* orig_conv = (LDKCResult_VerifiedInvoiceRequestNoneZ*)untag_ptr(orig);
23633         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
23634         *ret_conv = CResult_VerifiedInvoiceRequestNoneZ_clone(orig_conv);
23635         return tag_ptr(ret_conv, true);
23636 }
23637
23638 int32_t  CS_LDK_COption_NoneZ_some() {
23639         int32_t ret_conv = LDKCOption_NoneZ_to_cs(COption_NoneZ_some());
23640         return ret_conv;
23641 }
23642
23643 int32_t  CS_LDK_COption_NoneZ_none() {
23644         int32_t ret_conv = LDKCOption_NoneZ_to_cs(COption_NoneZ_none());
23645         return ret_conv;
23646 }
23647
23648 void  CS_LDK_COption_NoneZ_free(int32_t _res) {
23649         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_cs(_res);
23650         COption_NoneZ_free(_res_conv);
23651 }
23652
23653 void  CS_LDK_CVec_WitnessZ_free(ptrArray _res) {
23654         LDKCVec_WitnessZ _res_constr;
23655         _res_constr.datalen = _res->arr_len;
23656         if (_res_constr.datalen > 0)
23657                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKWitness), "LDKCVec_WitnessZ Elements");
23658         else
23659                 _res_constr.data = NULL;
23660         int8_tArray* _res_vals = (void*) _res->elems;
23661         for (size_t i = 0; i < _res_constr.datalen; i++) {
23662                 int8_tArray _res_conv_8 = _res_vals[i];
23663                 LDKWitness _res_conv_8_ref;
23664                 _res_conv_8_ref.datalen = _res_conv_8->arr_len;
23665                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKWitness Bytes");
23666                 memcpy(_res_conv_8_ref.data, _res_conv_8->elems, _res_conv_8_ref.datalen); FREE(_res_conv_8);
23667                 _res_conv_8_ref.data_is_owned = true;
23668                 _res_constr.data[i] = _res_conv_8_ref;
23669         }
23670         FREE(_res);
23671         CVec_WitnessZ_free(_res_constr);
23672 }
23673
23674 int64_t  CS_LDK_COption_i64Z_some(int64_t o) {
23675         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23676         *ret_copy = COption_i64Z_some(o);
23677         int64_t ret_ref = tag_ptr(ret_copy, true);
23678         return ret_ref;
23679 }
23680
23681 int64_t  CS_LDK_COption_i64Z_none() {
23682         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23683         *ret_copy = COption_i64Z_none();
23684         int64_t ret_ref = tag_ptr(ret_copy, true);
23685         return ret_ref;
23686 }
23687
23688 void  CS_LDK_COption_i64Z_free(int64_t _res) {
23689         if (!ptr_is_owned(_res)) return;
23690         void* _res_ptr = untag_ptr(_res);
23691         CHECK_ACCESS(_res_ptr);
23692         LDKCOption_i64Z _res_conv = *(LDKCOption_i64Z*)(_res_ptr);
23693         FREE(untag_ptr(_res));
23694         COption_i64Z_free(_res_conv);
23695 }
23696
23697 static inline uint64_t COption_i64Z_clone_ptr(LDKCOption_i64Z *NONNULL_PTR arg) {
23698         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23699         *ret_copy = COption_i64Z_clone(arg);
23700         int64_t ret_ref = tag_ptr(ret_copy, true);
23701         return ret_ref;
23702 }
23703 int64_t  CS_LDK_COption_i64Z_clone_ptr(int64_t arg) {
23704         LDKCOption_i64Z* arg_conv = (LDKCOption_i64Z*)untag_ptr(arg);
23705         int64_t ret_conv = COption_i64Z_clone_ptr(arg_conv);
23706         return ret_conv;
23707 }
23708
23709 int64_t  CS_LDK_COption_i64Z_clone(int64_t orig) {
23710         LDKCOption_i64Z* orig_conv = (LDKCOption_i64Z*)untag_ptr(orig);
23711         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
23712         *ret_copy = COption_i64Z_clone(orig_conv);
23713         int64_t ret_ref = tag_ptr(ret_copy, true);
23714         return ret_ref;
23715 }
23716
23717 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_ok(int64_t o) {
23718         void* o_ptr = untag_ptr(o);
23719         CHECK_ACCESS(o_ptr);
23720         LDKSocketAddress o_conv = *(LDKSocketAddress*)(o_ptr);
23721         o_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o));
23722         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23723         *ret_conv = CResult_SocketAddressDecodeErrorZ_ok(o_conv);
23724         return tag_ptr(ret_conv, true);
23725 }
23726
23727 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_err(int64_t e) {
23728         void* e_ptr = untag_ptr(e);
23729         CHECK_ACCESS(e_ptr);
23730         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23731         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23732         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23733         *ret_conv = CResult_SocketAddressDecodeErrorZ_err(e_conv);
23734         return tag_ptr(ret_conv, true);
23735 }
23736
23737 jboolean  CS_LDK_CResult_SocketAddressDecodeErrorZ_is_ok(int64_t o) {
23738         LDKCResult_SocketAddressDecodeErrorZ* o_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(o);
23739         jboolean ret_conv = CResult_SocketAddressDecodeErrorZ_is_ok(o_conv);
23740         return ret_conv;
23741 }
23742
23743 void  CS_LDK_CResult_SocketAddressDecodeErrorZ_free(int64_t _res) {
23744         if (!ptr_is_owned(_res)) return;
23745         void* _res_ptr = untag_ptr(_res);
23746         CHECK_ACCESS(_res_ptr);
23747         LDKCResult_SocketAddressDecodeErrorZ _res_conv = *(LDKCResult_SocketAddressDecodeErrorZ*)(_res_ptr);
23748         FREE(untag_ptr(_res));
23749         CResult_SocketAddressDecodeErrorZ_free(_res_conv);
23750 }
23751
23752 static inline uint64_t CResult_SocketAddressDecodeErrorZ_clone_ptr(LDKCResult_SocketAddressDecodeErrorZ *NONNULL_PTR arg) {
23753         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23754         *ret_conv = CResult_SocketAddressDecodeErrorZ_clone(arg);
23755         return tag_ptr(ret_conv, true);
23756 }
23757 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_clone_ptr(int64_t arg) {
23758         LDKCResult_SocketAddressDecodeErrorZ* arg_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(arg);
23759         int64_t ret_conv = CResult_SocketAddressDecodeErrorZ_clone_ptr(arg_conv);
23760         return ret_conv;
23761 }
23762
23763 int64_t  CS_LDK_CResult_SocketAddressDecodeErrorZ_clone(int64_t orig) {
23764         LDKCResult_SocketAddressDecodeErrorZ* orig_conv = (LDKCResult_SocketAddressDecodeErrorZ*)untag_ptr(orig);
23765         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
23766         *ret_conv = CResult_SocketAddressDecodeErrorZ_clone(orig_conv);
23767         return tag_ptr(ret_conv, true);
23768 }
23769
23770 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_ok(int64_t o) {
23771         void* o_ptr = untag_ptr(o);
23772         CHECK_ACCESS(o_ptr);
23773         LDKSocketAddress o_conv = *(LDKSocketAddress*)(o_ptr);
23774         o_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(o));
23775         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23776         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_ok(o_conv);
23777         return tag_ptr(ret_conv, true);
23778 }
23779
23780 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_err(int32_t e) {
23781         LDKSocketAddressParseError e_conv = LDKSocketAddressParseError_from_cs(e);
23782         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23783         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_err(e_conv);
23784         return tag_ptr(ret_conv, true);
23785 }
23786
23787 jboolean  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_is_ok(int64_t o) {
23788         LDKCResult_SocketAddressSocketAddressParseErrorZ* o_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(o);
23789         jboolean ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_is_ok(o_conv);
23790         return ret_conv;
23791 }
23792
23793 void  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_free(int64_t _res) {
23794         if (!ptr_is_owned(_res)) return;
23795         void* _res_ptr = untag_ptr(_res);
23796         CHECK_ACCESS(_res_ptr);
23797         LDKCResult_SocketAddressSocketAddressParseErrorZ _res_conv = *(LDKCResult_SocketAddressSocketAddressParseErrorZ*)(_res_ptr);
23798         FREE(untag_ptr(_res));
23799         CResult_SocketAddressSocketAddressParseErrorZ_free(_res_conv);
23800 }
23801
23802 static inline uint64_t CResult_SocketAddressSocketAddressParseErrorZ_clone_ptr(LDKCResult_SocketAddressSocketAddressParseErrorZ *NONNULL_PTR arg) {
23803         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23804         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_clone(arg);
23805         return tag_ptr(ret_conv, true);
23806 }
23807 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_clone_ptr(int64_t arg) {
23808         LDKCResult_SocketAddressSocketAddressParseErrorZ* arg_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(arg);
23809         int64_t ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_clone_ptr(arg_conv);
23810         return ret_conv;
23811 }
23812
23813 int64_t  CS_LDK_CResult_SocketAddressSocketAddressParseErrorZ_clone(int64_t orig) {
23814         LDKCResult_SocketAddressSocketAddressParseErrorZ* orig_conv = (LDKCResult_SocketAddressSocketAddressParseErrorZ*)untag_ptr(orig);
23815         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
23816         *ret_conv = CResult_SocketAddressSocketAddressParseErrorZ_clone(orig_conv);
23817         return tag_ptr(ret_conv, true);
23818 }
23819
23820 void  CS_LDK_CVec_UpdateAddHTLCZ_free(int64_tArray _res) {
23821         LDKCVec_UpdateAddHTLCZ _res_constr;
23822         _res_constr.datalen = _res->arr_len;
23823         if (_res_constr.datalen > 0)
23824                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23825         else
23826                 _res_constr.data = NULL;
23827         int64_t* _res_vals = _res->elems;
23828         for (size_t p = 0; p < _res_constr.datalen; p++) {
23829                 int64_t _res_conv_15 = _res_vals[p];
23830                 LDKUpdateAddHTLC _res_conv_15_conv;
23831                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
23832                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
23833                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
23834                 _res_constr.data[p] = _res_conv_15_conv;
23835         }
23836         FREE(_res);
23837         CVec_UpdateAddHTLCZ_free(_res_constr);
23838 }
23839
23840 void  CS_LDK_CVec_UpdateFulfillHTLCZ_free(int64_tArray _res) {
23841         LDKCVec_UpdateFulfillHTLCZ _res_constr;
23842         _res_constr.datalen = _res->arr_len;
23843         if (_res_constr.datalen > 0)
23844                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23845         else
23846                 _res_constr.data = NULL;
23847         int64_t* _res_vals = _res->elems;
23848         for (size_t t = 0; t < _res_constr.datalen; t++) {
23849                 int64_t _res_conv_19 = _res_vals[t];
23850                 LDKUpdateFulfillHTLC _res_conv_19_conv;
23851                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
23852                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
23853                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23854                 _res_constr.data[t] = _res_conv_19_conv;
23855         }
23856         FREE(_res);
23857         CVec_UpdateFulfillHTLCZ_free(_res_constr);
23858 }
23859
23860 void  CS_LDK_CVec_UpdateFailHTLCZ_free(int64_tArray _res) {
23861         LDKCVec_UpdateFailHTLCZ _res_constr;
23862         _res_constr.datalen = _res->arr_len;
23863         if (_res_constr.datalen > 0)
23864                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23865         else
23866                 _res_constr.data = NULL;
23867         int64_t* _res_vals = _res->elems;
23868         for (size_t q = 0; q < _res_constr.datalen; q++) {
23869                 int64_t _res_conv_16 = _res_vals[q];
23870                 LDKUpdateFailHTLC _res_conv_16_conv;
23871                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
23872                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
23873                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
23874                 _res_constr.data[q] = _res_conv_16_conv;
23875         }
23876         FREE(_res);
23877         CVec_UpdateFailHTLCZ_free(_res_constr);
23878 }
23879
23880 void  CS_LDK_CVec_UpdateFailMalformedHTLCZ_free(int64_tArray _res) {
23881         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
23882         _res_constr.datalen = _res->arr_len;
23883         if (_res_constr.datalen > 0)
23884                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23885         else
23886                 _res_constr.data = NULL;
23887         int64_t* _res_vals = _res->elems;
23888         for (size_t z = 0; z < _res_constr.datalen; z++) {
23889                 int64_t _res_conv_25 = _res_vals[z];
23890                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
23891                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
23892                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
23893                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
23894                 _res_constr.data[z] = _res_conv_25_conv;
23895         }
23896         FREE(_res);
23897         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
23898 }
23899
23900 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_ok(int64_t o) {
23901         LDKAcceptChannel o_conv;
23902         o_conv.inner = untag_ptr(o);
23903         o_conv.is_owned = ptr_is_owned(o);
23904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23905         o_conv = AcceptChannel_clone(&o_conv);
23906         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23907         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
23908         return tag_ptr(ret_conv, true);
23909 }
23910
23911 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_err(int64_t e) {
23912         void* e_ptr = untag_ptr(e);
23913         CHECK_ACCESS(e_ptr);
23914         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23915         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23916         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23917         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
23918         return tag_ptr(ret_conv, true);
23919 }
23920
23921 jboolean  CS_LDK_CResult_AcceptChannelDecodeErrorZ_is_ok(int64_t o) {
23922         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
23923         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
23924         return ret_conv;
23925 }
23926
23927 void  CS_LDK_CResult_AcceptChannelDecodeErrorZ_free(int64_t _res) {
23928         if (!ptr_is_owned(_res)) return;
23929         void* _res_ptr = untag_ptr(_res);
23930         CHECK_ACCESS(_res_ptr);
23931         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
23932         FREE(untag_ptr(_res));
23933         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
23934 }
23935
23936 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
23937         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23938         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
23939         return tag_ptr(ret_conv, true);
23940 }
23941 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_clone_ptr(int64_t arg) {
23942         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
23943         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
23944         return ret_conv;
23945 }
23946
23947 int64_t  CS_LDK_CResult_AcceptChannelDecodeErrorZ_clone(int64_t orig) {
23948         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
23949         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23950         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
23951         return tag_ptr(ret_conv, true);
23952 }
23953
23954 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_ok(int64_t o) {
23955         LDKAcceptChannelV2 o_conv;
23956         o_conv.inner = untag_ptr(o);
23957         o_conv.is_owned = ptr_is_owned(o);
23958         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23959         o_conv = AcceptChannelV2_clone(&o_conv);
23960         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
23961         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_ok(o_conv);
23962         return tag_ptr(ret_conv, true);
23963 }
23964
23965 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_err(int64_t e) {
23966         void* e_ptr = untag_ptr(e);
23967         CHECK_ACCESS(e_ptr);
23968         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23969         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23970         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
23971         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_err(e_conv);
23972         return tag_ptr(ret_conv, true);
23973 }
23974
23975 jboolean  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_is_ok(int64_t o) {
23976         LDKCResult_AcceptChannelV2DecodeErrorZ* o_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(o);
23977         jboolean ret_conv = CResult_AcceptChannelV2DecodeErrorZ_is_ok(o_conv);
23978         return ret_conv;
23979 }
23980
23981 void  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_free(int64_t _res) {
23982         if (!ptr_is_owned(_res)) return;
23983         void* _res_ptr = untag_ptr(_res);
23984         CHECK_ACCESS(_res_ptr);
23985         LDKCResult_AcceptChannelV2DecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelV2DecodeErrorZ*)(_res_ptr);
23986         FREE(untag_ptr(_res));
23987         CResult_AcceptChannelV2DecodeErrorZ_free(_res_conv);
23988 }
23989
23990 static inline uint64_t CResult_AcceptChannelV2DecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelV2DecodeErrorZ *NONNULL_PTR arg) {
23991         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
23992         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_clone(arg);
23993         return tag_ptr(ret_conv, true);
23994 }
23995 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_clone_ptr(int64_t arg) {
23996         LDKCResult_AcceptChannelV2DecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(arg);
23997         int64_t ret_conv = CResult_AcceptChannelV2DecodeErrorZ_clone_ptr(arg_conv);
23998         return ret_conv;
23999 }
24000
24001 int64_t  CS_LDK_CResult_AcceptChannelV2DecodeErrorZ_clone(int64_t orig) {
24002         LDKCResult_AcceptChannelV2DecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelV2DecodeErrorZ*)untag_ptr(orig);
24003         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
24004         *ret_conv = CResult_AcceptChannelV2DecodeErrorZ_clone(orig_conv);
24005         return tag_ptr(ret_conv, true);
24006 }
24007
24008 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_ok(int64_t o) {
24009         LDKTxAddInput o_conv;
24010         o_conv.inner = untag_ptr(o);
24011         o_conv.is_owned = ptr_is_owned(o);
24012         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24013         o_conv = TxAddInput_clone(&o_conv);
24014         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24015         *ret_conv = CResult_TxAddInputDecodeErrorZ_ok(o_conv);
24016         return tag_ptr(ret_conv, true);
24017 }
24018
24019 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_err(int64_t e) {
24020         void* e_ptr = untag_ptr(e);
24021         CHECK_ACCESS(e_ptr);
24022         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24023         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24024         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24025         *ret_conv = CResult_TxAddInputDecodeErrorZ_err(e_conv);
24026         return tag_ptr(ret_conv, true);
24027 }
24028
24029 jboolean  CS_LDK_CResult_TxAddInputDecodeErrorZ_is_ok(int64_t o) {
24030         LDKCResult_TxAddInputDecodeErrorZ* o_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(o);
24031         jboolean ret_conv = CResult_TxAddInputDecodeErrorZ_is_ok(o_conv);
24032         return ret_conv;
24033 }
24034
24035 void  CS_LDK_CResult_TxAddInputDecodeErrorZ_free(int64_t _res) {
24036         if (!ptr_is_owned(_res)) return;
24037         void* _res_ptr = untag_ptr(_res);
24038         CHECK_ACCESS(_res_ptr);
24039         LDKCResult_TxAddInputDecodeErrorZ _res_conv = *(LDKCResult_TxAddInputDecodeErrorZ*)(_res_ptr);
24040         FREE(untag_ptr(_res));
24041         CResult_TxAddInputDecodeErrorZ_free(_res_conv);
24042 }
24043
24044 static inline uint64_t CResult_TxAddInputDecodeErrorZ_clone_ptr(LDKCResult_TxAddInputDecodeErrorZ *NONNULL_PTR arg) {
24045         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24046         *ret_conv = CResult_TxAddInputDecodeErrorZ_clone(arg);
24047         return tag_ptr(ret_conv, true);
24048 }
24049 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_clone_ptr(int64_t arg) {
24050         LDKCResult_TxAddInputDecodeErrorZ* arg_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(arg);
24051         int64_t ret_conv = CResult_TxAddInputDecodeErrorZ_clone_ptr(arg_conv);
24052         return ret_conv;
24053 }
24054
24055 int64_t  CS_LDK_CResult_TxAddInputDecodeErrorZ_clone(int64_t orig) {
24056         LDKCResult_TxAddInputDecodeErrorZ* orig_conv = (LDKCResult_TxAddInputDecodeErrorZ*)untag_ptr(orig);
24057         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
24058         *ret_conv = CResult_TxAddInputDecodeErrorZ_clone(orig_conv);
24059         return tag_ptr(ret_conv, true);
24060 }
24061
24062 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_ok(int64_t o) {
24063         LDKTxAddOutput o_conv;
24064         o_conv.inner = untag_ptr(o);
24065         o_conv.is_owned = ptr_is_owned(o);
24066         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24067         o_conv = TxAddOutput_clone(&o_conv);
24068         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24069         *ret_conv = CResult_TxAddOutputDecodeErrorZ_ok(o_conv);
24070         return tag_ptr(ret_conv, true);
24071 }
24072
24073 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_err(int64_t e) {
24074         void* e_ptr = untag_ptr(e);
24075         CHECK_ACCESS(e_ptr);
24076         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24077         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24078         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24079         *ret_conv = CResult_TxAddOutputDecodeErrorZ_err(e_conv);
24080         return tag_ptr(ret_conv, true);
24081 }
24082
24083 jboolean  CS_LDK_CResult_TxAddOutputDecodeErrorZ_is_ok(int64_t o) {
24084         LDKCResult_TxAddOutputDecodeErrorZ* o_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(o);
24085         jboolean ret_conv = CResult_TxAddOutputDecodeErrorZ_is_ok(o_conv);
24086         return ret_conv;
24087 }
24088
24089 void  CS_LDK_CResult_TxAddOutputDecodeErrorZ_free(int64_t _res) {
24090         if (!ptr_is_owned(_res)) return;
24091         void* _res_ptr = untag_ptr(_res);
24092         CHECK_ACCESS(_res_ptr);
24093         LDKCResult_TxAddOutputDecodeErrorZ _res_conv = *(LDKCResult_TxAddOutputDecodeErrorZ*)(_res_ptr);
24094         FREE(untag_ptr(_res));
24095         CResult_TxAddOutputDecodeErrorZ_free(_res_conv);
24096 }
24097
24098 static inline uint64_t CResult_TxAddOutputDecodeErrorZ_clone_ptr(LDKCResult_TxAddOutputDecodeErrorZ *NONNULL_PTR arg) {
24099         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24100         *ret_conv = CResult_TxAddOutputDecodeErrorZ_clone(arg);
24101         return tag_ptr(ret_conv, true);
24102 }
24103 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_clone_ptr(int64_t arg) {
24104         LDKCResult_TxAddOutputDecodeErrorZ* arg_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(arg);
24105         int64_t ret_conv = CResult_TxAddOutputDecodeErrorZ_clone_ptr(arg_conv);
24106         return ret_conv;
24107 }
24108
24109 int64_t  CS_LDK_CResult_TxAddOutputDecodeErrorZ_clone(int64_t orig) {
24110         LDKCResult_TxAddOutputDecodeErrorZ* orig_conv = (LDKCResult_TxAddOutputDecodeErrorZ*)untag_ptr(orig);
24111         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
24112         *ret_conv = CResult_TxAddOutputDecodeErrorZ_clone(orig_conv);
24113         return tag_ptr(ret_conv, true);
24114 }
24115
24116 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_ok(int64_t o) {
24117         LDKTxRemoveInput o_conv;
24118         o_conv.inner = untag_ptr(o);
24119         o_conv.is_owned = ptr_is_owned(o);
24120         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24121         o_conv = TxRemoveInput_clone(&o_conv);
24122         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24123         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_ok(o_conv);
24124         return tag_ptr(ret_conv, true);
24125 }
24126
24127 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_err(int64_t e) {
24128         void* e_ptr = untag_ptr(e);
24129         CHECK_ACCESS(e_ptr);
24130         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24131         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24132         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24133         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_err(e_conv);
24134         return tag_ptr(ret_conv, true);
24135 }
24136
24137 jboolean  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_is_ok(int64_t o) {
24138         LDKCResult_TxRemoveInputDecodeErrorZ* o_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(o);
24139         jboolean ret_conv = CResult_TxRemoveInputDecodeErrorZ_is_ok(o_conv);
24140         return ret_conv;
24141 }
24142
24143 void  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_free(int64_t _res) {
24144         if (!ptr_is_owned(_res)) return;
24145         void* _res_ptr = untag_ptr(_res);
24146         CHECK_ACCESS(_res_ptr);
24147         LDKCResult_TxRemoveInputDecodeErrorZ _res_conv = *(LDKCResult_TxRemoveInputDecodeErrorZ*)(_res_ptr);
24148         FREE(untag_ptr(_res));
24149         CResult_TxRemoveInputDecodeErrorZ_free(_res_conv);
24150 }
24151
24152 static inline uint64_t CResult_TxRemoveInputDecodeErrorZ_clone_ptr(LDKCResult_TxRemoveInputDecodeErrorZ *NONNULL_PTR arg) {
24153         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24154         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_clone(arg);
24155         return tag_ptr(ret_conv, true);
24156 }
24157 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_clone_ptr(int64_t arg) {
24158         LDKCResult_TxRemoveInputDecodeErrorZ* arg_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(arg);
24159         int64_t ret_conv = CResult_TxRemoveInputDecodeErrorZ_clone_ptr(arg_conv);
24160         return ret_conv;
24161 }
24162
24163 int64_t  CS_LDK_CResult_TxRemoveInputDecodeErrorZ_clone(int64_t orig) {
24164         LDKCResult_TxRemoveInputDecodeErrorZ* orig_conv = (LDKCResult_TxRemoveInputDecodeErrorZ*)untag_ptr(orig);
24165         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
24166         *ret_conv = CResult_TxRemoveInputDecodeErrorZ_clone(orig_conv);
24167         return tag_ptr(ret_conv, true);
24168 }
24169
24170 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_ok(int64_t o) {
24171         LDKTxRemoveOutput o_conv;
24172         o_conv.inner = untag_ptr(o);
24173         o_conv.is_owned = ptr_is_owned(o);
24174         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24175         o_conv = TxRemoveOutput_clone(&o_conv);
24176         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24177         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_ok(o_conv);
24178         return tag_ptr(ret_conv, true);
24179 }
24180
24181 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_err(int64_t e) {
24182         void* e_ptr = untag_ptr(e);
24183         CHECK_ACCESS(e_ptr);
24184         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24185         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24186         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24187         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_err(e_conv);
24188         return tag_ptr(ret_conv, true);
24189 }
24190
24191 jboolean  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_is_ok(int64_t o) {
24192         LDKCResult_TxRemoveOutputDecodeErrorZ* o_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(o);
24193         jboolean ret_conv = CResult_TxRemoveOutputDecodeErrorZ_is_ok(o_conv);
24194         return ret_conv;
24195 }
24196
24197 void  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_free(int64_t _res) {
24198         if (!ptr_is_owned(_res)) return;
24199         void* _res_ptr = untag_ptr(_res);
24200         CHECK_ACCESS(_res_ptr);
24201         LDKCResult_TxRemoveOutputDecodeErrorZ _res_conv = *(LDKCResult_TxRemoveOutputDecodeErrorZ*)(_res_ptr);
24202         FREE(untag_ptr(_res));
24203         CResult_TxRemoveOutputDecodeErrorZ_free(_res_conv);
24204 }
24205
24206 static inline uint64_t CResult_TxRemoveOutputDecodeErrorZ_clone_ptr(LDKCResult_TxRemoveOutputDecodeErrorZ *NONNULL_PTR arg) {
24207         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24208         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_clone(arg);
24209         return tag_ptr(ret_conv, true);
24210 }
24211 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_clone_ptr(int64_t arg) {
24212         LDKCResult_TxRemoveOutputDecodeErrorZ* arg_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(arg);
24213         int64_t ret_conv = CResult_TxRemoveOutputDecodeErrorZ_clone_ptr(arg_conv);
24214         return ret_conv;
24215 }
24216
24217 int64_t  CS_LDK_CResult_TxRemoveOutputDecodeErrorZ_clone(int64_t orig) {
24218         LDKCResult_TxRemoveOutputDecodeErrorZ* orig_conv = (LDKCResult_TxRemoveOutputDecodeErrorZ*)untag_ptr(orig);
24219         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
24220         *ret_conv = CResult_TxRemoveOutputDecodeErrorZ_clone(orig_conv);
24221         return tag_ptr(ret_conv, true);
24222 }
24223
24224 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_ok(int64_t o) {
24225         LDKTxComplete o_conv;
24226         o_conv.inner = untag_ptr(o);
24227         o_conv.is_owned = ptr_is_owned(o);
24228         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24229         o_conv = TxComplete_clone(&o_conv);
24230         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24231         *ret_conv = CResult_TxCompleteDecodeErrorZ_ok(o_conv);
24232         return tag_ptr(ret_conv, true);
24233 }
24234
24235 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_err(int64_t e) {
24236         void* e_ptr = untag_ptr(e);
24237         CHECK_ACCESS(e_ptr);
24238         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24239         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24240         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24241         *ret_conv = CResult_TxCompleteDecodeErrorZ_err(e_conv);
24242         return tag_ptr(ret_conv, true);
24243 }
24244
24245 jboolean  CS_LDK_CResult_TxCompleteDecodeErrorZ_is_ok(int64_t o) {
24246         LDKCResult_TxCompleteDecodeErrorZ* o_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(o);
24247         jboolean ret_conv = CResult_TxCompleteDecodeErrorZ_is_ok(o_conv);
24248         return ret_conv;
24249 }
24250
24251 void  CS_LDK_CResult_TxCompleteDecodeErrorZ_free(int64_t _res) {
24252         if (!ptr_is_owned(_res)) return;
24253         void* _res_ptr = untag_ptr(_res);
24254         CHECK_ACCESS(_res_ptr);
24255         LDKCResult_TxCompleteDecodeErrorZ _res_conv = *(LDKCResult_TxCompleteDecodeErrorZ*)(_res_ptr);
24256         FREE(untag_ptr(_res));
24257         CResult_TxCompleteDecodeErrorZ_free(_res_conv);
24258 }
24259
24260 static inline uint64_t CResult_TxCompleteDecodeErrorZ_clone_ptr(LDKCResult_TxCompleteDecodeErrorZ *NONNULL_PTR arg) {
24261         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24262         *ret_conv = CResult_TxCompleteDecodeErrorZ_clone(arg);
24263         return tag_ptr(ret_conv, true);
24264 }
24265 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_clone_ptr(int64_t arg) {
24266         LDKCResult_TxCompleteDecodeErrorZ* arg_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(arg);
24267         int64_t ret_conv = CResult_TxCompleteDecodeErrorZ_clone_ptr(arg_conv);
24268         return ret_conv;
24269 }
24270
24271 int64_t  CS_LDK_CResult_TxCompleteDecodeErrorZ_clone(int64_t orig) {
24272         LDKCResult_TxCompleteDecodeErrorZ* orig_conv = (LDKCResult_TxCompleteDecodeErrorZ*)untag_ptr(orig);
24273         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
24274         *ret_conv = CResult_TxCompleteDecodeErrorZ_clone(orig_conv);
24275         return tag_ptr(ret_conv, true);
24276 }
24277
24278 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_ok(int64_t o) {
24279         LDKTxSignatures o_conv;
24280         o_conv.inner = untag_ptr(o);
24281         o_conv.is_owned = ptr_is_owned(o);
24282         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24283         o_conv = TxSignatures_clone(&o_conv);
24284         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24285         *ret_conv = CResult_TxSignaturesDecodeErrorZ_ok(o_conv);
24286         return tag_ptr(ret_conv, true);
24287 }
24288
24289 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_err(int64_t e) {
24290         void* e_ptr = untag_ptr(e);
24291         CHECK_ACCESS(e_ptr);
24292         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24293         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24294         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24295         *ret_conv = CResult_TxSignaturesDecodeErrorZ_err(e_conv);
24296         return tag_ptr(ret_conv, true);
24297 }
24298
24299 jboolean  CS_LDK_CResult_TxSignaturesDecodeErrorZ_is_ok(int64_t o) {
24300         LDKCResult_TxSignaturesDecodeErrorZ* o_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(o);
24301         jboolean ret_conv = CResult_TxSignaturesDecodeErrorZ_is_ok(o_conv);
24302         return ret_conv;
24303 }
24304
24305 void  CS_LDK_CResult_TxSignaturesDecodeErrorZ_free(int64_t _res) {
24306         if (!ptr_is_owned(_res)) return;
24307         void* _res_ptr = untag_ptr(_res);
24308         CHECK_ACCESS(_res_ptr);
24309         LDKCResult_TxSignaturesDecodeErrorZ _res_conv = *(LDKCResult_TxSignaturesDecodeErrorZ*)(_res_ptr);
24310         FREE(untag_ptr(_res));
24311         CResult_TxSignaturesDecodeErrorZ_free(_res_conv);
24312 }
24313
24314 static inline uint64_t CResult_TxSignaturesDecodeErrorZ_clone_ptr(LDKCResult_TxSignaturesDecodeErrorZ *NONNULL_PTR arg) {
24315         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24316         *ret_conv = CResult_TxSignaturesDecodeErrorZ_clone(arg);
24317         return tag_ptr(ret_conv, true);
24318 }
24319 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_clone_ptr(int64_t arg) {
24320         LDKCResult_TxSignaturesDecodeErrorZ* arg_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(arg);
24321         int64_t ret_conv = CResult_TxSignaturesDecodeErrorZ_clone_ptr(arg_conv);
24322         return ret_conv;
24323 }
24324
24325 int64_t  CS_LDK_CResult_TxSignaturesDecodeErrorZ_clone(int64_t orig) {
24326         LDKCResult_TxSignaturesDecodeErrorZ* orig_conv = (LDKCResult_TxSignaturesDecodeErrorZ*)untag_ptr(orig);
24327         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
24328         *ret_conv = CResult_TxSignaturesDecodeErrorZ_clone(orig_conv);
24329         return tag_ptr(ret_conv, true);
24330 }
24331
24332 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_ok(int64_t o) {
24333         LDKTxInitRbf o_conv;
24334         o_conv.inner = untag_ptr(o);
24335         o_conv.is_owned = ptr_is_owned(o);
24336         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24337         o_conv = TxInitRbf_clone(&o_conv);
24338         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24339         *ret_conv = CResult_TxInitRbfDecodeErrorZ_ok(o_conv);
24340         return tag_ptr(ret_conv, true);
24341 }
24342
24343 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_err(int64_t e) {
24344         void* e_ptr = untag_ptr(e);
24345         CHECK_ACCESS(e_ptr);
24346         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24347         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24348         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24349         *ret_conv = CResult_TxInitRbfDecodeErrorZ_err(e_conv);
24350         return tag_ptr(ret_conv, true);
24351 }
24352
24353 jboolean  CS_LDK_CResult_TxInitRbfDecodeErrorZ_is_ok(int64_t o) {
24354         LDKCResult_TxInitRbfDecodeErrorZ* o_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(o);
24355         jboolean ret_conv = CResult_TxInitRbfDecodeErrorZ_is_ok(o_conv);
24356         return ret_conv;
24357 }
24358
24359 void  CS_LDK_CResult_TxInitRbfDecodeErrorZ_free(int64_t _res) {
24360         if (!ptr_is_owned(_res)) return;
24361         void* _res_ptr = untag_ptr(_res);
24362         CHECK_ACCESS(_res_ptr);
24363         LDKCResult_TxInitRbfDecodeErrorZ _res_conv = *(LDKCResult_TxInitRbfDecodeErrorZ*)(_res_ptr);
24364         FREE(untag_ptr(_res));
24365         CResult_TxInitRbfDecodeErrorZ_free(_res_conv);
24366 }
24367
24368 static inline uint64_t CResult_TxInitRbfDecodeErrorZ_clone_ptr(LDKCResult_TxInitRbfDecodeErrorZ *NONNULL_PTR arg) {
24369         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24370         *ret_conv = CResult_TxInitRbfDecodeErrorZ_clone(arg);
24371         return tag_ptr(ret_conv, true);
24372 }
24373 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_clone_ptr(int64_t arg) {
24374         LDKCResult_TxInitRbfDecodeErrorZ* arg_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(arg);
24375         int64_t ret_conv = CResult_TxInitRbfDecodeErrorZ_clone_ptr(arg_conv);
24376         return ret_conv;
24377 }
24378
24379 int64_t  CS_LDK_CResult_TxInitRbfDecodeErrorZ_clone(int64_t orig) {
24380         LDKCResult_TxInitRbfDecodeErrorZ* orig_conv = (LDKCResult_TxInitRbfDecodeErrorZ*)untag_ptr(orig);
24381         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
24382         *ret_conv = CResult_TxInitRbfDecodeErrorZ_clone(orig_conv);
24383         return tag_ptr(ret_conv, true);
24384 }
24385
24386 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_ok(int64_t o) {
24387         LDKTxAckRbf o_conv;
24388         o_conv.inner = untag_ptr(o);
24389         o_conv.is_owned = ptr_is_owned(o);
24390         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24391         o_conv = TxAckRbf_clone(&o_conv);
24392         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24393         *ret_conv = CResult_TxAckRbfDecodeErrorZ_ok(o_conv);
24394         return tag_ptr(ret_conv, true);
24395 }
24396
24397 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_err(int64_t e) {
24398         void* e_ptr = untag_ptr(e);
24399         CHECK_ACCESS(e_ptr);
24400         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24401         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24402         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24403         *ret_conv = CResult_TxAckRbfDecodeErrorZ_err(e_conv);
24404         return tag_ptr(ret_conv, true);
24405 }
24406
24407 jboolean  CS_LDK_CResult_TxAckRbfDecodeErrorZ_is_ok(int64_t o) {
24408         LDKCResult_TxAckRbfDecodeErrorZ* o_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(o);
24409         jboolean ret_conv = CResult_TxAckRbfDecodeErrorZ_is_ok(o_conv);
24410         return ret_conv;
24411 }
24412
24413 void  CS_LDK_CResult_TxAckRbfDecodeErrorZ_free(int64_t _res) {
24414         if (!ptr_is_owned(_res)) return;
24415         void* _res_ptr = untag_ptr(_res);
24416         CHECK_ACCESS(_res_ptr);
24417         LDKCResult_TxAckRbfDecodeErrorZ _res_conv = *(LDKCResult_TxAckRbfDecodeErrorZ*)(_res_ptr);
24418         FREE(untag_ptr(_res));
24419         CResult_TxAckRbfDecodeErrorZ_free(_res_conv);
24420 }
24421
24422 static inline uint64_t CResult_TxAckRbfDecodeErrorZ_clone_ptr(LDKCResult_TxAckRbfDecodeErrorZ *NONNULL_PTR arg) {
24423         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24424         *ret_conv = CResult_TxAckRbfDecodeErrorZ_clone(arg);
24425         return tag_ptr(ret_conv, true);
24426 }
24427 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_clone_ptr(int64_t arg) {
24428         LDKCResult_TxAckRbfDecodeErrorZ* arg_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(arg);
24429         int64_t ret_conv = CResult_TxAckRbfDecodeErrorZ_clone_ptr(arg_conv);
24430         return ret_conv;
24431 }
24432
24433 int64_t  CS_LDK_CResult_TxAckRbfDecodeErrorZ_clone(int64_t orig) {
24434         LDKCResult_TxAckRbfDecodeErrorZ* orig_conv = (LDKCResult_TxAckRbfDecodeErrorZ*)untag_ptr(orig);
24435         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
24436         *ret_conv = CResult_TxAckRbfDecodeErrorZ_clone(orig_conv);
24437         return tag_ptr(ret_conv, true);
24438 }
24439
24440 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_ok(int64_t o) {
24441         LDKTxAbort o_conv;
24442         o_conv.inner = untag_ptr(o);
24443         o_conv.is_owned = ptr_is_owned(o);
24444         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24445         o_conv = TxAbort_clone(&o_conv);
24446         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24447         *ret_conv = CResult_TxAbortDecodeErrorZ_ok(o_conv);
24448         return tag_ptr(ret_conv, true);
24449 }
24450
24451 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_err(int64_t e) {
24452         void* e_ptr = untag_ptr(e);
24453         CHECK_ACCESS(e_ptr);
24454         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24455         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24456         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24457         *ret_conv = CResult_TxAbortDecodeErrorZ_err(e_conv);
24458         return tag_ptr(ret_conv, true);
24459 }
24460
24461 jboolean  CS_LDK_CResult_TxAbortDecodeErrorZ_is_ok(int64_t o) {
24462         LDKCResult_TxAbortDecodeErrorZ* o_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(o);
24463         jboolean ret_conv = CResult_TxAbortDecodeErrorZ_is_ok(o_conv);
24464         return ret_conv;
24465 }
24466
24467 void  CS_LDK_CResult_TxAbortDecodeErrorZ_free(int64_t _res) {
24468         if (!ptr_is_owned(_res)) return;
24469         void* _res_ptr = untag_ptr(_res);
24470         CHECK_ACCESS(_res_ptr);
24471         LDKCResult_TxAbortDecodeErrorZ _res_conv = *(LDKCResult_TxAbortDecodeErrorZ*)(_res_ptr);
24472         FREE(untag_ptr(_res));
24473         CResult_TxAbortDecodeErrorZ_free(_res_conv);
24474 }
24475
24476 static inline uint64_t CResult_TxAbortDecodeErrorZ_clone_ptr(LDKCResult_TxAbortDecodeErrorZ *NONNULL_PTR arg) {
24477         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24478         *ret_conv = CResult_TxAbortDecodeErrorZ_clone(arg);
24479         return tag_ptr(ret_conv, true);
24480 }
24481 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_clone_ptr(int64_t arg) {
24482         LDKCResult_TxAbortDecodeErrorZ* arg_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(arg);
24483         int64_t ret_conv = CResult_TxAbortDecodeErrorZ_clone_ptr(arg_conv);
24484         return ret_conv;
24485 }
24486
24487 int64_t  CS_LDK_CResult_TxAbortDecodeErrorZ_clone(int64_t orig) {
24488         LDKCResult_TxAbortDecodeErrorZ* orig_conv = (LDKCResult_TxAbortDecodeErrorZ*)untag_ptr(orig);
24489         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
24490         *ret_conv = CResult_TxAbortDecodeErrorZ_clone(orig_conv);
24491         return tag_ptr(ret_conv, true);
24492 }
24493
24494 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_ok(int64_t o) {
24495         LDKAnnouncementSignatures o_conv;
24496         o_conv.inner = untag_ptr(o);
24497         o_conv.is_owned = ptr_is_owned(o);
24498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24499         o_conv = AnnouncementSignatures_clone(&o_conv);
24500         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24501         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
24502         return tag_ptr(ret_conv, true);
24503 }
24504
24505 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_err(int64_t e) {
24506         void* e_ptr = untag_ptr(e);
24507         CHECK_ACCESS(e_ptr);
24508         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24509         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24510         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24511         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
24512         return tag_ptr(ret_conv, true);
24513 }
24514
24515 jboolean  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(int64_t o) {
24516         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
24517         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
24518         return ret_conv;
24519 }
24520
24521 void  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_free(int64_t _res) {
24522         if (!ptr_is_owned(_res)) return;
24523         void* _res_ptr = untag_ptr(_res);
24524         CHECK_ACCESS(_res_ptr);
24525         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
24526         FREE(untag_ptr(_res));
24527         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
24528 }
24529
24530 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
24531         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24532         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
24533         return tag_ptr(ret_conv, true);
24534 }
24535 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(int64_t arg) {
24536         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
24537         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
24538         return ret_conv;
24539 }
24540
24541 int64_t  CS_LDK_CResult_AnnouncementSignaturesDecodeErrorZ_clone(int64_t orig) {
24542         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
24543         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
24544         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
24545         return tag_ptr(ret_conv, true);
24546 }
24547
24548 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_ok(int64_t o) {
24549         LDKChannelReestablish o_conv;
24550         o_conv.inner = untag_ptr(o);
24551         o_conv.is_owned = ptr_is_owned(o);
24552         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24553         o_conv = ChannelReestablish_clone(&o_conv);
24554         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24555         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
24556         return tag_ptr(ret_conv, true);
24557 }
24558
24559 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_err(int64_t e) {
24560         void* e_ptr = untag_ptr(e);
24561         CHECK_ACCESS(e_ptr);
24562         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24563         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24564         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24565         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
24566         return tag_ptr(ret_conv, true);
24567 }
24568
24569 jboolean  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_is_ok(int64_t o) {
24570         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
24571         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
24572         return ret_conv;
24573 }
24574
24575 void  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_free(int64_t _res) {
24576         if (!ptr_is_owned(_res)) return;
24577         void* _res_ptr = untag_ptr(_res);
24578         CHECK_ACCESS(_res_ptr);
24579         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
24580         FREE(untag_ptr(_res));
24581         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
24582 }
24583
24584 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
24585         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24586         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
24587         return tag_ptr(ret_conv, true);
24588 }
24589 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(int64_t arg) {
24590         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
24591         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
24592         return ret_conv;
24593 }
24594
24595 int64_t  CS_LDK_CResult_ChannelReestablishDecodeErrorZ_clone(int64_t orig) {
24596         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
24597         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24598         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
24599         return tag_ptr(ret_conv, true);
24600 }
24601
24602 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_ok(int64_t o) {
24603         LDKClosingSigned o_conv;
24604         o_conv.inner = untag_ptr(o);
24605         o_conv.is_owned = ptr_is_owned(o);
24606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24607         o_conv = ClosingSigned_clone(&o_conv);
24608         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24609         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
24610         return tag_ptr(ret_conv, true);
24611 }
24612
24613 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_err(int64_t e) {
24614         void* e_ptr = untag_ptr(e);
24615         CHECK_ACCESS(e_ptr);
24616         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24617         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24618         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24619         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
24620         return tag_ptr(ret_conv, true);
24621 }
24622
24623 jboolean  CS_LDK_CResult_ClosingSignedDecodeErrorZ_is_ok(int64_t o) {
24624         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
24625         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
24626         return ret_conv;
24627 }
24628
24629 void  CS_LDK_CResult_ClosingSignedDecodeErrorZ_free(int64_t _res) {
24630         if (!ptr_is_owned(_res)) return;
24631         void* _res_ptr = untag_ptr(_res);
24632         CHECK_ACCESS(_res_ptr);
24633         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
24634         FREE(untag_ptr(_res));
24635         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
24636 }
24637
24638 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
24639         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24640         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
24641         return tag_ptr(ret_conv, true);
24642 }
24643 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_clone_ptr(int64_t arg) {
24644         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
24645         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
24646         return ret_conv;
24647 }
24648
24649 int64_t  CS_LDK_CResult_ClosingSignedDecodeErrorZ_clone(int64_t orig) {
24650         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
24651         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24652         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
24653         return tag_ptr(ret_conv, true);
24654 }
24655
24656 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(int64_t o) {
24657         LDKClosingSignedFeeRange o_conv;
24658         o_conv.inner = untag_ptr(o);
24659         o_conv.is_owned = ptr_is_owned(o);
24660         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24661         o_conv = ClosingSignedFeeRange_clone(&o_conv);
24662         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24663         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
24664         return tag_ptr(ret_conv, true);
24665 }
24666
24667 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(int64_t e) {
24668         void* e_ptr = untag_ptr(e);
24669         CHECK_ACCESS(e_ptr);
24670         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24671         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24672         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24673         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
24674         return tag_ptr(ret_conv, true);
24675 }
24676
24677 jboolean  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(int64_t o) {
24678         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
24679         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
24680         return ret_conv;
24681 }
24682
24683 void  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(int64_t _res) {
24684         if (!ptr_is_owned(_res)) return;
24685         void* _res_ptr = untag_ptr(_res);
24686         CHECK_ACCESS(_res_ptr);
24687         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
24688         FREE(untag_ptr(_res));
24689         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
24690 }
24691
24692 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
24693         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24694         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
24695         return tag_ptr(ret_conv, true);
24696 }
24697 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(int64_t arg) {
24698         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
24699         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
24700         return ret_conv;
24701 }
24702
24703 int64_t  CS_LDK_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(int64_t orig) {
24704         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
24705         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24706         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
24707         return tag_ptr(ret_conv, true);
24708 }
24709
24710 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_ok(int64_t o) {
24711         LDKCommitmentSigned o_conv;
24712         o_conv.inner = untag_ptr(o);
24713         o_conv.is_owned = ptr_is_owned(o);
24714         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24715         o_conv = CommitmentSigned_clone(&o_conv);
24716         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24717         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
24718         return tag_ptr(ret_conv, true);
24719 }
24720
24721 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_err(int64_t e) {
24722         void* e_ptr = untag_ptr(e);
24723         CHECK_ACCESS(e_ptr);
24724         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24725         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24726         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24727         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
24728         return tag_ptr(ret_conv, true);
24729 }
24730
24731 jboolean  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_is_ok(int64_t o) {
24732         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
24733         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
24734         return ret_conv;
24735 }
24736
24737 void  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_free(int64_t _res) {
24738         if (!ptr_is_owned(_res)) return;
24739         void* _res_ptr = untag_ptr(_res);
24740         CHECK_ACCESS(_res_ptr);
24741         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
24742         FREE(untag_ptr(_res));
24743         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
24744 }
24745
24746 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
24747         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24748         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
24749         return tag_ptr(ret_conv, true);
24750 }
24751 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(int64_t arg) {
24752         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
24753         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
24754         return ret_conv;
24755 }
24756
24757 int64_t  CS_LDK_CResult_CommitmentSignedDecodeErrorZ_clone(int64_t orig) {
24758         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
24759         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24760         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
24761         return tag_ptr(ret_conv, true);
24762 }
24763
24764 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_ok(int64_t o) {
24765         LDKFundingCreated o_conv;
24766         o_conv.inner = untag_ptr(o);
24767         o_conv.is_owned = ptr_is_owned(o);
24768         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24769         o_conv = FundingCreated_clone(&o_conv);
24770         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24771         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
24772         return tag_ptr(ret_conv, true);
24773 }
24774
24775 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_err(int64_t e) {
24776         void* e_ptr = untag_ptr(e);
24777         CHECK_ACCESS(e_ptr);
24778         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24779         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24780         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24781         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
24782         return tag_ptr(ret_conv, true);
24783 }
24784
24785 jboolean  CS_LDK_CResult_FundingCreatedDecodeErrorZ_is_ok(int64_t o) {
24786         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
24787         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
24788         return ret_conv;
24789 }
24790
24791 void  CS_LDK_CResult_FundingCreatedDecodeErrorZ_free(int64_t _res) {
24792         if (!ptr_is_owned(_res)) return;
24793         void* _res_ptr = untag_ptr(_res);
24794         CHECK_ACCESS(_res_ptr);
24795         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
24796         FREE(untag_ptr(_res));
24797         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
24798 }
24799
24800 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
24801         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24802         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
24803         return tag_ptr(ret_conv, true);
24804 }
24805 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_clone_ptr(int64_t arg) {
24806         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
24807         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
24808         return ret_conv;
24809 }
24810
24811 int64_t  CS_LDK_CResult_FundingCreatedDecodeErrorZ_clone(int64_t orig) {
24812         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
24813         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24814         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
24815         return tag_ptr(ret_conv, true);
24816 }
24817
24818 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_ok(int64_t o) {
24819         LDKFundingSigned o_conv;
24820         o_conv.inner = untag_ptr(o);
24821         o_conv.is_owned = ptr_is_owned(o);
24822         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24823         o_conv = FundingSigned_clone(&o_conv);
24824         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24825         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
24826         return tag_ptr(ret_conv, true);
24827 }
24828
24829 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_err(int64_t e) {
24830         void* e_ptr = untag_ptr(e);
24831         CHECK_ACCESS(e_ptr);
24832         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24833         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24834         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24835         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
24836         return tag_ptr(ret_conv, true);
24837 }
24838
24839 jboolean  CS_LDK_CResult_FundingSignedDecodeErrorZ_is_ok(int64_t o) {
24840         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
24841         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
24842         return ret_conv;
24843 }
24844
24845 void  CS_LDK_CResult_FundingSignedDecodeErrorZ_free(int64_t _res) {
24846         if (!ptr_is_owned(_res)) return;
24847         void* _res_ptr = untag_ptr(_res);
24848         CHECK_ACCESS(_res_ptr);
24849         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
24850         FREE(untag_ptr(_res));
24851         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
24852 }
24853
24854 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
24855         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24856         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
24857         return tag_ptr(ret_conv, true);
24858 }
24859 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_clone_ptr(int64_t arg) {
24860         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
24861         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
24862         return ret_conv;
24863 }
24864
24865 int64_t  CS_LDK_CResult_FundingSignedDecodeErrorZ_clone(int64_t orig) {
24866         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
24867         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24868         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
24869         return tag_ptr(ret_conv, true);
24870 }
24871
24872 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_ok(int64_t o) {
24873         LDKChannelReady o_conv;
24874         o_conv.inner = untag_ptr(o);
24875         o_conv.is_owned = ptr_is_owned(o);
24876         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24877         o_conv = ChannelReady_clone(&o_conv);
24878         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24879         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
24880         return tag_ptr(ret_conv, true);
24881 }
24882
24883 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_err(int64_t e) {
24884         void* e_ptr = untag_ptr(e);
24885         CHECK_ACCESS(e_ptr);
24886         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24887         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24888         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24889         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
24890         return tag_ptr(ret_conv, true);
24891 }
24892
24893 jboolean  CS_LDK_CResult_ChannelReadyDecodeErrorZ_is_ok(int64_t o) {
24894         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
24895         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
24896         return ret_conv;
24897 }
24898
24899 void  CS_LDK_CResult_ChannelReadyDecodeErrorZ_free(int64_t _res) {
24900         if (!ptr_is_owned(_res)) return;
24901         void* _res_ptr = untag_ptr(_res);
24902         CHECK_ACCESS(_res_ptr);
24903         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
24904         FREE(untag_ptr(_res));
24905         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
24906 }
24907
24908 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
24909         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24910         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
24911         return tag_ptr(ret_conv, true);
24912 }
24913 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_clone_ptr(int64_t arg) {
24914         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
24915         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
24916         return ret_conv;
24917 }
24918
24919 int64_t  CS_LDK_CResult_ChannelReadyDecodeErrorZ_clone(int64_t orig) {
24920         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
24921         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24922         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
24923         return tag_ptr(ret_conv, true);
24924 }
24925
24926 int64_t  CS_LDK_CResult_InitDecodeErrorZ_ok(int64_t o) {
24927         LDKInit o_conv;
24928         o_conv.inner = untag_ptr(o);
24929         o_conv.is_owned = ptr_is_owned(o);
24930         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24931         o_conv = Init_clone(&o_conv);
24932         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24933         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
24934         return tag_ptr(ret_conv, true);
24935 }
24936
24937 int64_t  CS_LDK_CResult_InitDecodeErrorZ_err(int64_t e) {
24938         void* e_ptr = untag_ptr(e);
24939         CHECK_ACCESS(e_ptr);
24940         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24941         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24942         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24943         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
24944         return tag_ptr(ret_conv, true);
24945 }
24946
24947 jboolean  CS_LDK_CResult_InitDecodeErrorZ_is_ok(int64_t o) {
24948         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
24949         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
24950         return ret_conv;
24951 }
24952
24953 void  CS_LDK_CResult_InitDecodeErrorZ_free(int64_t _res) {
24954         if (!ptr_is_owned(_res)) return;
24955         void* _res_ptr = untag_ptr(_res);
24956         CHECK_ACCESS(_res_ptr);
24957         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
24958         FREE(untag_ptr(_res));
24959         CResult_InitDecodeErrorZ_free(_res_conv);
24960 }
24961
24962 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
24963         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24964         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
24965         return tag_ptr(ret_conv, true);
24966 }
24967 int64_t  CS_LDK_CResult_InitDecodeErrorZ_clone_ptr(int64_t arg) {
24968         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
24969         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
24970         return ret_conv;
24971 }
24972
24973 int64_t  CS_LDK_CResult_InitDecodeErrorZ_clone(int64_t orig) {
24974         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
24975         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24976         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
24977         return tag_ptr(ret_conv, true);
24978 }
24979
24980 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_ok(int64_t o) {
24981         LDKOpenChannel o_conv;
24982         o_conv.inner = untag_ptr(o);
24983         o_conv.is_owned = ptr_is_owned(o);
24984         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24985         o_conv = OpenChannel_clone(&o_conv);
24986         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24987         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
24988         return tag_ptr(ret_conv, true);
24989 }
24990
24991 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_err(int64_t e) {
24992         void* e_ptr = untag_ptr(e);
24993         CHECK_ACCESS(e_ptr);
24994         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24995         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24996         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24997         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
24998         return tag_ptr(ret_conv, true);
24999 }
25000
25001 jboolean  CS_LDK_CResult_OpenChannelDecodeErrorZ_is_ok(int64_t o) {
25002         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
25003         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
25004         return ret_conv;
25005 }
25006
25007 void  CS_LDK_CResult_OpenChannelDecodeErrorZ_free(int64_t _res) {
25008         if (!ptr_is_owned(_res)) return;
25009         void* _res_ptr = untag_ptr(_res);
25010         CHECK_ACCESS(_res_ptr);
25011         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
25012         FREE(untag_ptr(_res));
25013         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
25014 }
25015
25016 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
25017         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25018         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
25019         return tag_ptr(ret_conv, true);
25020 }
25021 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_clone_ptr(int64_t arg) {
25022         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
25023         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
25024         return ret_conv;
25025 }
25026
25027 int64_t  CS_LDK_CResult_OpenChannelDecodeErrorZ_clone(int64_t orig) {
25028         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
25029         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
25030         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
25031         return tag_ptr(ret_conv, true);
25032 }
25033
25034 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_ok(int64_t o) {
25035         LDKOpenChannelV2 o_conv;
25036         o_conv.inner = untag_ptr(o);
25037         o_conv.is_owned = ptr_is_owned(o);
25038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25039         o_conv = OpenChannelV2_clone(&o_conv);
25040         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25041         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_ok(o_conv);
25042         return tag_ptr(ret_conv, true);
25043 }
25044
25045 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_err(int64_t e) {
25046         void* e_ptr = untag_ptr(e);
25047         CHECK_ACCESS(e_ptr);
25048         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25049         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25050         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25051         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_err(e_conv);
25052         return tag_ptr(ret_conv, true);
25053 }
25054
25055 jboolean  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_is_ok(int64_t o) {
25056         LDKCResult_OpenChannelV2DecodeErrorZ* o_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(o);
25057         jboolean ret_conv = CResult_OpenChannelV2DecodeErrorZ_is_ok(o_conv);
25058         return ret_conv;
25059 }
25060
25061 void  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_free(int64_t _res) {
25062         if (!ptr_is_owned(_res)) return;
25063         void* _res_ptr = untag_ptr(_res);
25064         CHECK_ACCESS(_res_ptr);
25065         LDKCResult_OpenChannelV2DecodeErrorZ _res_conv = *(LDKCResult_OpenChannelV2DecodeErrorZ*)(_res_ptr);
25066         FREE(untag_ptr(_res));
25067         CResult_OpenChannelV2DecodeErrorZ_free(_res_conv);
25068 }
25069
25070 static inline uint64_t CResult_OpenChannelV2DecodeErrorZ_clone_ptr(LDKCResult_OpenChannelV2DecodeErrorZ *NONNULL_PTR arg) {
25071         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25072         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_clone(arg);
25073         return tag_ptr(ret_conv, true);
25074 }
25075 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_clone_ptr(int64_t arg) {
25076         LDKCResult_OpenChannelV2DecodeErrorZ* arg_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(arg);
25077         int64_t ret_conv = CResult_OpenChannelV2DecodeErrorZ_clone_ptr(arg_conv);
25078         return ret_conv;
25079 }
25080
25081 int64_t  CS_LDK_CResult_OpenChannelV2DecodeErrorZ_clone(int64_t orig) {
25082         LDKCResult_OpenChannelV2DecodeErrorZ* orig_conv = (LDKCResult_OpenChannelV2DecodeErrorZ*)untag_ptr(orig);
25083         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
25084         *ret_conv = CResult_OpenChannelV2DecodeErrorZ_clone(orig_conv);
25085         return tag_ptr(ret_conv, true);
25086 }
25087
25088 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_ok(int64_t o) {
25089         LDKRevokeAndACK o_conv;
25090         o_conv.inner = untag_ptr(o);
25091         o_conv.is_owned = ptr_is_owned(o);
25092         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25093         o_conv = RevokeAndACK_clone(&o_conv);
25094         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25095         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
25096         return tag_ptr(ret_conv, true);
25097 }
25098
25099 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_err(int64_t e) {
25100         void* e_ptr = untag_ptr(e);
25101         CHECK_ACCESS(e_ptr);
25102         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25103         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25104         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25105         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
25106         return tag_ptr(ret_conv, true);
25107 }
25108
25109 jboolean  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_is_ok(int64_t o) {
25110         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
25111         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
25112         return ret_conv;
25113 }
25114
25115 void  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_free(int64_t _res) {
25116         if (!ptr_is_owned(_res)) return;
25117         void* _res_ptr = untag_ptr(_res);
25118         CHECK_ACCESS(_res_ptr);
25119         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
25120         FREE(untag_ptr(_res));
25121         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
25122 }
25123
25124 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
25125         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25126         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
25127         return tag_ptr(ret_conv, true);
25128 }
25129 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(int64_t arg) {
25130         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
25131         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
25132         return ret_conv;
25133 }
25134
25135 int64_t  CS_LDK_CResult_RevokeAndACKDecodeErrorZ_clone(int64_t orig) {
25136         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
25137         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
25138         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
25139         return tag_ptr(ret_conv, true);
25140 }
25141
25142 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_ok(int64_t o) {
25143         LDKShutdown o_conv;
25144         o_conv.inner = untag_ptr(o);
25145         o_conv.is_owned = ptr_is_owned(o);
25146         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25147         o_conv = Shutdown_clone(&o_conv);
25148         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25149         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
25150         return tag_ptr(ret_conv, true);
25151 }
25152
25153 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_err(int64_t e) {
25154         void* e_ptr = untag_ptr(e);
25155         CHECK_ACCESS(e_ptr);
25156         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25157         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25158         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25159         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
25160         return tag_ptr(ret_conv, true);
25161 }
25162
25163 jboolean  CS_LDK_CResult_ShutdownDecodeErrorZ_is_ok(int64_t o) {
25164         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
25165         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
25166         return ret_conv;
25167 }
25168
25169 void  CS_LDK_CResult_ShutdownDecodeErrorZ_free(int64_t _res) {
25170         if (!ptr_is_owned(_res)) return;
25171         void* _res_ptr = untag_ptr(_res);
25172         CHECK_ACCESS(_res_ptr);
25173         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
25174         FREE(untag_ptr(_res));
25175         CResult_ShutdownDecodeErrorZ_free(_res_conv);
25176 }
25177
25178 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
25179         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25180         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
25181         return tag_ptr(ret_conv, true);
25182 }
25183 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_clone_ptr(int64_t arg) {
25184         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
25185         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
25186         return ret_conv;
25187 }
25188
25189 int64_t  CS_LDK_CResult_ShutdownDecodeErrorZ_clone(int64_t orig) {
25190         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
25191         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
25192         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
25193         return tag_ptr(ret_conv, true);
25194 }
25195
25196 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_ok(int64_t o) {
25197         LDKUpdateFailHTLC o_conv;
25198         o_conv.inner = untag_ptr(o);
25199         o_conv.is_owned = ptr_is_owned(o);
25200         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25201         o_conv = UpdateFailHTLC_clone(&o_conv);
25202         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25203         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
25204         return tag_ptr(ret_conv, true);
25205 }
25206
25207 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_err(int64_t e) {
25208         void* e_ptr = untag_ptr(e);
25209         CHECK_ACCESS(e_ptr);
25210         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25211         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25212         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25213         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
25214         return tag_ptr(ret_conv, true);
25215 }
25216
25217 jboolean  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(int64_t o) {
25218         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
25219         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
25220         return ret_conv;
25221 }
25222
25223 void  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_free(int64_t _res) {
25224         if (!ptr_is_owned(_res)) return;
25225         void* _res_ptr = untag_ptr(_res);
25226         CHECK_ACCESS(_res_ptr);
25227         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
25228         FREE(untag_ptr(_res));
25229         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
25230 }
25231
25232 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
25233         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25234         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
25235         return tag_ptr(ret_conv, true);
25236 }
25237 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25238         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
25239         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
25240         return ret_conv;
25241 }
25242
25243 int64_t  CS_LDK_CResult_UpdateFailHTLCDecodeErrorZ_clone(int64_t orig) {
25244         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
25245         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
25246         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
25247         return tag_ptr(ret_conv, true);
25248 }
25249
25250 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(int64_t o) {
25251         LDKUpdateFailMalformedHTLC o_conv;
25252         o_conv.inner = untag_ptr(o);
25253         o_conv.is_owned = ptr_is_owned(o);
25254         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25255         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
25256         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25257         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
25258         return tag_ptr(ret_conv, true);
25259 }
25260
25261 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(int64_t e) {
25262         void* e_ptr = untag_ptr(e);
25263         CHECK_ACCESS(e_ptr);
25264         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25265         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25266         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25267         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
25268         return tag_ptr(ret_conv, true);
25269 }
25270
25271 jboolean  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(int64_t o) {
25272         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
25273         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
25274         return ret_conv;
25275 }
25276
25277 void  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(int64_t _res) {
25278         if (!ptr_is_owned(_res)) return;
25279         void* _res_ptr = untag_ptr(_res);
25280         CHECK_ACCESS(_res_ptr);
25281         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
25282         FREE(untag_ptr(_res));
25283         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
25284 }
25285
25286 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
25287         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25288         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
25289         return tag_ptr(ret_conv, true);
25290 }
25291 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25292         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
25293         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
25294         return ret_conv;
25295 }
25296
25297 int64_t  CS_LDK_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(int64_t orig) {
25298         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
25299         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
25300         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
25301         return tag_ptr(ret_conv, true);
25302 }
25303
25304 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_ok(int64_t o) {
25305         LDKUpdateFee o_conv;
25306         o_conv.inner = untag_ptr(o);
25307         o_conv.is_owned = ptr_is_owned(o);
25308         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25309         o_conv = UpdateFee_clone(&o_conv);
25310         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25311         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
25312         return tag_ptr(ret_conv, true);
25313 }
25314
25315 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_err(int64_t e) {
25316         void* e_ptr = untag_ptr(e);
25317         CHECK_ACCESS(e_ptr);
25318         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25319         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25320         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25321         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
25322         return tag_ptr(ret_conv, true);
25323 }
25324
25325 jboolean  CS_LDK_CResult_UpdateFeeDecodeErrorZ_is_ok(int64_t o) {
25326         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
25327         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
25328         return ret_conv;
25329 }
25330
25331 void  CS_LDK_CResult_UpdateFeeDecodeErrorZ_free(int64_t _res) {
25332         if (!ptr_is_owned(_res)) return;
25333         void* _res_ptr = untag_ptr(_res);
25334         CHECK_ACCESS(_res_ptr);
25335         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
25336         FREE(untag_ptr(_res));
25337         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
25338 }
25339
25340 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
25341         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25342         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
25343         return tag_ptr(ret_conv, true);
25344 }
25345 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_clone_ptr(int64_t arg) {
25346         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
25347         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
25348         return ret_conv;
25349 }
25350
25351 int64_t  CS_LDK_CResult_UpdateFeeDecodeErrorZ_clone(int64_t orig) {
25352         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
25353         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
25354         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
25355         return tag_ptr(ret_conv, true);
25356 }
25357
25358 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(int64_t o) {
25359         LDKUpdateFulfillHTLC o_conv;
25360         o_conv.inner = untag_ptr(o);
25361         o_conv.is_owned = ptr_is_owned(o);
25362         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25363         o_conv = UpdateFulfillHTLC_clone(&o_conv);
25364         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25365         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
25366         return tag_ptr(ret_conv, true);
25367 }
25368
25369 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_err(int64_t e) {
25370         void* e_ptr = untag_ptr(e);
25371         CHECK_ACCESS(e_ptr);
25372         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25373         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25374         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25375         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
25376         return tag_ptr(ret_conv, true);
25377 }
25378
25379 jboolean  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(int64_t o) {
25380         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
25381         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
25382         return ret_conv;
25383 }
25384
25385 void  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_free(int64_t _res) {
25386         if (!ptr_is_owned(_res)) return;
25387         void* _res_ptr = untag_ptr(_res);
25388         CHECK_ACCESS(_res_ptr);
25389         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
25390         FREE(untag_ptr(_res));
25391         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
25392 }
25393
25394 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
25395         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25396         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
25397         return tag_ptr(ret_conv, true);
25398 }
25399 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25400         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
25401         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
25402         return ret_conv;
25403 }
25404
25405 int64_t  CS_LDK_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(int64_t orig) {
25406         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
25407         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
25408         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
25409         return tag_ptr(ret_conv, true);
25410 }
25411
25412 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_ok(int64_t o) {
25413         LDKUpdateAddHTLC o_conv;
25414         o_conv.inner = untag_ptr(o);
25415         o_conv.is_owned = ptr_is_owned(o);
25416         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25417         o_conv = UpdateAddHTLC_clone(&o_conv);
25418         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25419         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
25420         return tag_ptr(ret_conv, true);
25421 }
25422
25423 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_err(int64_t e) {
25424         void* e_ptr = untag_ptr(e);
25425         CHECK_ACCESS(e_ptr);
25426         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25427         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25428         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25429         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
25430         return tag_ptr(ret_conv, true);
25431 }
25432
25433 jboolean  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(int64_t o) {
25434         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
25435         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
25436         return ret_conv;
25437 }
25438
25439 void  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_free(int64_t _res) {
25440         if (!ptr_is_owned(_res)) return;
25441         void* _res_ptr = untag_ptr(_res);
25442         CHECK_ACCESS(_res_ptr);
25443         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
25444         FREE(untag_ptr(_res));
25445         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
25446 }
25447
25448 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
25449         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25450         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
25451         return tag_ptr(ret_conv, true);
25452 }
25453 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
25454         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
25455         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
25456         return ret_conv;
25457 }
25458
25459 int64_t  CS_LDK_CResult_UpdateAddHTLCDecodeErrorZ_clone(int64_t orig) {
25460         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
25461         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
25462         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
25463         return tag_ptr(ret_conv, true);
25464 }
25465
25466 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_ok(int64_t o) {
25467         LDKOnionMessage o_conv;
25468         o_conv.inner = untag_ptr(o);
25469         o_conv.is_owned = ptr_is_owned(o);
25470         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25471         o_conv = OnionMessage_clone(&o_conv);
25472         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25473         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
25474         return tag_ptr(ret_conv, true);
25475 }
25476
25477 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_err(int64_t e) {
25478         void* e_ptr = untag_ptr(e);
25479         CHECK_ACCESS(e_ptr);
25480         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25481         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25482         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25483         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
25484         return tag_ptr(ret_conv, true);
25485 }
25486
25487 jboolean  CS_LDK_CResult_OnionMessageDecodeErrorZ_is_ok(int64_t o) {
25488         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
25489         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
25490         return ret_conv;
25491 }
25492
25493 void  CS_LDK_CResult_OnionMessageDecodeErrorZ_free(int64_t _res) {
25494         if (!ptr_is_owned(_res)) return;
25495         void* _res_ptr = untag_ptr(_res);
25496         CHECK_ACCESS(_res_ptr);
25497         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
25498         FREE(untag_ptr(_res));
25499         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
25500 }
25501
25502 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
25503         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25504         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
25505         return tag_ptr(ret_conv, true);
25506 }
25507 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_clone_ptr(int64_t arg) {
25508         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
25509         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
25510         return ret_conv;
25511 }
25512
25513 int64_t  CS_LDK_CResult_OnionMessageDecodeErrorZ_clone(int64_t orig) {
25514         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
25515         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
25516         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
25517         return tag_ptr(ret_conv, true);
25518 }
25519
25520 int64_t  CS_LDK_CResult_PingDecodeErrorZ_ok(int64_t o) {
25521         LDKPing o_conv;
25522         o_conv.inner = untag_ptr(o);
25523         o_conv.is_owned = ptr_is_owned(o);
25524         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25525         o_conv = Ping_clone(&o_conv);
25526         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25527         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
25528         return tag_ptr(ret_conv, true);
25529 }
25530
25531 int64_t  CS_LDK_CResult_PingDecodeErrorZ_err(int64_t e) {
25532         void* e_ptr = untag_ptr(e);
25533         CHECK_ACCESS(e_ptr);
25534         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25535         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25536         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25537         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
25538         return tag_ptr(ret_conv, true);
25539 }
25540
25541 jboolean  CS_LDK_CResult_PingDecodeErrorZ_is_ok(int64_t o) {
25542         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
25543         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
25544         return ret_conv;
25545 }
25546
25547 void  CS_LDK_CResult_PingDecodeErrorZ_free(int64_t _res) {
25548         if (!ptr_is_owned(_res)) return;
25549         void* _res_ptr = untag_ptr(_res);
25550         CHECK_ACCESS(_res_ptr);
25551         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
25552         FREE(untag_ptr(_res));
25553         CResult_PingDecodeErrorZ_free(_res_conv);
25554 }
25555
25556 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
25557         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25558         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
25559         return tag_ptr(ret_conv, true);
25560 }
25561 int64_t  CS_LDK_CResult_PingDecodeErrorZ_clone_ptr(int64_t arg) {
25562         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
25563         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
25564         return ret_conv;
25565 }
25566
25567 int64_t  CS_LDK_CResult_PingDecodeErrorZ_clone(int64_t orig) {
25568         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
25569         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
25570         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
25571         return tag_ptr(ret_conv, true);
25572 }
25573
25574 int64_t  CS_LDK_CResult_PongDecodeErrorZ_ok(int64_t o) {
25575         LDKPong o_conv;
25576         o_conv.inner = untag_ptr(o);
25577         o_conv.is_owned = ptr_is_owned(o);
25578         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25579         o_conv = Pong_clone(&o_conv);
25580         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25581         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
25582         return tag_ptr(ret_conv, true);
25583 }
25584
25585 int64_t  CS_LDK_CResult_PongDecodeErrorZ_err(int64_t e) {
25586         void* e_ptr = untag_ptr(e);
25587         CHECK_ACCESS(e_ptr);
25588         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25589         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25590         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25591         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
25592         return tag_ptr(ret_conv, true);
25593 }
25594
25595 jboolean  CS_LDK_CResult_PongDecodeErrorZ_is_ok(int64_t o) {
25596         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
25597         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
25598         return ret_conv;
25599 }
25600
25601 void  CS_LDK_CResult_PongDecodeErrorZ_free(int64_t _res) {
25602         if (!ptr_is_owned(_res)) return;
25603         void* _res_ptr = untag_ptr(_res);
25604         CHECK_ACCESS(_res_ptr);
25605         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
25606         FREE(untag_ptr(_res));
25607         CResult_PongDecodeErrorZ_free(_res_conv);
25608 }
25609
25610 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
25611         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25612         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
25613         return tag_ptr(ret_conv, true);
25614 }
25615 int64_t  CS_LDK_CResult_PongDecodeErrorZ_clone_ptr(int64_t arg) {
25616         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
25617         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
25618         return ret_conv;
25619 }
25620
25621 int64_t  CS_LDK_CResult_PongDecodeErrorZ_clone(int64_t orig) {
25622         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
25623         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
25624         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
25625         return tag_ptr(ret_conv, true);
25626 }
25627
25628 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(int64_t o) {
25629         LDKUnsignedChannelAnnouncement o_conv;
25630         o_conv.inner = untag_ptr(o);
25631         o_conv.is_owned = ptr_is_owned(o);
25632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25633         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
25634         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25635         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
25636         return tag_ptr(ret_conv, true);
25637 }
25638
25639 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(int64_t e) {
25640         void* e_ptr = untag_ptr(e);
25641         CHECK_ACCESS(e_ptr);
25642         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25643         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25644         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25645         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
25646         return tag_ptr(ret_conv, true);
25647 }
25648
25649 jboolean  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(int64_t o) {
25650         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25651         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25652         return ret_conv;
25653 }
25654
25655 void  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(int64_t _res) {
25656         if (!ptr_is_owned(_res)) return;
25657         void* _res_ptr = untag_ptr(_res);
25658         CHECK_ACCESS(_res_ptr);
25659         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25660         FREE(untag_ptr(_res));
25661         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
25662 }
25663
25664 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25665         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25666         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
25667         return tag_ptr(ret_conv, true);
25668 }
25669 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
25670         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25671         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25672         return ret_conv;
25673 }
25674
25675 int64_t  CS_LDK_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(int64_t orig) {
25676         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25677         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25678         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25679         return tag_ptr(ret_conv, true);
25680 }
25681
25682 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_ok(int64_t o) {
25683         LDKChannelAnnouncement o_conv;
25684         o_conv.inner = untag_ptr(o);
25685         o_conv.is_owned = ptr_is_owned(o);
25686         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25687         o_conv = ChannelAnnouncement_clone(&o_conv);
25688         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25689         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
25690         return tag_ptr(ret_conv, true);
25691 }
25692
25693 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_err(int64_t e) {
25694         void* e_ptr = untag_ptr(e);
25695         CHECK_ACCESS(e_ptr);
25696         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25697         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25698         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25699         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
25700         return tag_ptr(ret_conv, true);
25701 }
25702
25703 jboolean  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(int64_t o) {
25704         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25705         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25706         return ret_conv;
25707 }
25708
25709 void  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_free(int64_t _res) {
25710         if (!ptr_is_owned(_res)) return;
25711         void* _res_ptr = untag_ptr(_res);
25712         CHECK_ACCESS(_res_ptr);
25713         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25714         FREE(untag_ptr(_res));
25715         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
25716 }
25717
25718 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25719         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25720         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
25721         return tag_ptr(ret_conv, true);
25722 }
25723 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
25724         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25725         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25726         return ret_conv;
25727 }
25728
25729 int64_t  CS_LDK_CResult_ChannelAnnouncementDecodeErrorZ_clone(int64_t orig) {
25730         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25731         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25732         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25733         return tag_ptr(ret_conv, true);
25734 }
25735
25736 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(int64_t o) {
25737         LDKUnsignedChannelUpdate o_conv;
25738         o_conv.inner = untag_ptr(o);
25739         o_conv.is_owned = ptr_is_owned(o);
25740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25741         o_conv = UnsignedChannelUpdate_clone(&o_conv);
25742         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25743         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
25744         return tag_ptr(ret_conv, true);
25745 }
25746
25747 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_err(int64_t e) {
25748         void* e_ptr = untag_ptr(e);
25749         CHECK_ACCESS(e_ptr);
25750         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25751         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25752         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25753         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
25754         return tag_ptr(ret_conv, true);
25755 }
25756
25757 jboolean  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(int64_t o) {
25758         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
25759         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
25760         return ret_conv;
25761 }
25762
25763 void  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_free(int64_t _res) {
25764         if (!ptr_is_owned(_res)) return;
25765         void* _res_ptr = untag_ptr(_res);
25766         CHECK_ACCESS(_res_ptr);
25767         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
25768         FREE(untag_ptr(_res));
25769         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
25770 }
25771
25772 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25773         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25774         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
25775         return tag_ptr(ret_conv, true);
25776 }
25777 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
25778         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25779         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25780         return ret_conv;
25781 }
25782
25783 int64_t  CS_LDK_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(int64_t orig) {
25784         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25785         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25786         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
25787         return tag_ptr(ret_conv, true);
25788 }
25789
25790 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_ok(int64_t o) {
25791         LDKChannelUpdate o_conv;
25792         o_conv.inner = untag_ptr(o);
25793         o_conv.is_owned = ptr_is_owned(o);
25794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25795         o_conv = ChannelUpdate_clone(&o_conv);
25796         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25797         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
25798         return tag_ptr(ret_conv, true);
25799 }
25800
25801 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_err(int64_t e) {
25802         void* e_ptr = untag_ptr(e);
25803         CHECK_ACCESS(e_ptr);
25804         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25805         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25806         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25807         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
25808         return tag_ptr(ret_conv, true);
25809 }
25810
25811 jboolean  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_is_ok(int64_t o) {
25812         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
25813         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
25814         return ret_conv;
25815 }
25816
25817 void  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_free(int64_t _res) {
25818         if (!ptr_is_owned(_res)) return;
25819         void* _res_ptr = untag_ptr(_res);
25820         CHECK_ACCESS(_res_ptr);
25821         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
25822         FREE(untag_ptr(_res));
25823         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
25824 }
25825
25826 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25827         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25828         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
25829         return tag_ptr(ret_conv, true);
25830 }
25831 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(int64_t arg) {
25832         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25833         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25834         return ret_conv;
25835 }
25836
25837 int64_t  CS_LDK_CResult_ChannelUpdateDecodeErrorZ_clone(int64_t orig) {
25838         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25839         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25840         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
25841         return tag_ptr(ret_conv, true);
25842 }
25843
25844 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_ok(int64_t o) {
25845         LDKErrorMessage o_conv;
25846         o_conv.inner = untag_ptr(o);
25847         o_conv.is_owned = ptr_is_owned(o);
25848         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25849         o_conv = ErrorMessage_clone(&o_conv);
25850         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25851         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
25852         return tag_ptr(ret_conv, true);
25853 }
25854
25855 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_err(int64_t e) {
25856         void* e_ptr = untag_ptr(e);
25857         CHECK_ACCESS(e_ptr);
25858         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25859         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25860         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25861         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
25862         return tag_ptr(ret_conv, true);
25863 }
25864
25865 jboolean  CS_LDK_CResult_ErrorMessageDecodeErrorZ_is_ok(int64_t o) {
25866         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
25867         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
25868         return ret_conv;
25869 }
25870
25871 void  CS_LDK_CResult_ErrorMessageDecodeErrorZ_free(int64_t _res) {
25872         if (!ptr_is_owned(_res)) return;
25873         void* _res_ptr = untag_ptr(_res);
25874         CHECK_ACCESS(_res_ptr);
25875         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
25876         FREE(untag_ptr(_res));
25877         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
25878 }
25879
25880 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
25881         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25882         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
25883         return tag_ptr(ret_conv, true);
25884 }
25885 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_clone_ptr(int64_t arg) {
25886         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
25887         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
25888         return ret_conv;
25889 }
25890
25891 int64_t  CS_LDK_CResult_ErrorMessageDecodeErrorZ_clone(int64_t orig) {
25892         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
25893         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25894         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
25895         return tag_ptr(ret_conv, true);
25896 }
25897
25898 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_ok(int64_t o) {
25899         LDKWarningMessage o_conv;
25900         o_conv.inner = untag_ptr(o);
25901         o_conv.is_owned = ptr_is_owned(o);
25902         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25903         o_conv = WarningMessage_clone(&o_conv);
25904         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25905         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
25906         return tag_ptr(ret_conv, true);
25907 }
25908
25909 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_err(int64_t e) {
25910         void* e_ptr = untag_ptr(e);
25911         CHECK_ACCESS(e_ptr);
25912         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25913         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25914         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25915         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
25916         return tag_ptr(ret_conv, true);
25917 }
25918
25919 jboolean  CS_LDK_CResult_WarningMessageDecodeErrorZ_is_ok(int64_t o) {
25920         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
25921         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
25922         return ret_conv;
25923 }
25924
25925 void  CS_LDK_CResult_WarningMessageDecodeErrorZ_free(int64_t _res) {
25926         if (!ptr_is_owned(_res)) return;
25927         void* _res_ptr = untag_ptr(_res);
25928         CHECK_ACCESS(_res_ptr);
25929         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
25930         FREE(untag_ptr(_res));
25931         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
25932 }
25933
25934 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
25935         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25936         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
25937         return tag_ptr(ret_conv, true);
25938 }
25939 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_clone_ptr(int64_t arg) {
25940         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
25941         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
25942         return ret_conv;
25943 }
25944
25945 int64_t  CS_LDK_CResult_WarningMessageDecodeErrorZ_clone(int64_t orig) {
25946         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
25947         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25948         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
25949         return tag_ptr(ret_conv, true);
25950 }
25951
25952 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(int64_t o) {
25953         LDKUnsignedNodeAnnouncement o_conv;
25954         o_conv.inner = untag_ptr(o);
25955         o_conv.is_owned = ptr_is_owned(o);
25956         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25957         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
25958         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25959         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
25960         return tag_ptr(ret_conv, true);
25961 }
25962
25963 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(int64_t e) {
25964         void* e_ptr = untag_ptr(e);
25965         CHECK_ACCESS(e_ptr);
25966         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25967         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25968         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25969         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
25970         return tag_ptr(ret_conv, true);
25971 }
25972
25973 jboolean  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(int64_t o) {
25974         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25975         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25976         return ret_conv;
25977 }
25978
25979 void  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(int64_t _res) {
25980         if (!ptr_is_owned(_res)) return;
25981         void* _res_ptr = untag_ptr(_res);
25982         CHECK_ACCESS(_res_ptr);
25983         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
25984         FREE(untag_ptr(_res));
25985         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
25986 }
25987
25988 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25989         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25990         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
25991         return tag_ptr(ret_conv, true);
25992 }
25993 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
25994         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25995         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25996         return ret_conv;
25997 }
25998
25999 int64_t  CS_LDK_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(int64_t orig) {
26000         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26001         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
26002         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
26003         return tag_ptr(ret_conv, true);
26004 }
26005
26006 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_ok(int64_t o) {
26007         LDKNodeAnnouncement o_conv;
26008         o_conv.inner = untag_ptr(o);
26009         o_conv.is_owned = ptr_is_owned(o);
26010         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26011         o_conv = NodeAnnouncement_clone(&o_conv);
26012         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26013         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
26014         return tag_ptr(ret_conv, true);
26015 }
26016
26017 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_err(int64_t e) {
26018         void* e_ptr = untag_ptr(e);
26019         CHECK_ACCESS(e_ptr);
26020         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26021         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26022         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26023         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
26024         return tag_ptr(ret_conv, true);
26025 }
26026
26027 jboolean  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_is_ok(int64_t o) {
26028         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
26029         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
26030         return ret_conv;
26031 }
26032
26033 void  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_free(int64_t _res) {
26034         if (!ptr_is_owned(_res)) return;
26035         void* _res_ptr = untag_ptr(_res);
26036         CHECK_ACCESS(_res_ptr);
26037         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
26038         FREE(untag_ptr(_res));
26039         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
26040 }
26041
26042 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
26043         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26044         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
26045         return tag_ptr(ret_conv, true);
26046 }
26047 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(int64_t arg) {
26048         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
26049         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
26050         return ret_conv;
26051 }
26052
26053 int64_t  CS_LDK_CResult_NodeAnnouncementDecodeErrorZ_clone(int64_t orig) {
26054         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
26055         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
26056         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
26057         return tag_ptr(ret_conv, true);
26058 }
26059
26060 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_ok(int64_t o) {
26061         LDKQueryShortChannelIds o_conv;
26062         o_conv.inner = untag_ptr(o);
26063         o_conv.is_owned = ptr_is_owned(o);
26064         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26065         o_conv = QueryShortChannelIds_clone(&o_conv);
26066         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26067         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
26068         return tag_ptr(ret_conv, true);
26069 }
26070
26071 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_err(int64_t e) {
26072         void* e_ptr = untag_ptr(e);
26073         CHECK_ACCESS(e_ptr);
26074         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26075         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26076         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26077         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
26078         return tag_ptr(ret_conv, true);
26079 }
26080
26081 jboolean  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(int64_t o) {
26082         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
26083         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
26084         return ret_conv;
26085 }
26086
26087 void  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_free(int64_t _res) {
26088         if (!ptr_is_owned(_res)) return;
26089         void* _res_ptr = untag_ptr(_res);
26090         CHECK_ACCESS(_res_ptr);
26091         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
26092         FREE(untag_ptr(_res));
26093         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
26094 }
26095
26096 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
26097         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26098         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
26099         return tag_ptr(ret_conv, true);
26100 }
26101 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(int64_t arg) {
26102         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
26103         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
26104         return ret_conv;
26105 }
26106
26107 int64_t  CS_LDK_CResult_QueryShortChannelIdsDecodeErrorZ_clone(int64_t orig) {
26108         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
26109         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
26110         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
26111         return tag_ptr(ret_conv, true);
26112 }
26113
26114 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(int64_t o) {
26115         LDKReplyShortChannelIdsEnd o_conv;
26116         o_conv.inner = untag_ptr(o);
26117         o_conv.is_owned = ptr_is_owned(o);
26118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26119         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
26120         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26121         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
26122         return tag_ptr(ret_conv, true);
26123 }
26124
26125 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(int64_t e) {
26126         void* e_ptr = untag_ptr(e);
26127         CHECK_ACCESS(e_ptr);
26128         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26129         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26130         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26131         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
26132         return tag_ptr(ret_conv, true);
26133 }
26134
26135 jboolean  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(int64_t o) {
26136         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
26137         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
26138         return ret_conv;
26139 }
26140
26141 void  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(int64_t _res) {
26142         if (!ptr_is_owned(_res)) return;
26143         void* _res_ptr = untag_ptr(_res);
26144         CHECK_ACCESS(_res_ptr);
26145         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
26146         FREE(untag_ptr(_res));
26147         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
26148 }
26149
26150 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
26151         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26152         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
26153         return tag_ptr(ret_conv, true);
26154 }
26155 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(int64_t arg) {
26156         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
26157         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
26158         return ret_conv;
26159 }
26160
26161 int64_t  CS_LDK_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(int64_t orig) {
26162         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
26163         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
26164         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
26165         return tag_ptr(ret_conv, true);
26166 }
26167
26168 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_ok(int64_t o) {
26169         LDKQueryChannelRange o_conv;
26170         o_conv.inner = untag_ptr(o);
26171         o_conv.is_owned = ptr_is_owned(o);
26172         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26173         o_conv = QueryChannelRange_clone(&o_conv);
26174         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26175         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
26176         return tag_ptr(ret_conv, true);
26177 }
26178
26179 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_err(int64_t e) {
26180         void* e_ptr = untag_ptr(e);
26181         CHECK_ACCESS(e_ptr);
26182         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26183         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26184         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26185         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
26186         return tag_ptr(ret_conv, true);
26187 }
26188
26189 jboolean  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_is_ok(int64_t o) {
26190         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
26191         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
26192         return ret_conv;
26193 }
26194
26195 void  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_free(int64_t _res) {
26196         if (!ptr_is_owned(_res)) return;
26197         void* _res_ptr = untag_ptr(_res);
26198         CHECK_ACCESS(_res_ptr);
26199         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
26200         FREE(untag_ptr(_res));
26201         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
26202 }
26203
26204 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26205         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26206         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
26207         return tag_ptr(ret_conv, true);
26208 }
26209 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(int64_t arg) {
26210         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
26211         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26212         return ret_conv;
26213 }
26214
26215 int64_t  CS_LDK_CResult_QueryChannelRangeDecodeErrorZ_clone(int64_t orig) {
26216         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
26217         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
26218         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
26219         return tag_ptr(ret_conv, true);
26220 }
26221
26222 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_ok(int64_t o) {
26223         LDKReplyChannelRange o_conv;
26224         o_conv.inner = untag_ptr(o);
26225         o_conv.is_owned = ptr_is_owned(o);
26226         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26227         o_conv = ReplyChannelRange_clone(&o_conv);
26228         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26229         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
26230         return tag_ptr(ret_conv, true);
26231 }
26232
26233 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_err(int64_t e) {
26234         void* e_ptr = untag_ptr(e);
26235         CHECK_ACCESS(e_ptr);
26236         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26237         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26238         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26239         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
26240         return tag_ptr(ret_conv, true);
26241 }
26242
26243 jboolean  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(int64_t o) {
26244         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
26245         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
26246         return ret_conv;
26247 }
26248
26249 void  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_free(int64_t _res) {
26250         if (!ptr_is_owned(_res)) return;
26251         void* _res_ptr = untag_ptr(_res);
26252         CHECK_ACCESS(_res_ptr);
26253         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
26254         FREE(untag_ptr(_res));
26255         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
26256 }
26257
26258 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
26259         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26260         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
26261         return tag_ptr(ret_conv, true);
26262 }
26263 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(int64_t arg) {
26264         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
26265         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
26266         return ret_conv;
26267 }
26268
26269 int64_t  CS_LDK_CResult_ReplyChannelRangeDecodeErrorZ_clone(int64_t orig) {
26270         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
26271         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
26272         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
26273         return tag_ptr(ret_conv, true);
26274 }
26275
26276 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_ok(int64_t o) {
26277         LDKGossipTimestampFilter o_conv;
26278         o_conv.inner = untag_ptr(o);
26279         o_conv.is_owned = ptr_is_owned(o);
26280         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26281         o_conv = GossipTimestampFilter_clone(&o_conv);
26282         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26283         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
26284         return tag_ptr(ret_conv, true);
26285 }
26286
26287 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_err(int64_t e) {
26288         void* e_ptr = untag_ptr(e);
26289         CHECK_ACCESS(e_ptr);
26290         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26291         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26292         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26293         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
26294         return tag_ptr(ret_conv, true);
26295 }
26296
26297 jboolean  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(int64_t o) {
26298         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
26299         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
26300         return ret_conv;
26301 }
26302
26303 void  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_free(int64_t _res) {
26304         if (!ptr_is_owned(_res)) return;
26305         void* _res_ptr = untag_ptr(_res);
26306         CHECK_ACCESS(_res_ptr);
26307         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
26308         FREE(untag_ptr(_res));
26309         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
26310 }
26311
26312 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
26313         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26314         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
26315         return tag_ptr(ret_conv, true);
26316 }
26317 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(int64_t arg) {
26318         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
26319         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
26320         return ret_conv;
26321 }
26322
26323 int64_t  CS_LDK_CResult_GossipTimestampFilterDecodeErrorZ_clone(int64_t orig) {
26324         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
26325         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
26326         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
26327         return tag_ptr(ret_conv, true);
26328 }
26329
26330 void  CS_LDK_CVec_PhantomRouteHintsZ_free(int64_tArray _res) {
26331         LDKCVec_PhantomRouteHintsZ _res_constr;
26332         _res_constr.datalen = _res->arr_len;
26333         if (_res_constr.datalen > 0)
26334                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
26335         else
26336                 _res_constr.data = NULL;
26337         int64_t* _res_vals = _res->elems;
26338         for (size_t t = 0; t < _res_constr.datalen; t++) {
26339                 int64_t _res_conv_19 = _res_vals[t];
26340                 LDKPhantomRouteHints _res_conv_19_conv;
26341                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
26342                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
26343                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
26344                 _res_constr.data[t] = _res_conv_19_conv;
26345         }
26346         FREE(_res);
26347         CVec_PhantomRouteHintsZ_free(_res_constr);
26348 }
26349
26350 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(int64_t o) {
26351         LDKBolt11Invoice o_conv;
26352         o_conv.inner = untag_ptr(o);
26353         o_conv.is_owned = ptr_is_owned(o);
26354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26355         o_conv = Bolt11Invoice_clone(&o_conv);
26356         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26357         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_ok(o_conv);
26358         return tag_ptr(ret_conv, true);
26359 }
26360
26361 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_err(int64_t e) {
26362         void* e_ptr = untag_ptr(e);
26363         CHECK_ACCESS(e_ptr);
26364         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
26365         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
26366         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26367         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_err(e_conv);
26368         return tag_ptr(ret_conv, true);
26369 }
26370
26371 jboolean  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(int64_t o) {
26372         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(o);
26373         jboolean ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_is_ok(o_conv);
26374         return ret_conv;
26375 }
26376
26377 void  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_free(int64_t _res) {
26378         if (!ptr_is_owned(_res)) return;
26379         void* _res_ptr = untag_ptr(_res);
26380         CHECK_ACCESS(_res_ptr);
26381         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)(_res_ptr);
26382         FREE(untag_ptr(_res));
26383         CResult_Bolt11InvoiceSignOrCreationErrorZ_free(_res_conv);
26384 }
26385
26386 static inline uint64_t CResult_Bolt11InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
26387         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26388         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(arg);
26389         return tag_ptr(ret_conv, true);
26390 }
26391 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_clone_ptr(int64_t arg) {
26392         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
26393         int64_t ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
26394         return ret_conv;
26395 }
26396
26397 int64_t  CS_LDK_CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(int64_t orig) {
26398         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
26399         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
26400         *ret_conv = CResult_Bolt11InvoiceSignOrCreationErrorZ_clone(orig_conv);
26401         return tag_ptr(ret_conv, true);
26402 }
26403
26404 void  CS_LDK_CVec_FutureZ_free(int64_tArray _res) {
26405         LDKCVec_FutureZ _res_constr;
26406         _res_constr.datalen = _res->arr_len;
26407         if (_res_constr.datalen > 0)
26408                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
26409         else
26410                 _res_constr.data = NULL;
26411         int64_t* _res_vals = _res->elems;
26412         for (size_t i = 0; i < _res_constr.datalen; i++) {
26413                 int64_t _res_conv_8 = _res_vals[i];
26414                 LDKFuture _res_conv_8_conv;
26415                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
26416                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
26417                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
26418                 _res_constr.data[i] = _res_conv_8_conv;
26419         }
26420         FREE(_res);
26421         CVec_FutureZ_free(_res_constr);
26422 }
26423
26424 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_ok(int64_t o) {
26425         void* o_ptr = untag_ptr(o);
26426         CHECK_ACCESS(o_ptr);
26427         LDKOffersMessage o_conv = *(LDKOffersMessage*)(o_ptr);
26428         o_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(o));
26429         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26430         *ret_conv = CResult_OffersMessageDecodeErrorZ_ok(o_conv);
26431         return tag_ptr(ret_conv, true);
26432 }
26433
26434 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_err(int64_t e) {
26435         void* e_ptr = untag_ptr(e);
26436         CHECK_ACCESS(e_ptr);
26437         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26438         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26439         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26440         *ret_conv = CResult_OffersMessageDecodeErrorZ_err(e_conv);
26441         return tag_ptr(ret_conv, true);
26442 }
26443
26444 jboolean  CS_LDK_CResult_OffersMessageDecodeErrorZ_is_ok(int64_t o) {
26445         LDKCResult_OffersMessageDecodeErrorZ* o_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(o);
26446         jboolean ret_conv = CResult_OffersMessageDecodeErrorZ_is_ok(o_conv);
26447         return ret_conv;
26448 }
26449
26450 void  CS_LDK_CResult_OffersMessageDecodeErrorZ_free(int64_t _res) {
26451         if (!ptr_is_owned(_res)) return;
26452         void* _res_ptr = untag_ptr(_res);
26453         CHECK_ACCESS(_res_ptr);
26454         LDKCResult_OffersMessageDecodeErrorZ _res_conv = *(LDKCResult_OffersMessageDecodeErrorZ*)(_res_ptr);
26455         FREE(untag_ptr(_res));
26456         CResult_OffersMessageDecodeErrorZ_free(_res_conv);
26457 }
26458
26459 static inline uint64_t CResult_OffersMessageDecodeErrorZ_clone_ptr(LDKCResult_OffersMessageDecodeErrorZ *NONNULL_PTR arg) {
26460         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26461         *ret_conv = CResult_OffersMessageDecodeErrorZ_clone(arg);
26462         return tag_ptr(ret_conv, true);
26463 }
26464 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_clone_ptr(int64_t arg) {
26465         LDKCResult_OffersMessageDecodeErrorZ* arg_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(arg);
26466         int64_t ret_conv = CResult_OffersMessageDecodeErrorZ_clone_ptr(arg_conv);
26467         return ret_conv;
26468 }
26469
26470 int64_t  CS_LDK_CResult_OffersMessageDecodeErrorZ_clone(int64_t orig) {
26471         LDKCResult_OffersMessageDecodeErrorZ* orig_conv = (LDKCResult_OffersMessageDecodeErrorZ*)untag_ptr(orig);
26472         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
26473         *ret_conv = CResult_OffersMessageDecodeErrorZ_clone(orig_conv);
26474         return tag_ptr(ret_conv, true);
26475 }
26476
26477 int64_t  CS_LDK_COption_HTLCClaimZ_some(int32_t o) {
26478         LDKHTLCClaim o_conv = LDKHTLCClaim_from_cs(o);
26479         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
26480         *ret_copy = COption_HTLCClaimZ_some(o_conv);
26481         int64_t ret_ref = tag_ptr(ret_copy, true);
26482         return ret_ref;
26483 }
26484
26485 int64_t  CS_LDK_COption_HTLCClaimZ_none() {
26486         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
26487         *ret_copy = COption_HTLCClaimZ_none();
26488         int64_t ret_ref = tag_ptr(ret_copy, true);
26489         return ret_ref;
26490 }
26491
26492 void  CS_LDK_COption_HTLCClaimZ_free(int64_t _res) {
26493         if (!ptr_is_owned(_res)) return;
26494         void* _res_ptr = untag_ptr(_res);
26495         CHECK_ACCESS(_res_ptr);
26496         LDKCOption_HTLCClaimZ _res_conv = *(LDKCOption_HTLCClaimZ*)(_res_ptr);
26497         FREE(untag_ptr(_res));
26498         COption_HTLCClaimZ_free(_res_conv);
26499 }
26500
26501 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(int64_t o) {
26502         LDKCounterpartyCommitmentSecrets o_conv;
26503         o_conv.inner = untag_ptr(o);
26504         o_conv.is_owned = ptr_is_owned(o);
26505         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26506         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
26507         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26508         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
26509         return tag_ptr(ret_conv, true);
26510 }
26511
26512 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(int64_t e) {
26513         void* e_ptr = untag_ptr(e);
26514         CHECK_ACCESS(e_ptr);
26515         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26516         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26517         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26518         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
26519         return tag_ptr(ret_conv, true);
26520 }
26521
26522 jboolean  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(int64_t o) {
26523         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
26524         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
26525         return ret_conv;
26526 }
26527
26528 void  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(int64_t _res) {
26529         if (!ptr_is_owned(_res)) return;
26530         void* _res_ptr = untag_ptr(_res);
26531         CHECK_ACCESS(_res_ptr);
26532         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
26533         FREE(untag_ptr(_res));
26534         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
26535 }
26536
26537 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
26538         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26539         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
26540         return tag_ptr(ret_conv, true);
26541 }
26542 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(int64_t arg) {
26543         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
26544         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
26545         return ret_conv;
26546 }
26547
26548 int64_t  CS_LDK_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(int64_t orig) {
26549         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
26550         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
26551         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
26552         return tag_ptr(ret_conv, true);
26553 }
26554
26555 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_ok(int64_t o) {
26556         LDKTxCreationKeys o_conv;
26557         o_conv.inner = untag_ptr(o);
26558         o_conv.is_owned = ptr_is_owned(o);
26559         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26560         o_conv = TxCreationKeys_clone(&o_conv);
26561         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26562         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
26563         return tag_ptr(ret_conv, true);
26564 }
26565
26566 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_err(int64_t e) {
26567         void* e_ptr = untag_ptr(e);
26568         CHECK_ACCESS(e_ptr);
26569         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26570         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26571         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26572         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
26573         return tag_ptr(ret_conv, true);
26574 }
26575
26576 jboolean  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_is_ok(int64_t o) {
26577         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
26578         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
26579         return ret_conv;
26580 }
26581
26582 void  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_free(int64_t _res) {
26583         if (!ptr_is_owned(_res)) return;
26584         void* _res_ptr = untag_ptr(_res);
26585         CHECK_ACCESS(_res_ptr);
26586         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
26587         FREE(untag_ptr(_res));
26588         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
26589 }
26590
26591 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
26592         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26593         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
26594         return tag_ptr(ret_conv, true);
26595 }
26596 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(int64_t arg) {
26597         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
26598         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
26599         return ret_conv;
26600 }
26601
26602 int64_t  CS_LDK_CResult_TxCreationKeysDecodeErrorZ_clone(int64_t orig) {
26603         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
26604         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
26605         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
26606         return tag_ptr(ret_conv, true);
26607 }
26608
26609 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_ok(int64_t o) {
26610         LDKChannelPublicKeys o_conv;
26611         o_conv.inner = untag_ptr(o);
26612         o_conv.is_owned = ptr_is_owned(o);
26613         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26614         o_conv = ChannelPublicKeys_clone(&o_conv);
26615         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26616         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
26617         return tag_ptr(ret_conv, true);
26618 }
26619
26620 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_err(int64_t e) {
26621         void* e_ptr = untag_ptr(e);
26622         CHECK_ACCESS(e_ptr);
26623         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26624         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26625         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26626         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
26627         return tag_ptr(ret_conv, true);
26628 }
26629
26630 jboolean  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(int64_t o) {
26631         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
26632         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
26633         return ret_conv;
26634 }
26635
26636 void  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_free(int64_t _res) {
26637         if (!ptr_is_owned(_res)) return;
26638         void* _res_ptr = untag_ptr(_res);
26639         CHECK_ACCESS(_res_ptr);
26640         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
26641         FREE(untag_ptr(_res));
26642         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
26643 }
26644
26645 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
26646         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26647         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
26648         return tag_ptr(ret_conv, true);
26649 }
26650 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(int64_t arg) {
26651         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
26652         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
26653         return ret_conv;
26654 }
26655
26656 int64_t  CS_LDK_CResult_ChannelPublicKeysDecodeErrorZ_clone(int64_t orig) {
26657         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
26658         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
26659         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
26660         return tag_ptr(ret_conv, true);
26661 }
26662
26663 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(int64_t o) {
26664         LDKHTLCOutputInCommitment o_conv;
26665         o_conv.inner = untag_ptr(o);
26666         o_conv.is_owned = ptr_is_owned(o);
26667         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26668         o_conv = HTLCOutputInCommitment_clone(&o_conv);
26669         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26670         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
26671         return tag_ptr(ret_conv, true);
26672 }
26673
26674 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(int64_t e) {
26675         void* e_ptr = untag_ptr(e);
26676         CHECK_ACCESS(e_ptr);
26677         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26678         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26679         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26680         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
26681         return tag_ptr(ret_conv, true);
26682 }
26683
26684 jboolean  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(int64_t o) {
26685         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
26686         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
26687         return ret_conv;
26688 }
26689
26690 void  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(int64_t _res) {
26691         if (!ptr_is_owned(_res)) return;
26692         void* _res_ptr = untag_ptr(_res);
26693         CHECK_ACCESS(_res_ptr);
26694         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
26695         FREE(untag_ptr(_res));
26696         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
26697 }
26698
26699 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
26700         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26701         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
26702         return tag_ptr(ret_conv, true);
26703 }
26704 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(int64_t arg) {
26705         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
26706         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
26707         return ret_conv;
26708 }
26709
26710 int64_t  CS_LDK_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(int64_t orig) {
26711         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
26712         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
26713         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
26714         return tag_ptr(ret_conv, true);
26715 }
26716
26717 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(int64_t o) {
26718         LDKCounterpartyChannelTransactionParameters o_conv;
26719         o_conv.inner = untag_ptr(o);
26720         o_conv.is_owned = ptr_is_owned(o);
26721         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26722         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
26723         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26724         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
26725         return tag_ptr(ret_conv, true);
26726 }
26727
26728 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(int64_t e) {
26729         void* e_ptr = untag_ptr(e);
26730         CHECK_ACCESS(e_ptr);
26731         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26732         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26733         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26734         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
26735         return tag_ptr(ret_conv, true);
26736 }
26737
26738 jboolean  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(int64_t o) {
26739         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
26740         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
26741         return ret_conv;
26742 }
26743
26744 void  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(int64_t _res) {
26745         if (!ptr_is_owned(_res)) return;
26746         void* _res_ptr = untag_ptr(_res);
26747         CHECK_ACCESS(_res_ptr);
26748         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
26749         FREE(untag_ptr(_res));
26750         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
26751 }
26752
26753 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
26754         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26755         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
26756         return tag_ptr(ret_conv, true);
26757 }
26758 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(int64_t arg) {
26759         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
26760         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
26761         return ret_conv;
26762 }
26763
26764 int64_t  CS_LDK_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(int64_t orig) {
26765         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
26766         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
26767         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
26768         return tag_ptr(ret_conv, true);
26769 }
26770
26771 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_ok(int64_t o) {
26772         LDKChannelTransactionParameters o_conv;
26773         o_conv.inner = untag_ptr(o);
26774         o_conv.is_owned = ptr_is_owned(o);
26775         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26776         o_conv = ChannelTransactionParameters_clone(&o_conv);
26777         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26778         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
26779         return tag_ptr(ret_conv, true);
26780 }
26781
26782 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_err(int64_t e) {
26783         void* e_ptr = untag_ptr(e);
26784         CHECK_ACCESS(e_ptr);
26785         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26786         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26787         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26788         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
26789         return tag_ptr(ret_conv, true);
26790 }
26791
26792 jboolean  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(int64_t o) {
26793         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
26794         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
26795         return ret_conv;
26796 }
26797
26798 void  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_free(int64_t _res) {
26799         if (!ptr_is_owned(_res)) return;
26800         void* _res_ptr = untag_ptr(_res);
26801         CHECK_ACCESS(_res_ptr);
26802         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
26803         FREE(untag_ptr(_res));
26804         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
26805 }
26806
26807 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
26808         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26809         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
26810         return tag_ptr(ret_conv, true);
26811 }
26812 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(int64_t arg) {
26813         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
26814         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
26815         return ret_conv;
26816 }
26817
26818 int64_t  CS_LDK_CResult_ChannelTransactionParametersDecodeErrorZ_clone(int64_t orig) {
26819         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
26820         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
26821         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
26822         return tag_ptr(ret_conv, true);
26823 }
26824
26825 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(int64_t o) {
26826         LDKHolderCommitmentTransaction o_conv;
26827         o_conv.inner = untag_ptr(o);
26828         o_conv.is_owned = ptr_is_owned(o);
26829         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26830         o_conv = HolderCommitmentTransaction_clone(&o_conv);
26831         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26832         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
26833         return tag_ptr(ret_conv, true);
26834 }
26835
26836 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_err(int64_t e) {
26837         void* e_ptr = untag_ptr(e);
26838         CHECK_ACCESS(e_ptr);
26839         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26840         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26841         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26842         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
26843         return tag_ptr(ret_conv, true);
26844 }
26845
26846 jboolean  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(int64_t o) {
26847         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
26848         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
26849         return ret_conv;
26850 }
26851
26852 void  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_free(int64_t _res) {
26853         if (!ptr_is_owned(_res)) return;
26854         void* _res_ptr = untag_ptr(_res);
26855         CHECK_ACCESS(_res_ptr);
26856         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
26857         FREE(untag_ptr(_res));
26858         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
26859 }
26860
26861 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
26862         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26863         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
26864         return tag_ptr(ret_conv, true);
26865 }
26866 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(int64_t arg) {
26867         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
26868         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
26869         return ret_conv;
26870 }
26871
26872 int64_t  CS_LDK_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(int64_t orig) {
26873         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
26874         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
26875         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
26876         return tag_ptr(ret_conv, true);
26877 }
26878
26879 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(int64_t o) {
26880         LDKBuiltCommitmentTransaction o_conv;
26881         o_conv.inner = untag_ptr(o);
26882         o_conv.is_owned = ptr_is_owned(o);
26883         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26884         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
26885         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26886         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
26887         return tag_ptr(ret_conv, true);
26888 }
26889
26890 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(int64_t e) {
26891         void* e_ptr = untag_ptr(e);
26892         CHECK_ACCESS(e_ptr);
26893         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26894         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26895         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26896         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
26897         return tag_ptr(ret_conv, true);
26898 }
26899
26900 jboolean  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(int64_t o) {
26901         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
26902         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
26903         return ret_conv;
26904 }
26905
26906 void  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(int64_t _res) {
26907         if (!ptr_is_owned(_res)) return;
26908         void* _res_ptr = untag_ptr(_res);
26909         CHECK_ACCESS(_res_ptr);
26910         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
26911         FREE(untag_ptr(_res));
26912         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
26913 }
26914
26915 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
26916         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26917         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
26918         return tag_ptr(ret_conv, true);
26919 }
26920 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(int64_t arg) {
26921         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
26922         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
26923         return ret_conv;
26924 }
26925
26926 int64_t  CS_LDK_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(int64_t orig) {
26927         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
26928         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
26929         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
26930         return tag_ptr(ret_conv, true);
26931 }
26932
26933 int64_t  CS_LDK_CResult_TrustedClosingTransactionNoneZ_ok(int64_t o) {
26934         LDKTrustedClosingTransaction o_conv;
26935         o_conv.inner = untag_ptr(o);
26936         o_conv.is_owned = ptr_is_owned(o);
26937         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26938         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
26939         
26940         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
26941         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
26942         return tag_ptr(ret_conv, true);
26943 }
26944
26945 int64_t  CS_LDK_CResult_TrustedClosingTransactionNoneZ_err() {
26946         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
26947         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
26948         return tag_ptr(ret_conv, true);
26949 }
26950
26951 jboolean  CS_LDK_CResult_TrustedClosingTransactionNoneZ_is_ok(int64_t o) {
26952         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
26953         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
26954         return ret_conv;
26955 }
26956
26957 void  CS_LDK_CResult_TrustedClosingTransactionNoneZ_free(int64_t _res) {
26958         if (!ptr_is_owned(_res)) return;
26959         void* _res_ptr = untag_ptr(_res);
26960         CHECK_ACCESS(_res_ptr);
26961         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
26962         FREE(untag_ptr(_res));
26963         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
26964 }
26965
26966 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_ok(int64_t o) {
26967         LDKCommitmentTransaction o_conv;
26968         o_conv.inner = untag_ptr(o);
26969         o_conv.is_owned = ptr_is_owned(o);
26970         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
26971         o_conv = CommitmentTransaction_clone(&o_conv);
26972         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
26973         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
26974         return tag_ptr(ret_conv, true);
26975 }
26976
26977 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_err(int64_t e) {
26978         void* e_ptr = untag_ptr(e);
26979         CHECK_ACCESS(e_ptr);
26980         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
26981         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
26982         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
26983         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
26984         return tag_ptr(ret_conv, true);
26985 }
26986
26987 jboolean  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_is_ok(int64_t o) {
26988         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
26989         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
26990         return ret_conv;
26991 }
26992
26993 void  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_free(int64_t _res) {
26994         if (!ptr_is_owned(_res)) return;
26995         void* _res_ptr = untag_ptr(_res);
26996         CHECK_ACCESS(_res_ptr);
26997         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
26998         FREE(untag_ptr(_res));
26999         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
27000 }
27001
27002 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
27003         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
27004         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
27005         return tag_ptr(ret_conv, true);
27006 }
27007 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(int64_t arg) {
27008         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
27009         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
27010         return ret_conv;
27011 }
27012
27013 int64_t  CS_LDK_CResult_CommitmentTransactionDecodeErrorZ_clone(int64_t orig) {
27014         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
27015         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
27016         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
27017         return tag_ptr(ret_conv, true);
27018 }
27019
27020 int64_t  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_ok(int64_t o) {
27021         LDKTrustedCommitmentTransaction o_conv;
27022         o_conv.inner = untag_ptr(o);
27023         o_conv.is_owned = ptr_is_owned(o);
27024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27025         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
27026         
27027         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
27028         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
27029         return tag_ptr(ret_conv, true);
27030 }
27031
27032 int64_t  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_err() {
27033         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
27034         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
27035         return tag_ptr(ret_conv, true);
27036 }
27037
27038 jboolean  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_is_ok(int64_t o) {
27039         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
27040         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
27041         return ret_conv;
27042 }
27043
27044 void  CS_LDK_CResult_TrustedCommitmentTransactionNoneZ_free(int64_t _res) {
27045         if (!ptr_is_owned(_res)) return;
27046         void* _res_ptr = untag_ptr(_res);
27047         CHECK_ACCESS(_res_ptr);
27048         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
27049         FREE(untag_ptr(_res));
27050         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
27051 }
27052
27053 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_ok(ptrArray o) {
27054         LDKCVec_ECDSASignatureZ o_constr;
27055         o_constr.datalen = o->arr_len;
27056         if (o_constr.datalen > 0)
27057                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
27058         else
27059                 o_constr.data = NULL;
27060         int8_tArray* o_vals = (void*) o->elems;
27061         for (size_t i = 0; i < o_constr.datalen; i++) {
27062                 int8_tArray o_conv_8 = o_vals[i];
27063                 LDKECDSASignature o_conv_8_ref;
27064                 CHECK(o_conv_8->arr_len == 64);
27065                 memcpy(o_conv_8_ref.compact_form, o_conv_8->elems, 64); FREE(o_conv_8);
27066                 o_constr.data[i] = o_conv_8_ref;
27067         }
27068         FREE(o);
27069         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27070         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_ok(o_constr);
27071         return tag_ptr(ret_conv, true);
27072 }
27073
27074 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_err() {
27075         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27076         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_err();
27077         return tag_ptr(ret_conv, true);
27078 }
27079
27080 jboolean  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_is_ok(int64_t o) {
27081         LDKCResult_CVec_ECDSASignatureZNoneZ* o_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(o);
27082         jboolean ret_conv = CResult_CVec_ECDSASignatureZNoneZ_is_ok(o_conv);
27083         return ret_conv;
27084 }
27085
27086 void  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_free(int64_t _res) {
27087         if (!ptr_is_owned(_res)) return;
27088         void* _res_ptr = untag_ptr(_res);
27089         CHECK_ACCESS(_res_ptr);
27090         LDKCResult_CVec_ECDSASignatureZNoneZ _res_conv = *(LDKCResult_CVec_ECDSASignatureZNoneZ*)(_res_ptr);
27091         FREE(untag_ptr(_res));
27092         CResult_CVec_ECDSASignatureZNoneZ_free(_res_conv);
27093 }
27094
27095 static inline uint64_t CResult_CVec_ECDSASignatureZNoneZ_clone_ptr(LDKCResult_CVec_ECDSASignatureZNoneZ *NONNULL_PTR arg) {
27096         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27097         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_clone(arg);
27098         return tag_ptr(ret_conv, true);
27099 }
27100 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_clone_ptr(int64_t arg) {
27101         LDKCResult_CVec_ECDSASignatureZNoneZ* arg_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(arg);
27102         int64_t ret_conv = CResult_CVec_ECDSASignatureZNoneZ_clone_ptr(arg_conv);
27103         return ret_conv;
27104 }
27105
27106 int64_t  CS_LDK_CResult_CVec_ECDSASignatureZNoneZ_clone(int64_t orig) {
27107         LDKCResult_CVec_ECDSASignatureZNoneZ* orig_conv = (LDKCResult_CVec_ECDSASignatureZNoneZ*)untag_ptr(orig);
27108         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
27109         *ret_conv = CResult_CVec_ECDSASignatureZNoneZ_clone(orig_conv);
27110         return tag_ptr(ret_conv, true);
27111 }
27112
27113 int64_t  CS_LDK_COption_usizeZ_some(int64_t o) {
27114         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27115         *ret_copy = COption_usizeZ_some(o);
27116         int64_t ret_ref = tag_ptr(ret_copy, true);
27117         return ret_ref;
27118 }
27119
27120 int64_t  CS_LDK_COption_usizeZ_none() {
27121         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27122         *ret_copy = COption_usizeZ_none();
27123         int64_t ret_ref = tag_ptr(ret_copy, true);
27124         return ret_ref;
27125 }
27126
27127 void  CS_LDK_COption_usizeZ_free(int64_t _res) {
27128         if (!ptr_is_owned(_res)) return;
27129         void* _res_ptr = untag_ptr(_res);
27130         CHECK_ACCESS(_res_ptr);
27131         LDKCOption_usizeZ _res_conv = *(LDKCOption_usizeZ*)(_res_ptr);
27132         FREE(untag_ptr(_res));
27133         COption_usizeZ_free(_res_conv);
27134 }
27135
27136 static inline uint64_t COption_usizeZ_clone_ptr(LDKCOption_usizeZ *NONNULL_PTR arg) {
27137         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27138         *ret_copy = COption_usizeZ_clone(arg);
27139         int64_t ret_ref = tag_ptr(ret_copy, true);
27140         return ret_ref;
27141 }
27142 int64_t  CS_LDK_COption_usizeZ_clone_ptr(int64_t arg) {
27143         LDKCOption_usizeZ* arg_conv = (LDKCOption_usizeZ*)untag_ptr(arg);
27144         int64_t ret_conv = COption_usizeZ_clone_ptr(arg_conv);
27145         return ret_conv;
27146 }
27147
27148 int64_t  CS_LDK_COption_usizeZ_clone(int64_t orig) {
27149         LDKCOption_usizeZ* orig_conv = (LDKCOption_usizeZ*)untag_ptr(orig);
27150         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
27151         *ret_copy = COption_usizeZ_clone(orig_conv);
27152         int64_t ret_ref = tag_ptr(ret_copy, true);
27153         return ret_ref;
27154 }
27155
27156 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_ok(int64_t o) {
27157         LDKShutdownScript o_conv;
27158         o_conv.inner = untag_ptr(o);
27159         o_conv.is_owned = ptr_is_owned(o);
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27161         o_conv = ShutdownScript_clone(&o_conv);
27162         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27163         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
27164         return tag_ptr(ret_conv, true);
27165 }
27166
27167 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_err(int64_t e) {
27168         void* e_ptr = untag_ptr(e);
27169         CHECK_ACCESS(e_ptr);
27170         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27171         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27172         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27173         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
27174         return tag_ptr(ret_conv, true);
27175 }
27176
27177 jboolean  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_is_ok(int64_t o) {
27178         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
27179         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
27180         return ret_conv;
27181 }
27182
27183 void  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_free(int64_t _res) {
27184         if (!ptr_is_owned(_res)) return;
27185         void* _res_ptr = untag_ptr(_res);
27186         CHECK_ACCESS(_res_ptr);
27187         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
27188         FREE(untag_ptr(_res));
27189         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
27190 }
27191
27192 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
27193         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27194         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
27195         return tag_ptr(ret_conv, true);
27196 }
27197 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(int64_t arg) {
27198         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
27199         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
27200         return ret_conv;
27201 }
27202
27203 int64_t  CS_LDK_CResult_ShutdownScriptDecodeErrorZ_clone(int64_t orig) {
27204         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
27205         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
27206         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
27207         return tag_ptr(ret_conv, true);
27208 }
27209
27210 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(int64_t o) {
27211         LDKShutdownScript o_conv;
27212         o_conv.inner = untag_ptr(o);
27213         o_conv.is_owned = ptr_is_owned(o);
27214         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27215         o_conv = ShutdownScript_clone(&o_conv);
27216         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27217         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
27218         return tag_ptr(ret_conv, true);
27219 }
27220
27221 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_err(int64_t e) {
27222         LDKInvalidShutdownScript e_conv;
27223         e_conv.inner = untag_ptr(e);
27224         e_conv.is_owned = ptr_is_owned(e);
27225         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
27226         e_conv = InvalidShutdownScript_clone(&e_conv);
27227         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27228         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
27229         return tag_ptr(ret_conv, true);
27230 }
27231
27232 jboolean  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(int64_t o) {
27233         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
27234         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
27235         return ret_conv;
27236 }
27237
27238 void  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_free(int64_t _res) {
27239         if (!ptr_is_owned(_res)) return;
27240         void* _res_ptr = untag_ptr(_res);
27241         CHECK_ACCESS(_res_ptr);
27242         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
27243         FREE(untag_ptr(_res));
27244         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
27245 }
27246
27247 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
27248         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27249         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
27250         return tag_ptr(ret_conv, true);
27251 }
27252 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(int64_t arg) {
27253         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
27254         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
27255         return ret_conv;
27256 }
27257
27258 int64_t  CS_LDK_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(int64_t orig) {
27259         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
27260         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
27261         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
27262         return tag_ptr(ret_conv, true);
27263 }
27264
27265 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_ok(int64_t o) {
27266         void* o_ptr = untag_ptr(o);
27267         CHECK_ACCESS(o_ptr);
27268         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
27269         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
27270         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27271         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
27272         return tag_ptr(ret_conv, true);
27273 }
27274
27275 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_err(int64_t e) {
27276         void* e_ptr = untag_ptr(e);
27277         CHECK_ACCESS(e_ptr);
27278         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27279         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27280         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27281         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
27282         return tag_ptr(ret_conv, true);
27283 }
27284
27285 jboolean  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_is_ok(int64_t o) {
27286         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
27287         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
27288         return ret_conv;
27289 }
27290
27291 void  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_free(int64_t _res) {
27292         if (!ptr_is_owned(_res)) return;
27293         void* _res_ptr = untag_ptr(_res);
27294         CHECK_ACCESS(_res_ptr);
27295         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
27296         FREE(untag_ptr(_res));
27297         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
27298 }
27299
27300 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
27301         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27302         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
27303         return tag_ptr(ret_conv, true);
27304 }
27305 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(int64_t arg) {
27306         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
27307         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
27308         return ret_conv;
27309 }
27310
27311 int64_t  CS_LDK_CResult_PaymentPurposeDecodeErrorZ_clone(int64_t orig) {
27312         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
27313         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
27314         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
27315         return tag_ptr(ret_conv, true);
27316 }
27317
27318 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_ok(int64_t o) {
27319         LDKClaimedHTLC o_conv;
27320         o_conv.inner = untag_ptr(o);
27321         o_conv.is_owned = ptr_is_owned(o);
27322         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27323         o_conv = ClaimedHTLC_clone(&o_conv);
27324         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27325         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_ok(o_conv);
27326         return tag_ptr(ret_conv, true);
27327 }
27328
27329 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_err(int64_t e) {
27330         void* e_ptr = untag_ptr(e);
27331         CHECK_ACCESS(e_ptr);
27332         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27333         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27334         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27335         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_err(e_conv);
27336         return tag_ptr(ret_conv, true);
27337 }
27338
27339 jboolean  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_is_ok(int64_t o) {
27340         LDKCResult_ClaimedHTLCDecodeErrorZ* o_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(o);
27341         jboolean ret_conv = CResult_ClaimedHTLCDecodeErrorZ_is_ok(o_conv);
27342         return ret_conv;
27343 }
27344
27345 void  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_free(int64_t _res) {
27346         if (!ptr_is_owned(_res)) return;
27347         void* _res_ptr = untag_ptr(_res);
27348         CHECK_ACCESS(_res_ptr);
27349         LDKCResult_ClaimedHTLCDecodeErrorZ _res_conv = *(LDKCResult_ClaimedHTLCDecodeErrorZ*)(_res_ptr);
27350         FREE(untag_ptr(_res));
27351         CResult_ClaimedHTLCDecodeErrorZ_free(_res_conv);
27352 }
27353
27354 static inline uint64_t CResult_ClaimedHTLCDecodeErrorZ_clone_ptr(LDKCResult_ClaimedHTLCDecodeErrorZ *NONNULL_PTR arg) {
27355         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27356         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_clone(arg);
27357         return tag_ptr(ret_conv, true);
27358 }
27359 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_clone_ptr(int64_t arg) {
27360         LDKCResult_ClaimedHTLCDecodeErrorZ* arg_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(arg);
27361         int64_t ret_conv = CResult_ClaimedHTLCDecodeErrorZ_clone_ptr(arg_conv);
27362         return ret_conv;
27363 }
27364
27365 int64_t  CS_LDK_CResult_ClaimedHTLCDecodeErrorZ_clone(int64_t orig) {
27366         LDKCResult_ClaimedHTLCDecodeErrorZ* orig_conv = (LDKCResult_ClaimedHTLCDecodeErrorZ*)untag_ptr(orig);
27367         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
27368         *ret_conv = CResult_ClaimedHTLCDecodeErrorZ_clone(orig_conv);
27369         return tag_ptr(ret_conv, true);
27370 }
27371
27372 int64_t  CS_LDK_COption_PathFailureZ_some(int64_t o) {
27373         void* o_ptr = untag_ptr(o);
27374         CHECK_ACCESS(o_ptr);
27375         LDKPathFailure o_conv = *(LDKPathFailure*)(o_ptr);
27376         o_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(o));
27377         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27378         *ret_copy = COption_PathFailureZ_some(o_conv);
27379         int64_t ret_ref = tag_ptr(ret_copy, true);
27380         return ret_ref;
27381 }
27382
27383 int64_t  CS_LDK_COption_PathFailureZ_none() {
27384         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27385         *ret_copy = COption_PathFailureZ_none();
27386         int64_t ret_ref = tag_ptr(ret_copy, true);
27387         return ret_ref;
27388 }
27389
27390 void  CS_LDK_COption_PathFailureZ_free(int64_t _res) {
27391         if (!ptr_is_owned(_res)) return;
27392         void* _res_ptr = untag_ptr(_res);
27393         CHECK_ACCESS(_res_ptr);
27394         LDKCOption_PathFailureZ _res_conv = *(LDKCOption_PathFailureZ*)(_res_ptr);
27395         FREE(untag_ptr(_res));
27396         COption_PathFailureZ_free(_res_conv);
27397 }
27398
27399 static inline uint64_t COption_PathFailureZ_clone_ptr(LDKCOption_PathFailureZ *NONNULL_PTR arg) {
27400         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27401         *ret_copy = COption_PathFailureZ_clone(arg);
27402         int64_t ret_ref = tag_ptr(ret_copy, true);
27403         return ret_ref;
27404 }
27405 int64_t  CS_LDK_COption_PathFailureZ_clone_ptr(int64_t arg) {
27406         LDKCOption_PathFailureZ* arg_conv = (LDKCOption_PathFailureZ*)untag_ptr(arg);
27407         int64_t ret_conv = COption_PathFailureZ_clone_ptr(arg_conv);
27408         return ret_conv;
27409 }
27410
27411 int64_t  CS_LDK_COption_PathFailureZ_clone(int64_t orig) {
27412         LDKCOption_PathFailureZ* orig_conv = (LDKCOption_PathFailureZ*)untag_ptr(orig);
27413         LDKCOption_PathFailureZ *ret_copy = MALLOC(sizeof(LDKCOption_PathFailureZ), "LDKCOption_PathFailureZ");
27414         *ret_copy = COption_PathFailureZ_clone(orig_conv);
27415         int64_t ret_ref = tag_ptr(ret_copy, true);
27416         return ret_ref;
27417 }
27418
27419 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_ok(int64_t o) {
27420         void* o_ptr = untag_ptr(o);
27421         CHECK_ACCESS(o_ptr);
27422         LDKCOption_PathFailureZ o_conv = *(LDKCOption_PathFailureZ*)(o_ptr);
27423         o_conv = COption_PathFailureZ_clone((LDKCOption_PathFailureZ*)untag_ptr(o));
27424         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27425         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_ok(o_conv);
27426         return tag_ptr(ret_conv, true);
27427 }
27428
27429 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_err(int64_t e) {
27430         void* e_ptr = untag_ptr(e);
27431         CHECK_ACCESS(e_ptr);
27432         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27433         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27434         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27435         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_err(e_conv);
27436         return tag_ptr(ret_conv, true);
27437 }
27438
27439 jboolean  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_is_ok(int64_t o) {
27440         LDKCResult_COption_PathFailureZDecodeErrorZ* o_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(o);
27441         jboolean ret_conv = CResult_COption_PathFailureZDecodeErrorZ_is_ok(o_conv);
27442         return ret_conv;
27443 }
27444
27445 void  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_free(int64_t _res) {
27446         if (!ptr_is_owned(_res)) return;
27447         void* _res_ptr = untag_ptr(_res);
27448         CHECK_ACCESS(_res_ptr);
27449         LDKCResult_COption_PathFailureZDecodeErrorZ _res_conv = *(LDKCResult_COption_PathFailureZDecodeErrorZ*)(_res_ptr);
27450         FREE(untag_ptr(_res));
27451         CResult_COption_PathFailureZDecodeErrorZ_free(_res_conv);
27452 }
27453
27454 static inline uint64_t CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(LDKCResult_COption_PathFailureZDecodeErrorZ *NONNULL_PTR arg) {
27455         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27456         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(arg);
27457         return tag_ptr(ret_conv, true);
27458 }
27459 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(int64_t arg) {
27460         LDKCResult_COption_PathFailureZDecodeErrorZ* arg_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(arg);
27461         int64_t ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone_ptr(arg_conv);
27462         return ret_conv;
27463 }
27464
27465 int64_t  CS_LDK_CResult_COption_PathFailureZDecodeErrorZ_clone(int64_t orig) {
27466         LDKCResult_COption_PathFailureZDecodeErrorZ* orig_conv = (LDKCResult_COption_PathFailureZDecodeErrorZ*)untag_ptr(orig);
27467         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
27468         *ret_conv = CResult_COption_PathFailureZDecodeErrorZ_clone(orig_conv);
27469         return tag_ptr(ret_conv, true);
27470 }
27471
27472 int64_t  CS_LDK_COption_ClosureReasonZ_some(int64_t o) {
27473         void* o_ptr = untag_ptr(o);
27474         CHECK_ACCESS(o_ptr);
27475         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
27476         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
27477         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27478         *ret_copy = COption_ClosureReasonZ_some(o_conv);
27479         int64_t ret_ref = tag_ptr(ret_copy, true);
27480         return ret_ref;
27481 }
27482
27483 int64_t  CS_LDK_COption_ClosureReasonZ_none() {
27484         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27485         *ret_copy = COption_ClosureReasonZ_none();
27486         int64_t ret_ref = tag_ptr(ret_copy, true);
27487         return ret_ref;
27488 }
27489
27490 void  CS_LDK_COption_ClosureReasonZ_free(int64_t _res) {
27491         if (!ptr_is_owned(_res)) return;
27492         void* _res_ptr = untag_ptr(_res);
27493         CHECK_ACCESS(_res_ptr);
27494         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
27495         FREE(untag_ptr(_res));
27496         COption_ClosureReasonZ_free(_res_conv);
27497 }
27498
27499 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
27500         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27501         *ret_copy = COption_ClosureReasonZ_clone(arg);
27502         int64_t ret_ref = tag_ptr(ret_copy, true);
27503         return ret_ref;
27504 }
27505 int64_t  CS_LDK_COption_ClosureReasonZ_clone_ptr(int64_t arg) {
27506         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
27507         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
27508         return ret_conv;
27509 }
27510
27511 int64_t  CS_LDK_COption_ClosureReasonZ_clone(int64_t orig) {
27512         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
27513         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
27514         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
27515         int64_t ret_ref = tag_ptr(ret_copy, true);
27516         return ret_ref;
27517 }
27518
27519 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_ok(int64_t o) {
27520         void* o_ptr = untag_ptr(o);
27521         CHECK_ACCESS(o_ptr);
27522         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
27523         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
27524         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27525         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
27526         return tag_ptr(ret_conv, true);
27527 }
27528
27529 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_err(int64_t e) {
27530         void* e_ptr = untag_ptr(e);
27531         CHECK_ACCESS(e_ptr);
27532         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27533         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27534         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27535         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
27536         return tag_ptr(ret_conv, true);
27537 }
27538
27539 jboolean  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(int64_t o) {
27540         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
27541         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
27542         return ret_conv;
27543 }
27544
27545 void  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_free(int64_t _res) {
27546         if (!ptr_is_owned(_res)) return;
27547         void* _res_ptr = untag_ptr(_res);
27548         CHECK_ACCESS(_res_ptr);
27549         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
27550         FREE(untag_ptr(_res));
27551         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
27552 }
27553
27554 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
27555         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27556         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
27557         return tag_ptr(ret_conv, true);
27558 }
27559 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(int64_t arg) {
27560         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
27561         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
27562         return ret_conv;
27563 }
27564
27565 int64_t  CS_LDK_CResult_COption_ClosureReasonZDecodeErrorZ_clone(int64_t orig) {
27566         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
27567         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
27568         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
27569         return tag_ptr(ret_conv, true);
27570 }
27571
27572 int64_t  CS_LDK_COption_HTLCDestinationZ_some(int64_t o) {
27573         void* o_ptr = untag_ptr(o);
27574         CHECK_ACCESS(o_ptr);
27575         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
27576         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
27577         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27578         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
27579         int64_t ret_ref = tag_ptr(ret_copy, true);
27580         return ret_ref;
27581 }
27582
27583 int64_t  CS_LDK_COption_HTLCDestinationZ_none() {
27584         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27585         *ret_copy = COption_HTLCDestinationZ_none();
27586         int64_t ret_ref = tag_ptr(ret_copy, true);
27587         return ret_ref;
27588 }
27589
27590 void  CS_LDK_COption_HTLCDestinationZ_free(int64_t _res) {
27591         if (!ptr_is_owned(_res)) return;
27592         void* _res_ptr = untag_ptr(_res);
27593         CHECK_ACCESS(_res_ptr);
27594         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
27595         FREE(untag_ptr(_res));
27596         COption_HTLCDestinationZ_free(_res_conv);
27597 }
27598
27599 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
27600         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27601         *ret_copy = COption_HTLCDestinationZ_clone(arg);
27602         int64_t ret_ref = tag_ptr(ret_copy, true);
27603         return ret_ref;
27604 }
27605 int64_t  CS_LDK_COption_HTLCDestinationZ_clone_ptr(int64_t arg) {
27606         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
27607         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
27608         return ret_conv;
27609 }
27610
27611 int64_t  CS_LDK_COption_HTLCDestinationZ_clone(int64_t orig) {
27612         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
27613         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
27614         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
27615         int64_t ret_ref = tag_ptr(ret_copy, true);
27616         return ret_ref;
27617 }
27618
27619 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_ok(int64_t o) {
27620         void* o_ptr = untag_ptr(o);
27621         CHECK_ACCESS(o_ptr);
27622         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
27623         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
27624         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27625         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
27626         return tag_ptr(ret_conv, true);
27627 }
27628
27629 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_err(int64_t e) {
27630         void* e_ptr = untag_ptr(e);
27631         CHECK_ACCESS(e_ptr);
27632         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27633         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27634         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27635         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
27636         return tag_ptr(ret_conv, true);
27637 }
27638
27639 jboolean  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(int64_t o) {
27640         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
27641         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
27642         return ret_conv;
27643 }
27644
27645 void  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_free(int64_t _res) {
27646         if (!ptr_is_owned(_res)) return;
27647         void* _res_ptr = untag_ptr(_res);
27648         CHECK_ACCESS(_res_ptr);
27649         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
27650         FREE(untag_ptr(_res));
27651         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
27652 }
27653
27654 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
27655         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27656         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
27657         return tag_ptr(ret_conv, true);
27658 }
27659 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(int64_t arg) {
27660         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
27661         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
27662         return ret_conv;
27663 }
27664
27665 int64_t  CS_LDK_CResult_COption_HTLCDestinationZDecodeErrorZ_clone(int64_t orig) {
27666         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
27667         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
27668         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
27669         return tag_ptr(ret_conv, true);
27670 }
27671
27672 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_ok(int32_t o) {
27673         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_cs(o);
27674         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27675         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_ok(o_conv);
27676         return tag_ptr(ret_conv, true);
27677 }
27678
27679 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_err(int64_t e) {
27680         void* e_ptr = untag_ptr(e);
27681         CHECK_ACCESS(e_ptr);
27682         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27683         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27684         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27685         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_err(e_conv);
27686         return tag_ptr(ret_conv, true);
27687 }
27688
27689 jboolean  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_is_ok(int64_t o) {
27690         LDKCResult_PaymentFailureReasonDecodeErrorZ* o_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(o);
27691         jboolean ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_is_ok(o_conv);
27692         return ret_conv;
27693 }
27694
27695 void  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_free(int64_t _res) {
27696         if (!ptr_is_owned(_res)) return;
27697         void* _res_ptr = untag_ptr(_res);
27698         CHECK_ACCESS(_res_ptr);
27699         LDKCResult_PaymentFailureReasonDecodeErrorZ _res_conv = *(LDKCResult_PaymentFailureReasonDecodeErrorZ*)(_res_ptr);
27700         FREE(untag_ptr(_res));
27701         CResult_PaymentFailureReasonDecodeErrorZ_free(_res_conv);
27702 }
27703
27704 static inline uint64_t CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(LDKCResult_PaymentFailureReasonDecodeErrorZ *NONNULL_PTR arg) {
27705         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27706         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(arg);
27707         return tag_ptr(ret_conv, true);
27708 }
27709 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(int64_t arg) {
27710         LDKCResult_PaymentFailureReasonDecodeErrorZ* arg_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(arg);
27711         int64_t ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone_ptr(arg_conv);
27712         return ret_conv;
27713 }
27714
27715 int64_t  CS_LDK_CResult_PaymentFailureReasonDecodeErrorZ_clone(int64_t orig) {
27716         LDKCResult_PaymentFailureReasonDecodeErrorZ* orig_conv = (LDKCResult_PaymentFailureReasonDecodeErrorZ*)untag_ptr(orig);
27717         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
27718         *ret_conv = CResult_PaymentFailureReasonDecodeErrorZ_clone(orig_conv);
27719         return tag_ptr(ret_conv, true);
27720 }
27721
27722 int64_t  CS_LDK_COption_U128Z_some(int8_tArray o) {
27723         LDKU128 o_ref;
27724         CHECK(o->arr_len == 16);
27725         memcpy(o_ref.le_bytes, o->elems, 16); FREE(o);
27726         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27727         *ret_copy = COption_U128Z_some(o_ref);
27728         int64_t ret_ref = tag_ptr(ret_copy, true);
27729         return ret_ref;
27730 }
27731
27732 int64_t  CS_LDK_COption_U128Z_none() {
27733         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27734         *ret_copy = COption_U128Z_none();
27735         int64_t ret_ref = tag_ptr(ret_copy, true);
27736         return ret_ref;
27737 }
27738
27739 void  CS_LDK_COption_U128Z_free(int64_t _res) {
27740         if (!ptr_is_owned(_res)) return;
27741         void* _res_ptr = untag_ptr(_res);
27742         CHECK_ACCESS(_res_ptr);
27743         LDKCOption_U128Z _res_conv = *(LDKCOption_U128Z*)(_res_ptr);
27744         FREE(untag_ptr(_res));
27745         COption_U128Z_free(_res_conv);
27746 }
27747
27748 static inline uint64_t COption_U128Z_clone_ptr(LDKCOption_U128Z *NONNULL_PTR arg) {
27749         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27750         *ret_copy = COption_U128Z_clone(arg);
27751         int64_t ret_ref = tag_ptr(ret_copy, true);
27752         return ret_ref;
27753 }
27754 int64_t  CS_LDK_COption_U128Z_clone_ptr(int64_t arg) {
27755         LDKCOption_U128Z* arg_conv = (LDKCOption_U128Z*)untag_ptr(arg);
27756         int64_t ret_conv = COption_U128Z_clone_ptr(arg_conv);
27757         return ret_conv;
27758 }
27759
27760 int64_t  CS_LDK_COption_U128Z_clone(int64_t orig) {
27761         LDKCOption_U128Z* orig_conv = (LDKCOption_U128Z*)untag_ptr(orig);
27762         LDKCOption_U128Z *ret_copy = MALLOC(sizeof(LDKCOption_U128Z), "LDKCOption_U128Z");
27763         *ret_copy = COption_U128Z_clone(orig_conv);
27764         int64_t ret_ref = tag_ptr(ret_copy, true);
27765         return ret_ref;
27766 }
27767
27768 void  CS_LDK_CVec_ClaimedHTLCZ_free(int64_tArray _res) {
27769         LDKCVec_ClaimedHTLCZ _res_constr;
27770         _res_constr.datalen = _res->arr_len;
27771         if (_res_constr.datalen > 0)
27772                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKClaimedHTLC), "LDKCVec_ClaimedHTLCZ Elements");
27773         else
27774                 _res_constr.data = NULL;
27775         int64_t* _res_vals = _res->elems;
27776         for (size_t n = 0; n < _res_constr.datalen; n++) {
27777                 int64_t _res_conv_13 = _res_vals[n];
27778                 LDKClaimedHTLC _res_conv_13_conv;
27779                 _res_conv_13_conv.inner = untag_ptr(_res_conv_13);
27780                 _res_conv_13_conv.is_owned = ptr_is_owned(_res_conv_13);
27781                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_13_conv);
27782                 _res_constr.data[n] = _res_conv_13_conv;
27783         }
27784         FREE(_res);
27785         CVec_ClaimedHTLCZ_free(_res_constr);
27786 }
27787
27788 int64_t  CS_LDK_COption_PaymentFailureReasonZ_some(int32_t o) {
27789         LDKPaymentFailureReason o_conv = LDKPaymentFailureReason_from_cs(o);
27790         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27791         *ret_copy = COption_PaymentFailureReasonZ_some(o_conv);
27792         int64_t ret_ref = tag_ptr(ret_copy, true);
27793         return ret_ref;
27794 }
27795
27796 int64_t  CS_LDK_COption_PaymentFailureReasonZ_none() {
27797         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27798         *ret_copy = COption_PaymentFailureReasonZ_none();
27799         int64_t ret_ref = tag_ptr(ret_copy, true);
27800         return ret_ref;
27801 }
27802
27803 void  CS_LDK_COption_PaymentFailureReasonZ_free(int64_t _res) {
27804         if (!ptr_is_owned(_res)) return;
27805         void* _res_ptr = untag_ptr(_res);
27806         CHECK_ACCESS(_res_ptr);
27807         LDKCOption_PaymentFailureReasonZ _res_conv = *(LDKCOption_PaymentFailureReasonZ*)(_res_ptr);
27808         FREE(untag_ptr(_res));
27809         COption_PaymentFailureReasonZ_free(_res_conv);
27810 }
27811
27812 static inline uint64_t COption_PaymentFailureReasonZ_clone_ptr(LDKCOption_PaymentFailureReasonZ *NONNULL_PTR arg) {
27813         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27814         *ret_copy = COption_PaymentFailureReasonZ_clone(arg);
27815         int64_t ret_ref = tag_ptr(ret_copy, true);
27816         return ret_ref;
27817 }
27818 int64_t  CS_LDK_COption_PaymentFailureReasonZ_clone_ptr(int64_t arg) {
27819         LDKCOption_PaymentFailureReasonZ* arg_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(arg);
27820         int64_t ret_conv = COption_PaymentFailureReasonZ_clone_ptr(arg_conv);
27821         return ret_conv;
27822 }
27823
27824 int64_t  CS_LDK_COption_PaymentFailureReasonZ_clone(int64_t orig) {
27825         LDKCOption_PaymentFailureReasonZ* orig_conv = (LDKCOption_PaymentFailureReasonZ*)untag_ptr(orig);
27826         LDKCOption_PaymentFailureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_PaymentFailureReasonZ), "LDKCOption_PaymentFailureReasonZ");
27827         *ret_copy = COption_PaymentFailureReasonZ_clone(orig_conv);
27828         int64_t ret_ref = tag_ptr(ret_copy, true);
27829         return ret_ref;
27830 }
27831
27832 int64_t  CS_LDK_COption_EventZ_some(int64_t o) {
27833         void* o_ptr = untag_ptr(o);
27834         CHECK_ACCESS(o_ptr);
27835         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
27836         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
27837         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27838         *ret_copy = COption_EventZ_some(o_conv);
27839         int64_t ret_ref = tag_ptr(ret_copy, true);
27840         return ret_ref;
27841 }
27842
27843 int64_t  CS_LDK_COption_EventZ_none() {
27844         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27845         *ret_copy = COption_EventZ_none();
27846         int64_t ret_ref = tag_ptr(ret_copy, true);
27847         return ret_ref;
27848 }
27849
27850 void  CS_LDK_COption_EventZ_free(int64_t _res) {
27851         if (!ptr_is_owned(_res)) return;
27852         void* _res_ptr = untag_ptr(_res);
27853         CHECK_ACCESS(_res_ptr);
27854         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
27855         FREE(untag_ptr(_res));
27856         COption_EventZ_free(_res_conv);
27857 }
27858
27859 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
27860         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27861         *ret_copy = COption_EventZ_clone(arg);
27862         int64_t ret_ref = tag_ptr(ret_copy, true);
27863         return ret_ref;
27864 }
27865 int64_t  CS_LDK_COption_EventZ_clone_ptr(int64_t arg) {
27866         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
27867         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
27868         return ret_conv;
27869 }
27870
27871 int64_t  CS_LDK_COption_EventZ_clone(int64_t orig) {
27872         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
27873         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
27874         *ret_copy = COption_EventZ_clone(orig_conv);
27875         int64_t ret_ref = tag_ptr(ret_copy, true);
27876         return ret_ref;
27877 }
27878
27879 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_ok(int64_t o) {
27880         void* o_ptr = untag_ptr(o);
27881         CHECK_ACCESS(o_ptr);
27882         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
27883         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
27884         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27885         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
27886         return tag_ptr(ret_conv, true);
27887 }
27888
27889 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_err(int64_t e) {
27890         void* e_ptr = untag_ptr(e);
27891         CHECK_ACCESS(e_ptr);
27892         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
27893         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
27894         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27895         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
27896         return tag_ptr(ret_conv, true);
27897 }
27898
27899 jboolean  CS_LDK_CResult_COption_EventZDecodeErrorZ_is_ok(int64_t o) {
27900         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
27901         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
27902         return ret_conv;
27903 }
27904
27905 void  CS_LDK_CResult_COption_EventZDecodeErrorZ_free(int64_t _res) {
27906         if (!ptr_is_owned(_res)) return;
27907         void* _res_ptr = untag_ptr(_res);
27908         CHECK_ACCESS(_res_ptr);
27909         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
27910         FREE(untag_ptr(_res));
27911         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
27912 }
27913
27914 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
27915         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27916         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
27917         return tag_ptr(ret_conv, true);
27918 }
27919 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_clone_ptr(int64_t arg) {
27920         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
27921         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
27922         return ret_conv;
27923 }
27924
27925 int64_t  CS_LDK_CResult_COption_EventZDecodeErrorZ_clone(int64_t orig) {
27926         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
27927         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
27928         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
27929         return tag_ptr(ret_conv, true);
27930 }
27931
27932 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_ok(int32_t o) {
27933         LDKSiPrefix o_conv = LDKSiPrefix_from_cs(o);
27934         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27935         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_ok(o_conv);
27936         return tag_ptr(ret_conv, true);
27937 }
27938
27939 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_err(int64_t e) {
27940         void* e_ptr = untag_ptr(e);
27941         CHECK_ACCESS(e_ptr);
27942         LDKBolt11ParseError e_conv = *(LDKBolt11ParseError*)(e_ptr);
27943         e_conv = Bolt11ParseError_clone((LDKBolt11ParseError*)untag_ptr(e));
27944         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27945         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_err(e_conv);
27946         return tag_ptr(ret_conv, true);
27947 }
27948
27949 jboolean  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_is_ok(int64_t o) {
27950         LDKCResult_SiPrefixBolt11ParseErrorZ* o_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(o);
27951         jboolean ret_conv = CResult_SiPrefixBolt11ParseErrorZ_is_ok(o_conv);
27952         return ret_conv;
27953 }
27954
27955 void  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_free(int64_t _res) {
27956         if (!ptr_is_owned(_res)) return;
27957         void* _res_ptr = untag_ptr(_res);
27958         CHECK_ACCESS(_res_ptr);
27959         LDKCResult_SiPrefixBolt11ParseErrorZ _res_conv = *(LDKCResult_SiPrefixBolt11ParseErrorZ*)(_res_ptr);
27960         FREE(untag_ptr(_res));
27961         CResult_SiPrefixBolt11ParseErrorZ_free(_res_conv);
27962 }
27963
27964 static inline uint64_t CResult_SiPrefixBolt11ParseErrorZ_clone_ptr(LDKCResult_SiPrefixBolt11ParseErrorZ *NONNULL_PTR arg) {
27965         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27966         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_clone(arg);
27967         return tag_ptr(ret_conv, true);
27968 }
27969 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_clone_ptr(int64_t arg) {
27970         LDKCResult_SiPrefixBolt11ParseErrorZ* arg_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(arg);
27971         int64_t ret_conv = CResult_SiPrefixBolt11ParseErrorZ_clone_ptr(arg_conv);
27972         return ret_conv;
27973 }
27974
27975 int64_t  CS_LDK_CResult_SiPrefixBolt11ParseErrorZ_clone(int64_t orig) {
27976         LDKCResult_SiPrefixBolt11ParseErrorZ* orig_conv = (LDKCResult_SiPrefixBolt11ParseErrorZ*)untag_ptr(orig);
27977         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
27978         *ret_conv = CResult_SiPrefixBolt11ParseErrorZ_clone(orig_conv);
27979         return tag_ptr(ret_conv, true);
27980 }
27981
27982 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(int64_t o) {
27983         LDKBolt11Invoice o_conv;
27984         o_conv.inner = untag_ptr(o);
27985         o_conv.is_owned = ptr_is_owned(o);
27986         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27987         o_conv = Bolt11Invoice_clone(&o_conv);
27988         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
27989         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_ok(o_conv);
27990         return tag_ptr(ret_conv, true);
27991 }
27992
27993 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(int64_t e) {
27994         void* e_ptr = untag_ptr(e);
27995         CHECK_ACCESS(e_ptr);
27996         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
27997         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
27998         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
27999         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_err(e_conv);
28000         return tag_ptr(ret_conv, true);
28001 }
28002
28003 jboolean  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(int64_t o) {
28004         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
28005         jboolean ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
28006         return ret_conv;
28007 }
28008
28009 void  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(int64_t _res) {
28010         if (!ptr_is_owned(_res)) return;
28011         void* _res_ptr = untag_ptr(_res);
28012         CHECK_ACCESS(_res_ptr);
28013         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)(_res_ptr);
28014         FREE(untag_ptr(_res));
28015         CResult_Bolt11InvoiceParseOrSemanticErrorZ_free(_res_conv);
28016 }
28017
28018 static inline uint64_t CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
28019         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
28020         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(arg);
28021         return tag_ptr(ret_conv, true);
28022 }
28023 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone_ptr(int64_t arg) {
28024         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
28025         int64_t ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
28026         return ret_conv;
28027 }
28028
28029 int64_t  CS_LDK_CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(int64_t orig) {
28030         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
28031         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
28032         *ret_conv = CResult_Bolt11InvoiceParseOrSemanticErrorZ_clone(orig_conv);
28033         return tag_ptr(ret_conv, true);
28034 }
28035
28036 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(int64_t o) {
28037         LDKSignedRawBolt11Invoice o_conv;
28038         o_conv.inner = untag_ptr(o);
28039         o_conv.is_owned = ptr_is_owned(o);
28040         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28041         o_conv = SignedRawBolt11Invoice_clone(&o_conv);
28042         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28043         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_ok(o_conv);
28044         return tag_ptr(ret_conv, true);
28045 }
28046
28047 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(int64_t e) {
28048         void* e_ptr = untag_ptr(e);
28049         CHECK_ACCESS(e_ptr);
28050         LDKBolt11ParseError e_conv = *(LDKBolt11ParseError*)(e_ptr);
28051         e_conv = Bolt11ParseError_clone((LDKBolt11ParseError*)untag_ptr(e));
28052         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28053         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_err(e_conv);
28054         return tag_ptr(ret_conv, true);
28055 }
28056
28057 jboolean  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(int64_t o) {
28058         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* o_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(o);
28059         jboolean ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_is_ok(o_conv);
28060         return ret_conv;
28061 }
28062
28063 void  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(int64_t _res) {
28064         if (!ptr_is_owned(_res)) return;
28065         void* _res_ptr = untag_ptr(_res);
28066         CHECK_ACCESS(_res_ptr);
28067         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ _res_conv = *(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)(_res_ptr);
28068         FREE(untag_ptr(_res));
28069         CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_free(_res_conv);
28070 }
28071
28072 static inline uint64_t CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone_ptr(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ *NONNULL_PTR arg) {
28073         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28074         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(arg);
28075         return tag_ptr(ret_conv, true);
28076 }
28077 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone_ptr(int64_t arg) {
28078         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* arg_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(arg);
28079         int64_t ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone_ptr(arg_conv);
28080         return ret_conv;
28081 }
28082
28083 int64_t  CS_LDK_CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(int64_t orig) {
28084         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* orig_conv = (LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ*)untag_ptr(orig);
28085         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
28086         *ret_conv = CResult_SignedRawBolt11InvoiceBolt11ParseErrorZ_clone(orig_conv);
28087         return tag_ptr(ret_conv, true);
28088 }
28089
28090 static inline uint64_t C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ *NONNULL_PTR arg) {
28091         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
28092         *ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(arg);
28093         return tag_ptr(ret_conv, true);
28094 }
28095 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone_ptr(int64_t arg) {
28096         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(arg);
28097         int64_t ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone_ptr(arg_conv);
28098         return ret_conv;
28099 }
28100
28101 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(int64_t orig) {
28102         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)untag_ptr(orig);
28103         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
28104         *ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_clone(orig_conv);
28105         return tag_ptr(ret_conv, true);
28106 }
28107
28108 int64_t  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(int64_t a, int8_tArray b, int64_t c) {
28109         LDKRawBolt11Invoice a_conv;
28110         a_conv.inner = untag_ptr(a);
28111         a_conv.is_owned = ptr_is_owned(a);
28112         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28113         a_conv = RawBolt11Invoice_clone(&a_conv);
28114         LDKThirtyTwoBytes b_ref;
28115         CHECK(b->arr_len == 32);
28116         memcpy(b_ref.data, b->elems, 32); FREE(b);
28117         LDKBolt11InvoiceSignature c_conv;
28118         c_conv.inner = untag_ptr(c);
28119         c_conv.is_owned = ptr_is_owned(c);
28120         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
28121         c_conv = Bolt11InvoiceSignature_clone(&c_conv);
28122         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
28123         *ret_conv = C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
28124         return tag_ptr(ret_conv, true);
28125 }
28126
28127 void  CS_LDK_C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(int64_t _res) {
28128         if (!ptr_is_owned(_res)) return;
28129         void* _res_ptr = untag_ptr(_res);
28130         CHECK_ACCESS(_res_ptr);
28131         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ*)(_res_ptr);
28132         FREE(untag_ptr(_res));
28133         C3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ_free(_res_conv);
28134 }
28135
28136 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_ok(int64_t o) {
28137         LDKPayeePubKey o_conv;
28138         o_conv.inner = untag_ptr(o);
28139         o_conv.is_owned = ptr_is_owned(o);
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28141         o_conv = PayeePubKey_clone(&o_conv);
28142         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28143         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_ok(o_conv);
28144         return tag_ptr(ret_conv, true);
28145 }
28146
28147 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_err(int32_t e) {
28148         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_cs(e);
28149         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28150         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_err(e_conv);
28151         return tag_ptr(ret_conv, true);
28152 }
28153
28154 jboolean  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_is_ok(int64_t o) {
28155         LDKCResult_PayeePubKeySecp256k1ErrorZ* o_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(o);
28156         jboolean ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_is_ok(o_conv);
28157         return ret_conv;
28158 }
28159
28160 void  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_free(int64_t _res) {
28161         if (!ptr_is_owned(_res)) return;
28162         void* _res_ptr = untag_ptr(_res);
28163         CHECK_ACCESS(_res_ptr);
28164         LDKCResult_PayeePubKeySecp256k1ErrorZ _res_conv = *(LDKCResult_PayeePubKeySecp256k1ErrorZ*)(_res_ptr);
28165         FREE(untag_ptr(_res));
28166         CResult_PayeePubKeySecp256k1ErrorZ_free(_res_conv);
28167 }
28168
28169 static inline uint64_t CResult_PayeePubKeySecp256k1ErrorZ_clone_ptr(LDKCResult_PayeePubKeySecp256k1ErrorZ *NONNULL_PTR arg) {
28170         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28171         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_clone(arg);
28172         return tag_ptr(ret_conv, true);
28173 }
28174 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_clone_ptr(int64_t arg) {
28175         LDKCResult_PayeePubKeySecp256k1ErrorZ* arg_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(arg);
28176         int64_t ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_clone_ptr(arg_conv);
28177         return ret_conv;
28178 }
28179
28180 int64_t  CS_LDK_CResult_PayeePubKeySecp256k1ErrorZ_clone(int64_t orig) {
28181         LDKCResult_PayeePubKeySecp256k1ErrorZ* orig_conv = (LDKCResult_PayeePubKeySecp256k1ErrorZ*)untag_ptr(orig);
28182         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
28183         *ret_conv = CResult_PayeePubKeySecp256k1ErrorZ_clone(orig_conv);
28184         return tag_ptr(ret_conv, true);
28185 }
28186
28187 void  CS_LDK_CVec_PrivateRouteZ_free(int64_tArray _res) {
28188         LDKCVec_PrivateRouteZ _res_constr;
28189         _res_constr.datalen = _res->arr_len;
28190         if (_res_constr.datalen > 0)
28191                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
28192         else
28193                 _res_constr.data = NULL;
28194         int64_t* _res_vals = _res->elems;
28195         for (size_t o = 0; o < _res_constr.datalen; o++) {
28196                 int64_t _res_conv_14 = _res_vals[o];
28197                 LDKPrivateRoute _res_conv_14_conv;
28198                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
28199                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
28200                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
28201                 _res_constr.data[o] = _res_conv_14_conv;
28202         }
28203         FREE(_res);
28204         CVec_PrivateRouteZ_free(_res_constr);
28205 }
28206
28207 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_ok(int64_t o) {
28208         LDKPositiveTimestamp o_conv;
28209         o_conv.inner = untag_ptr(o);
28210         o_conv.is_owned = ptr_is_owned(o);
28211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28212         o_conv = PositiveTimestamp_clone(&o_conv);
28213         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28214         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
28215         return tag_ptr(ret_conv, true);
28216 }
28217
28218 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_err(int32_t e) {
28219         LDKCreationError e_conv = LDKCreationError_from_cs(e);
28220         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28221         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
28222         return tag_ptr(ret_conv, true);
28223 }
28224
28225 jboolean  CS_LDK_CResult_PositiveTimestampCreationErrorZ_is_ok(int64_t o) {
28226         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
28227         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
28228         return ret_conv;
28229 }
28230
28231 void  CS_LDK_CResult_PositiveTimestampCreationErrorZ_free(int64_t _res) {
28232         if (!ptr_is_owned(_res)) return;
28233         void* _res_ptr = untag_ptr(_res);
28234         CHECK_ACCESS(_res_ptr);
28235         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
28236         FREE(untag_ptr(_res));
28237         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
28238 }
28239
28240 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
28241         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28242         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
28243         return tag_ptr(ret_conv, true);
28244 }
28245 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_clone_ptr(int64_t arg) {
28246         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
28247         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
28248         return ret_conv;
28249 }
28250
28251 int64_t  CS_LDK_CResult_PositiveTimestampCreationErrorZ_clone(int64_t orig) {
28252         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
28253         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
28254         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
28255         return tag_ptr(ret_conv, true);
28256 }
28257
28258 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_ok() {
28259         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28260         *ret_conv = CResult_NoneBolt11SemanticErrorZ_ok();
28261         return tag_ptr(ret_conv, true);
28262 }
28263
28264 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_err(int32_t e) {
28265         LDKBolt11SemanticError e_conv = LDKBolt11SemanticError_from_cs(e);
28266         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28267         *ret_conv = CResult_NoneBolt11SemanticErrorZ_err(e_conv);
28268         return tag_ptr(ret_conv, true);
28269 }
28270
28271 jboolean  CS_LDK_CResult_NoneBolt11SemanticErrorZ_is_ok(int64_t o) {
28272         LDKCResult_NoneBolt11SemanticErrorZ* o_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(o);
28273         jboolean ret_conv = CResult_NoneBolt11SemanticErrorZ_is_ok(o_conv);
28274         return ret_conv;
28275 }
28276
28277 void  CS_LDK_CResult_NoneBolt11SemanticErrorZ_free(int64_t _res) {
28278         if (!ptr_is_owned(_res)) return;
28279         void* _res_ptr = untag_ptr(_res);
28280         CHECK_ACCESS(_res_ptr);
28281         LDKCResult_NoneBolt11SemanticErrorZ _res_conv = *(LDKCResult_NoneBolt11SemanticErrorZ*)(_res_ptr);
28282         FREE(untag_ptr(_res));
28283         CResult_NoneBolt11SemanticErrorZ_free(_res_conv);
28284 }
28285
28286 static inline uint64_t CResult_NoneBolt11SemanticErrorZ_clone_ptr(LDKCResult_NoneBolt11SemanticErrorZ *NONNULL_PTR arg) {
28287         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28288         *ret_conv = CResult_NoneBolt11SemanticErrorZ_clone(arg);
28289         return tag_ptr(ret_conv, true);
28290 }
28291 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_clone_ptr(int64_t arg) {
28292         LDKCResult_NoneBolt11SemanticErrorZ* arg_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(arg);
28293         int64_t ret_conv = CResult_NoneBolt11SemanticErrorZ_clone_ptr(arg_conv);
28294         return ret_conv;
28295 }
28296
28297 int64_t  CS_LDK_CResult_NoneBolt11SemanticErrorZ_clone(int64_t orig) {
28298         LDKCResult_NoneBolt11SemanticErrorZ* orig_conv = (LDKCResult_NoneBolt11SemanticErrorZ*)untag_ptr(orig);
28299         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
28300         *ret_conv = CResult_NoneBolt11SemanticErrorZ_clone(orig_conv);
28301         return tag_ptr(ret_conv, true);
28302 }
28303
28304 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(int64_t o) {
28305         LDKBolt11Invoice o_conv;
28306         o_conv.inner = untag_ptr(o);
28307         o_conv.is_owned = ptr_is_owned(o);
28308         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28309         o_conv = Bolt11Invoice_clone(&o_conv);
28310         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28311         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_ok(o_conv);
28312         return tag_ptr(ret_conv, true);
28313 }
28314
28315 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(int32_t e) {
28316         LDKBolt11SemanticError e_conv = LDKBolt11SemanticError_from_cs(e);
28317         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28318         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_err(e_conv);
28319         return tag_ptr(ret_conv, true);
28320 }
28321
28322 jboolean  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(int64_t o) {
28323         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* o_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(o);
28324         jboolean ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_is_ok(o_conv);
28325         return ret_conv;
28326 }
28327
28328 void  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(int64_t _res) {
28329         if (!ptr_is_owned(_res)) return;
28330         void* _res_ptr = untag_ptr(_res);
28331         CHECK_ACCESS(_res_ptr);
28332         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ _res_conv = *(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)(_res_ptr);
28333         FREE(untag_ptr(_res));
28334         CResult_Bolt11InvoiceBolt11SemanticErrorZ_free(_res_conv);
28335 }
28336
28337 static inline uint64_t CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone_ptr(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ *NONNULL_PTR arg) {
28338         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28339         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(arg);
28340         return tag_ptr(ret_conv, true);
28341 }
28342 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone_ptr(int64_t arg) {
28343         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* arg_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(arg);
28344         int64_t ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone_ptr(arg_conv);
28345         return ret_conv;
28346 }
28347
28348 int64_t  CS_LDK_CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(int64_t orig) {
28349         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* orig_conv = (LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ*)untag_ptr(orig);
28350         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
28351         *ret_conv = CResult_Bolt11InvoiceBolt11SemanticErrorZ_clone(orig_conv);
28352         return tag_ptr(ret_conv, true);
28353 }
28354
28355 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_ok(int64_t o) {
28356         LDKDescription o_conv;
28357         o_conv.inner = untag_ptr(o);
28358         o_conv.is_owned = ptr_is_owned(o);
28359         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28360         o_conv = Description_clone(&o_conv);
28361         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28362         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
28363         return tag_ptr(ret_conv, true);
28364 }
28365
28366 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_err(int32_t e) {
28367         LDKCreationError e_conv = LDKCreationError_from_cs(e);
28368         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28369         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
28370         return tag_ptr(ret_conv, true);
28371 }
28372
28373 jboolean  CS_LDK_CResult_DescriptionCreationErrorZ_is_ok(int64_t o) {
28374         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
28375         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
28376         return ret_conv;
28377 }
28378
28379 void  CS_LDK_CResult_DescriptionCreationErrorZ_free(int64_t _res) {
28380         if (!ptr_is_owned(_res)) return;
28381         void* _res_ptr = untag_ptr(_res);
28382         CHECK_ACCESS(_res_ptr);
28383         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
28384         FREE(untag_ptr(_res));
28385         CResult_DescriptionCreationErrorZ_free(_res_conv);
28386 }
28387
28388 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
28389         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28390         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
28391         return tag_ptr(ret_conv, true);
28392 }
28393 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_clone_ptr(int64_t arg) {
28394         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
28395         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
28396         return ret_conv;
28397 }
28398
28399 int64_t  CS_LDK_CResult_DescriptionCreationErrorZ_clone(int64_t orig) {
28400         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
28401         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
28402         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
28403         return tag_ptr(ret_conv, true);
28404 }
28405
28406 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_ok(int64_t o) {
28407         LDKPrivateRoute o_conv;
28408         o_conv.inner = untag_ptr(o);
28409         o_conv.is_owned = ptr_is_owned(o);
28410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28411         o_conv = PrivateRoute_clone(&o_conv);
28412         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28413         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
28414         return tag_ptr(ret_conv, true);
28415 }
28416
28417 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_err(int32_t e) {
28418         LDKCreationError e_conv = LDKCreationError_from_cs(e);
28419         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28420         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
28421         return tag_ptr(ret_conv, true);
28422 }
28423
28424 jboolean  CS_LDK_CResult_PrivateRouteCreationErrorZ_is_ok(int64_t o) {
28425         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
28426         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
28427         return ret_conv;
28428 }
28429
28430 void  CS_LDK_CResult_PrivateRouteCreationErrorZ_free(int64_t _res) {
28431         if (!ptr_is_owned(_res)) return;
28432         void* _res_ptr = untag_ptr(_res);
28433         CHECK_ACCESS(_res_ptr);
28434         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
28435         FREE(untag_ptr(_res));
28436         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
28437 }
28438
28439 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
28440         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28441         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
28442         return tag_ptr(ret_conv, true);
28443 }
28444 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_clone_ptr(int64_t arg) {
28445         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
28446         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
28447         return ret_conv;
28448 }
28449
28450 int64_t  CS_LDK_CResult_PrivateRouteCreationErrorZ_clone(int64_t orig) {
28451         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
28452         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
28453         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
28454         return tag_ptr(ret_conv, true);
28455 }
28456
28457 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_ok(int64_t o) {
28458         LDKOutPoint o_conv;
28459         o_conv.inner = untag_ptr(o);
28460         o_conv.is_owned = ptr_is_owned(o);
28461         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28462         o_conv = OutPoint_clone(&o_conv);
28463         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28464         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
28465         return tag_ptr(ret_conv, true);
28466 }
28467
28468 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_err(int64_t e) {
28469         void* e_ptr = untag_ptr(e);
28470         CHECK_ACCESS(e_ptr);
28471         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28472         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28473         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28474         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
28475         return tag_ptr(ret_conv, true);
28476 }
28477
28478 jboolean  CS_LDK_CResult_OutPointDecodeErrorZ_is_ok(int64_t o) {
28479         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
28480         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
28481         return ret_conv;
28482 }
28483
28484 void  CS_LDK_CResult_OutPointDecodeErrorZ_free(int64_t _res) {
28485         if (!ptr_is_owned(_res)) return;
28486         void* _res_ptr = untag_ptr(_res);
28487         CHECK_ACCESS(_res_ptr);
28488         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
28489         FREE(untag_ptr(_res));
28490         CResult_OutPointDecodeErrorZ_free(_res_conv);
28491 }
28492
28493 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
28494         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28495         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
28496         return tag_ptr(ret_conv, true);
28497 }
28498 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_clone_ptr(int64_t arg) {
28499         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
28500         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
28501         return ret_conv;
28502 }
28503
28504 int64_t  CS_LDK_CResult_OutPointDecodeErrorZ_clone(int64_t orig) {
28505         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
28506         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28507         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
28508         return tag_ptr(ret_conv, true);
28509 }
28510
28511 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_ok(int64_t o) {
28512         LDKBigSize o_conv;
28513         o_conv.inner = untag_ptr(o);
28514         o_conv.is_owned = ptr_is_owned(o);
28515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28516         o_conv = BigSize_clone(&o_conv);
28517         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28518         *ret_conv = CResult_BigSizeDecodeErrorZ_ok(o_conv);
28519         return tag_ptr(ret_conv, true);
28520 }
28521
28522 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_err(int64_t e) {
28523         void* e_ptr = untag_ptr(e);
28524         CHECK_ACCESS(e_ptr);
28525         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28526         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28527         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28528         *ret_conv = CResult_BigSizeDecodeErrorZ_err(e_conv);
28529         return tag_ptr(ret_conv, true);
28530 }
28531
28532 jboolean  CS_LDK_CResult_BigSizeDecodeErrorZ_is_ok(int64_t o) {
28533         LDKCResult_BigSizeDecodeErrorZ* o_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(o);
28534         jboolean ret_conv = CResult_BigSizeDecodeErrorZ_is_ok(o_conv);
28535         return ret_conv;
28536 }
28537
28538 void  CS_LDK_CResult_BigSizeDecodeErrorZ_free(int64_t _res) {
28539         if (!ptr_is_owned(_res)) return;
28540         void* _res_ptr = untag_ptr(_res);
28541         CHECK_ACCESS(_res_ptr);
28542         LDKCResult_BigSizeDecodeErrorZ _res_conv = *(LDKCResult_BigSizeDecodeErrorZ*)(_res_ptr);
28543         FREE(untag_ptr(_res));
28544         CResult_BigSizeDecodeErrorZ_free(_res_conv);
28545 }
28546
28547 static inline uint64_t CResult_BigSizeDecodeErrorZ_clone_ptr(LDKCResult_BigSizeDecodeErrorZ *NONNULL_PTR arg) {
28548         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28549         *ret_conv = CResult_BigSizeDecodeErrorZ_clone(arg);
28550         return tag_ptr(ret_conv, true);
28551 }
28552 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_clone_ptr(int64_t arg) {
28553         LDKCResult_BigSizeDecodeErrorZ* arg_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(arg);
28554         int64_t ret_conv = CResult_BigSizeDecodeErrorZ_clone_ptr(arg_conv);
28555         return ret_conv;
28556 }
28557
28558 int64_t  CS_LDK_CResult_BigSizeDecodeErrorZ_clone(int64_t orig) {
28559         LDKCResult_BigSizeDecodeErrorZ* orig_conv = (LDKCResult_BigSizeDecodeErrorZ*)untag_ptr(orig);
28560         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
28561         *ret_conv = CResult_BigSizeDecodeErrorZ_clone(orig_conv);
28562         return tag_ptr(ret_conv, true);
28563 }
28564
28565 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_ok(int64_t o) {
28566         LDKHostname o_conv;
28567         o_conv.inner = untag_ptr(o);
28568         o_conv.is_owned = ptr_is_owned(o);
28569         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28570         o_conv = Hostname_clone(&o_conv);
28571         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28572         *ret_conv = CResult_HostnameDecodeErrorZ_ok(o_conv);
28573         return tag_ptr(ret_conv, true);
28574 }
28575
28576 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_err(int64_t e) {
28577         void* e_ptr = untag_ptr(e);
28578         CHECK_ACCESS(e_ptr);
28579         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28580         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28581         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28582         *ret_conv = CResult_HostnameDecodeErrorZ_err(e_conv);
28583         return tag_ptr(ret_conv, true);
28584 }
28585
28586 jboolean  CS_LDK_CResult_HostnameDecodeErrorZ_is_ok(int64_t o) {
28587         LDKCResult_HostnameDecodeErrorZ* o_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(o);
28588         jboolean ret_conv = CResult_HostnameDecodeErrorZ_is_ok(o_conv);
28589         return ret_conv;
28590 }
28591
28592 void  CS_LDK_CResult_HostnameDecodeErrorZ_free(int64_t _res) {
28593         if (!ptr_is_owned(_res)) return;
28594         void* _res_ptr = untag_ptr(_res);
28595         CHECK_ACCESS(_res_ptr);
28596         LDKCResult_HostnameDecodeErrorZ _res_conv = *(LDKCResult_HostnameDecodeErrorZ*)(_res_ptr);
28597         FREE(untag_ptr(_res));
28598         CResult_HostnameDecodeErrorZ_free(_res_conv);
28599 }
28600
28601 static inline uint64_t CResult_HostnameDecodeErrorZ_clone_ptr(LDKCResult_HostnameDecodeErrorZ *NONNULL_PTR arg) {
28602         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28603         *ret_conv = CResult_HostnameDecodeErrorZ_clone(arg);
28604         return tag_ptr(ret_conv, true);
28605 }
28606 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_clone_ptr(int64_t arg) {
28607         LDKCResult_HostnameDecodeErrorZ* arg_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(arg);
28608         int64_t ret_conv = CResult_HostnameDecodeErrorZ_clone_ptr(arg_conv);
28609         return ret_conv;
28610 }
28611
28612 int64_t  CS_LDK_CResult_HostnameDecodeErrorZ_clone(int64_t orig) {
28613         LDKCResult_HostnameDecodeErrorZ* orig_conv = (LDKCResult_HostnameDecodeErrorZ*)untag_ptr(orig);
28614         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
28615         *ret_conv = CResult_HostnameDecodeErrorZ_clone(orig_conv);
28616         return tag_ptr(ret_conv, true);
28617 }
28618
28619 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_ok(int64_t o) {
28620         LDKTransactionU16LenLimited o_conv;
28621         o_conv.inner = untag_ptr(o);
28622         o_conv.is_owned = ptr_is_owned(o);
28623         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28624         o_conv = TransactionU16LenLimited_clone(&o_conv);
28625         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28626         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_ok(o_conv);
28627         return tag_ptr(ret_conv, true);
28628 }
28629
28630 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_err() {
28631         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28632         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_err();
28633         return tag_ptr(ret_conv, true);
28634 }
28635
28636 jboolean  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_is_ok(int64_t o) {
28637         LDKCResult_TransactionU16LenLimitedNoneZ* o_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(o);
28638         jboolean ret_conv = CResult_TransactionU16LenLimitedNoneZ_is_ok(o_conv);
28639         return ret_conv;
28640 }
28641
28642 void  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_free(int64_t _res) {
28643         if (!ptr_is_owned(_res)) return;
28644         void* _res_ptr = untag_ptr(_res);
28645         CHECK_ACCESS(_res_ptr);
28646         LDKCResult_TransactionU16LenLimitedNoneZ _res_conv = *(LDKCResult_TransactionU16LenLimitedNoneZ*)(_res_ptr);
28647         FREE(untag_ptr(_res));
28648         CResult_TransactionU16LenLimitedNoneZ_free(_res_conv);
28649 }
28650
28651 static inline uint64_t CResult_TransactionU16LenLimitedNoneZ_clone_ptr(LDKCResult_TransactionU16LenLimitedNoneZ *NONNULL_PTR arg) {
28652         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28653         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_clone(arg);
28654         return tag_ptr(ret_conv, true);
28655 }
28656 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_clone_ptr(int64_t arg) {
28657         LDKCResult_TransactionU16LenLimitedNoneZ* arg_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(arg);
28658         int64_t ret_conv = CResult_TransactionU16LenLimitedNoneZ_clone_ptr(arg_conv);
28659         return ret_conv;
28660 }
28661
28662 int64_t  CS_LDK_CResult_TransactionU16LenLimitedNoneZ_clone(int64_t orig) {
28663         LDKCResult_TransactionU16LenLimitedNoneZ* orig_conv = (LDKCResult_TransactionU16LenLimitedNoneZ*)untag_ptr(orig);
28664         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
28665         *ret_conv = CResult_TransactionU16LenLimitedNoneZ_clone(orig_conv);
28666         return tag_ptr(ret_conv, true);
28667 }
28668
28669 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_ok(int64_t o) {
28670         LDKTransactionU16LenLimited o_conv;
28671         o_conv.inner = untag_ptr(o);
28672         o_conv.is_owned = ptr_is_owned(o);
28673         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28674         o_conv = TransactionU16LenLimited_clone(&o_conv);
28675         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28676         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_ok(o_conv);
28677         return tag_ptr(ret_conv, true);
28678 }
28679
28680 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_err(int64_t e) {
28681         void* e_ptr = untag_ptr(e);
28682         CHECK_ACCESS(e_ptr);
28683         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28684         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28685         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28686         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_err(e_conv);
28687         return tag_ptr(ret_conv, true);
28688 }
28689
28690 jboolean  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(int64_t o) {
28691         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* o_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(o);
28692         jboolean ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_is_ok(o_conv);
28693         return ret_conv;
28694 }
28695
28696 void  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_free(int64_t _res) {
28697         if (!ptr_is_owned(_res)) return;
28698         void* _res_ptr = untag_ptr(_res);
28699         CHECK_ACCESS(_res_ptr);
28700         LDKCResult_TransactionU16LenLimitedDecodeErrorZ _res_conv = *(LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)(_res_ptr);
28701         FREE(untag_ptr(_res));
28702         CResult_TransactionU16LenLimitedDecodeErrorZ_free(_res_conv);
28703 }
28704
28705 static inline uint64_t CResult_TransactionU16LenLimitedDecodeErrorZ_clone_ptr(LDKCResult_TransactionU16LenLimitedDecodeErrorZ *NONNULL_PTR arg) {
28706         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28707         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_clone(arg);
28708         return tag_ptr(ret_conv, true);
28709 }
28710 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_clone_ptr(int64_t arg) {
28711         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* arg_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(arg);
28712         int64_t ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_clone_ptr(arg_conv);
28713         return ret_conv;
28714 }
28715
28716 int64_t  CS_LDK_CResult_TransactionU16LenLimitedDecodeErrorZ_clone(int64_t orig) {
28717         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* orig_conv = (LDKCResult_TransactionU16LenLimitedDecodeErrorZ*)untag_ptr(orig);
28718         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
28719         *ret_conv = CResult_TransactionU16LenLimitedDecodeErrorZ_clone(orig_conv);
28720         return tag_ptr(ret_conv, true);
28721 }
28722
28723 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_ok(int64_t o) {
28724         LDKUntrustedString o_conv;
28725         o_conv.inner = untag_ptr(o);
28726         o_conv.is_owned = ptr_is_owned(o);
28727         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28728         o_conv = UntrustedString_clone(&o_conv);
28729         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28730         *ret_conv = CResult_UntrustedStringDecodeErrorZ_ok(o_conv);
28731         return tag_ptr(ret_conv, true);
28732 }
28733
28734 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_err(int64_t e) {
28735         void* e_ptr = untag_ptr(e);
28736         CHECK_ACCESS(e_ptr);
28737         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28738         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28739         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28740         *ret_conv = CResult_UntrustedStringDecodeErrorZ_err(e_conv);
28741         return tag_ptr(ret_conv, true);
28742 }
28743
28744 jboolean  CS_LDK_CResult_UntrustedStringDecodeErrorZ_is_ok(int64_t o) {
28745         LDKCResult_UntrustedStringDecodeErrorZ* o_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(o);
28746         jboolean ret_conv = CResult_UntrustedStringDecodeErrorZ_is_ok(o_conv);
28747         return ret_conv;
28748 }
28749
28750 void  CS_LDK_CResult_UntrustedStringDecodeErrorZ_free(int64_t _res) {
28751         if (!ptr_is_owned(_res)) return;
28752         void* _res_ptr = untag_ptr(_res);
28753         CHECK_ACCESS(_res_ptr);
28754         LDKCResult_UntrustedStringDecodeErrorZ _res_conv = *(LDKCResult_UntrustedStringDecodeErrorZ*)(_res_ptr);
28755         FREE(untag_ptr(_res));
28756         CResult_UntrustedStringDecodeErrorZ_free(_res_conv);
28757 }
28758
28759 static inline uint64_t CResult_UntrustedStringDecodeErrorZ_clone_ptr(LDKCResult_UntrustedStringDecodeErrorZ *NONNULL_PTR arg) {
28760         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28761         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(arg);
28762         return tag_ptr(ret_conv, true);
28763 }
28764 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_clone_ptr(int64_t arg) {
28765         LDKCResult_UntrustedStringDecodeErrorZ* arg_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(arg);
28766         int64_t ret_conv = CResult_UntrustedStringDecodeErrorZ_clone_ptr(arg_conv);
28767         return ret_conv;
28768 }
28769
28770 int64_t  CS_LDK_CResult_UntrustedStringDecodeErrorZ_clone(int64_t orig) {
28771         LDKCResult_UntrustedStringDecodeErrorZ* orig_conv = (LDKCResult_UntrustedStringDecodeErrorZ*)untag_ptr(orig);
28772         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
28773         *ret_conv = CResult_UntrustedStringDecodeErrorZ_clone(orig_conv);
28774         return tag_ptr(ret_conv, true);
28775 }
28776
28777 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_ok(int64_t o) {
28778         LDKReceiveTlvs o_conv;
28779         o_conv.inner = untag_ptr(o);
28780         o_conv.is_owned = ptr_is_owned(o);
28781         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28782         o_conv = ReceiveTlvs_clone(&o_conv);
28783         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28784         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_ok(o_conv);
28785         return tag_ptr(ret_conv, true);
28786 }
28787
28788 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_err(int64_t e) {
28789         void* e_ptr = untag_ptr(e);
28790         CHECK_ACCESS(e_ptr);
28791         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28792         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28793         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28794         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_err(e_conv);
28795         return tag_ptr(ret_conv, true);
28796 }
28797
28798 jboolean  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_is_ok(int64_t o) {
28799         LDKCResult_ReceiveTlvsDecodeErrorZ* o_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(o);
28800         jboolean ret_conv = CResult_ReceiveTlvsDecodeErrorZ_is_ok(o_conv);
28801         return ret_conv;
28802 }
28803
28804 void  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_free(int64_t _res) {
28805         if (!ptr_is_owned(_res)) return;
28806         void* _res_ptr = untag_ptr(_res);
28807         CHECK_ACCESS(_res_ptr);
28808         LDKCResult_ReceiveTlvsDecodeErrorZ _res_conv = *(LDKCResult_ReceiveTlvsDecodeErrorZ*)(_res_ptr);
28809         FREE(untag_ptr(_res));
28810         CResult_ReceiveTlvsDecodeErrorZ_free(_res_conv);
28811 }
28812
28813 static inline uint64_t CResult_ReceiveTlvsDecodeErrorZ_clone_ptr(LDKCResult_ReceiveTlvsDecodeErrorZ *NONNULL_PTR arg) {
28814         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28815         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_clone(arg);
28816         return tag_ptr(ret_conv, true);
28817 }
28818 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_clone_ptr(int64_t arg) {
28819         LDKCResult_ReceiveTlvsDecodeErrorZ* arg_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(arg);
28820         int64_t ret_conv = CResult_ReceiveTlvsDecodeErrorZ_clone_ptr(arg_conv);
28821         return ret_conv;
28822 }
28823
28824 int64_t  CS_LDK_CResult_ReceiveTlvsDecodeErrorZ_clone(int64_t orig) {
28825         LDKCResult_ReceiveTlvsDecodeErrorZ* orig_conv = (LDKCResult_ReceiveTlvsDecodeErrorZ*)untag_ptr(orig);
28826         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
28827         *ret_conv = CResult_ReceiveTlvsDecodeErrorZ_clone(orig_conv);
28828         return tag_ptr(ret_conv, true);
28829 }
28830
28831 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_ok(int64_t o) {
28832         LDKPaymentRelay o_conv;
28833         o_conv.inner = untag_ptr(o);
28834         o_conv.is_owned = ptr_is_owned(o);
28835         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28836         o_conv = PaymentRelay_clone(&o_conv);
28837         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28838         *ret_conv = CResult_PaymentRelayDecodeErrorZ_ok(o_conv);
28839         return tag_ptr(ret_conv, true);
28840 }
28841
28842 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_err(int64_t e) {
28843         void* e_ptr = untag_ptr(e);
28844         CHECK_ACCESS(e_ptr);
28845         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28846         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28847         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28848         *ret_conv = CResult_PaymentRelayDecodeErrorZ_err(e_conv);
28849         return tag_ptr(ret_conv, true);
28850 }
28851
28852 jboolean  CS_LDK_CResult_PaymentRelayDecodeErrorZ_is_ok(int64_t o) {
28853         LDKCResult_PaymentRelayDecodeErrorZ* o_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(o);
28854         jboolean ret_conv = CResult_PaymentRelayDecodeErrorZ_is_ok(o_conv);
28855         return ret_conv;
28856 }
28857
28858 void  CS_LDK_CResult_PaymentRelayDecodeErrorZ_free(int64_t _res) {
28859         if (!ptr_is_owned(_res)) return;
28860         void* _res_ptr = untag_ptr(_res);
28861         CHECK_ACCESS(_res_ptr);
28862         LDKCResult_PaymentRelayDecodeErrorZ _res_conv = *(LDKCResult_PaymentRelayDecodeErrorZ*)(_res_ptr);
28863         FREE(untag_ptr(_res));
28864         CResult_PaymentRelayDecodeErrorZ_free(_res_conv);
28865 }
28866
28867 static inline uint64_t CResult_PaymentRelayDecodeErrorZ_clone_ptr(LDKCResult_PaymentRelayDecodeErrorZ *NONNULL_PTR arg) {
28868         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28869         *ret_conv = CResult_PaymentRelayDecodeErrorZ_clone(arg);
28870         return tag_ptr(ret_conv, true);
28871 }
28872 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_clone_ptr(int64_t arg) {
28873         LDKCResult_PaymentRelayDecodeErrorZ* arg_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(arg);
28874         int64_t ret_conv = CResult_PaymentRelayDecodeErrorZ_clone_ptr(arg_conv);
28875         return ret_conv;
28876 }
28877
28878 int64_t  CS_LDK_CResult_PaymentRelayDecodeErrorZ_clone(int64_t orig) {
28879         LDKCResult_PaymentRelayDecodeErrorZ* orig_conv = (LDKCResult_PaymentRelayDecodeErrorZ*)untag_ptr(orig);
28880         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
28881         *ret_conv = CResult_PaymentRelayDecodeErrorZ_clone(orig_conv);
28882         return tag_ptr(ret_conv, true);
28883 }
28884
28885 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_ok(int64_t o) {
28886         LDKPaymentConstraints o_conv;
28887         o_conv.inner = untag_ptr(o);
28888         o_conv.is_owned = ptr_is_owned(o);
28889         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28890         o_conv = PaymentConstraints_clone(&o_conv);
28891         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28892         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_ok(o_conv);
28893         return tag_ptr(ret_conv, true);
28894 }
28895
28896 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_err(int64_t e) {
28897         void* e_ptr = untag_ptr(e);
28898         CHECK_ACCESS(e_ptr);
28899         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
28900         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
28901         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28902         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_err(e_conv);
28903         return tag_ptr(ret_conv, true);
28904 }
28905
28906 jboolean  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_is_ok(int64_t o) {
28907         LDKCResult_PaymentConstraintsDecodeErrorZ* o_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(o);
28908         jboolean ret_conv = CResult_PaymentConstraintsDecodeErrorZ_is_ok(o_conv);
28909         return ret_conv;
28910 }
28911
28912 void  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_free(int64_t _res) {
28913         if (!ptr_is_owned(_res)) return;
28914         void* _res_ptr = untag_ptr(_res);
28915         CHECK_ACCESS(_res_ptr);
28916         LDKCResult_PaymentConstraintsDecodeErrorZ _res_conv = *(LDKCResult_PaymentConstraintsDecodeErrorZ*)(_res_ptr);
28917         FREE(untag_ptr(_res));
28918         CResult_PaymentConstraintsDecodeErrorZ_free(_res_conv);
28919 }
28920
28921 static inline uint64_t CResult_PaymentConstraintsDecodeErrorZ_clone_ptr(LDKCResult_PaymentConstraintsDecodeErrorZ *NONNULL_PTR arg) {
28922         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28923         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_clone(arg);
28924         return tag_ptr(ret_conv, true);
28925 }
28926 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_clone_ptr(int64_t arg) {
28927         LDKCResult_PaymentConstraintsDecodeErrorZ* arg_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(arg);
28928         int64_t ret_conv = CResult_PaymentConstraintsDecodeErrorZ_clone_ptr(arg_conv);
28929         return ret_conv;
28930 }
28931
28932 int64_t  CS_LDK_CResult_PaymentConstraintsDecodeErrorZ_clone(int64_t orig) {
28933         LDKCResult_PaymentConstraintsDecodeErrorZ* orig_conv = (LDKCResult_PaymentConstraintsDecodeErrorZ*)untag_ptr(orig);
28934         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
28935         *ret_conv = CResult_PaymentConstraintsDecodeErrorZ_clone(orig_conv);
28936         return tag_ptr(ret_conv, true);
28937 }
28938
28939 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_ok(int8_tArray o) {
28940         LDKThirtyTwoBytes o_ref;
28941         CHECK(o->arr_len == 32);
28942         memcpy(o_ref.data, o->elems, 32); FREE(o);
28943         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28944         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_ok(o_ref);
28945         return tag_ptr(ret_conv, true);
28946 }
28947
28948 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_err(int64_t e) {
28949         void* e_ptr = untag_ptr(e);
28950         CHECK_ACCESS(e_ptr);
28951         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
28952         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
28953         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28954         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_err(e_conv);
28955         return tag_ptr(ret_conv, true);
28956 }
28957
28958 jboolean  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_is_ok(int64_t o) {
28959         LDKCResult_ThirtyTwoBytesPaymentErrorZ* o_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(o);
28960         jboolean ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_is_ok(o_conv);
28961         return ret_conv;
28962 }
28963
28964 void  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_free(int64_t _res) {
28965         if (!ptr_is_owned(_res)) return;
28966         void* _res_ptr = untag_ptr(_res);
28967         CHECK_ACCESS(_res_ptr);
28968         LDKCResult_ThirtyTwoBytesPaymentErrorZ _res_conv = *(LDKCResult_ThirtyTwoBytesPaymentErrorZ*)(_res_ptr);
28969         FREE(untag_ptr(_res));
28970         CResult_ThirtyTwoBytesPaymentErrorZ_free(_res_conv);
28971 }
28972
28973 static inline uint64_t CResult_ThirtyTwoBytesPaymentErrorZ_clone_ptr(LDKCResult_ThirtyTwoBytesPaymentErrorZ *NONNULL_PTR arg) {
28974         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28975         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_clone(arg);
28976         return tag_ptr(ret_conv, true);
28977 }
28978 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_clone_ptr(int64_t arg) {
28979         LDKCResult_ThirtyTwoBytesPaymentErrorZ* arg_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(arg);
28980         int64_t ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_clone_ptr(arg_conv);
28981         return ret_conv;
28982 }
28983
28984 int64_t  CS_LDK_CResult_ThirtyTwoBytesPaymentErrorZ_clone(int64_t orig) {
28985         LDKCResult_ThirtyTwoBytesPaymentErrorZ* orig_conv = (LDKCResult_ThirtyTwoBytesPaymentErrorZ*)untag_ptr(orig);
28986         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
28987         *ret_conv = CResult_ThirtyTwoBytesPaymentErrorZ_clone(orig_conv);
28988         return tag_ptr(ret_conv, true);
28989 }
28990
28991 int64_t  CS_LDK_CResult_NonePaymentErrorZ_ok() {
28992         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
28993         *ret_conv = CResult_NonePaymentErrorZ_ok();
28994         return tag_ptr(ret_conv, true);
28995 }
28996
28997 int64_t  CS_LDK_CResult_NonePaymentErrorZ_err(int64_t e) {
28998         void* e_ptr = untag_ptr(e);
28999         CHECK_ACCESS(e_ptr);
29000         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
29001         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
29002         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
29003         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
29004         return tag_ptr(ret_conv, true);
29005 }
29006
29007 jboolean  CS_LDK_CResult_NonePaymentErrorZ_is_ok(int64_t o) {
29008         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
29009         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
29010         return ret_conv;
29011 }
29012
29013 void  CS_LDK_CResult_NonePaymentErrorZ_free(int64_t _res) {
29014         if (!ptr_is_owned(_res)) return;
29015         void* _res_ptr = untag_ptr(_res);
29016         CHECK_ACCESS(_res_ptr);
29017         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
29018         FREE(untag_ptr(_res));
29019         CResult_NonePaymentErrorZ_free(_res_conv);
29020 }
29021
29022 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
29023         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
29024         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
29025         return tag_ptr(ret_conv, true);
29026 }
29027 int64_t  CS_LDK_CResult_NonePaymentErrorZ_clone_ptr(int64_t arg) {
29028         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
29029         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
29030         return ret_conv;
29031 }
29032
29033 int64_t  CS_LDK_CResult_NonePaymentErrorZ_clone(int64_t orig) {
29034         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
29035         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
29036         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
29037         return tag_ptr(ret_conv, true);
29038 }
29039
29040 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_ok(int64_tArray o) {
29041         LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ o_constr;
29042         o_constr.datalen = o->arr_len;
29043         if (o_constr.datalen > 0)
29044                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ), "LDKCVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ Elements");
29045         else
29046                 o_constr.data = NULL;
29047         int64_t* o_vals = o->elems;
29048         for (size_t o = 0; o < o_constr.datalen; o++) {
29049                 int64_t o_conv_40 = o_vals[o];
29050                 void* o_conv_40_ptr = untag_ptr(o_conv_40);
29051                 CHECK_ACCESS(o_conv_40_ptr);
29052                 LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ o_conv_40_conv = *(LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)(o_conv_40_ptr);
29053                 o_conv_40_conv = C2Tuple_ThirtyTwoBytesThirtyTwoBytesZ_clone((LDKC2Tuple_ThirtyTwoBytesThirtyTwoBytesZ*)untag_ptr(o_conv_40));
29054                 o_constr.data[o] = o_conv_40_conv;
29055         }
29056         FREE(o);
29057         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29058         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_ok(o_constr);
29059         return tag_ptr(ret_conv, true);
29060 }
29061
29062 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_err(int64_t e) {
29063         void* e_ptr = untag_ptr(e);
29064         CHECK_ACCESS(e_ptr);
29065         LDKProbingError e_conv = *(LDKProbingError*)(e_ptr);
29066         e_conv = ProbingError_clone((LDKProbingError*)untag_ptr(e));
29067         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29068         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_err(e_conv);
29069         return tag_ptr(ret_conv, true);
29070 }
29071
29072 jboolean  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_is_ok(int64_t o) {
29073         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(o);
29074         jboolean ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_is_ok(o_conv);
29075         return ret_conv;
29076 }
29077
29078 void  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_free(int64_t _res) {
29079         if (!ptr_is_owned(_res)) return;
29080         void* _res_ptr = untag_ptr(_res);
29081         CHECK_ACCESS(_res_ptr);
29082         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)(_res_ptr);
29083         FREE(untag_ptr(_res));
29084         CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_free(_res_conv);
29085 }
29086
29087 static inline uint64_t CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ *NONNULL_PTR arg) {
29088         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29089         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone(arg);
29090         return tag_ptr(ret_conv, true);
29091 }
29092 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone_ptr(int64_t arg) {
29093         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(arg);
29094         int64_t ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone_ptr(arg_conv);
29095         return ret_conv;
29096 }
29097
29098 int64_t  CS_LDK_CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone(int64_t orig) {
29099         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ*)untag_ptr(orig);
29100         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
29101         *ret_conv = CResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ_clone(orig_conv);
29102         return tag_ptr(ret_conv, true);
29103 }
29104
29105 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_ok(jstring o) {
29106         LDKStr o_conv = str_ref_to_owned_c(o);
29107         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29108         *ret_conv = CResult_StrSecp256k1ErrorZ_ok(o_conv);
29109         return tag_ptr(ret_conv, true);
29110 }
29111
29112 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_err(int32_t e) {
29113         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_cs(e);
29114         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29115         *ret_conv = CResult_StrSecp256k1ErrorZ_err(e_conv);
29116         return tag_ptr(ret_conv, true);
29117 }
29118
29119 jboolean  CS_LDK_CResult_StrSecp256k1ErrorZ_is_ok(int64_t o) {
29120         LDKCResult_StrSecp256k1ErrorZ* o_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(o);
29121         jboolean ret_conv = CResult_StrSecp256k1ErrorZ_is_ok(o_conv);
29122         return ret_conv;
29123 }
29124
29125 void  CS_LDK_CResult_StrSecp256k1ErrorZ_free(int64_t _res) {
29126         if (!ptr_is_owned(_res)) return;
29127         void* _res_ptr = untag_ptr(_res);
29128         CHECK_ACCESS(_res_ptr);
29129         LDKCResult_StrSecp256k1ErrorZ _res_conv = *(LDKCResult_StrSecp256k1ErrorZ*)(_res_ptr);
29130         FREE(untag_ptr(_res));
29131         CResult_StrSecp256k1ErrorZ_free(_res_conv);
29132 }
29133
29134 static inline uint64_t CResult_StrSecp256k1ErrorZ_clone_ptr(LDKCResult_StrSecp256k1ErrorZ *NONNULL_PTR arg) {
29135         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29136         *ret_conv = CResult_StrSecp256k1ErrorZ_clone(arg);
29137         return tag_ptr(ret_conv, true);
29138 }
29139 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_clone_ptr(int64_t arg) {
29140         LDKCResult_StrSecp256k1ErrorZ* arg_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(arg);
29141         int64_t ret_conv = CResult_StrSecp256k1ErrorZ_clone_ptr(arg_conv);
29142         return ret_conv;
29143 }
29144
29145 int64_t  CS_LDK_CResult_StrSecp256k1ErrorZ_clone(int64_t orig) {
29146         LDKCResult_StrSecp256k1ErrorZ* orig_conv = (LDKCResult_StrSecp256k1ErrorZ*)untag_ptr(orig);
29147         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
29148         *ret_conv = CResult_StrSecp256k1ErrorZ_clone(orig_conv);
29149         return tag_ptr(ret_conv, true);
29150 }
29151
29152 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_ok(int64_t o) {
29153         void* o_ptr = untag_ptr(o);
29154         CHECK_ACCESS(o_ptr);
29155         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
29156         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
29157         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29158         *ret_conv = CResult_TxOutUtxoLookupErrorZ_ok(o_conv);
29159         return tag_ptr(ret_conv, true);
29160 }
29161
29162 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_err(int32_t e) {
29163         LDKUtxoLookupError e_conv = LDKUtxoLookupError_from_cs(e);
29164         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29165         *ret_conv = CResult_TxOutUtxoLookupErrorZ_err(e_conv);
29166         return tag_ptr(ret_conv, true);
29167 }
29168
29169 jboolean  CS_LDK_CResult_TxOutUtxoLookupErrorZ_is_ok(int64_t o) {
29170         LDKCResult_TxOutUtxoLookupErrorZ* o_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(o);
29171         jboolean ret_conv = CResult_TxOutUtxoLookupErrorZ_is_ok(o_conv);
29172         return ret_conv;
29173 }
29174
29175 void  CS_LDK_CResult_TxOutUtxoLookupErrorZ_free(int64_t _res) {
29176         if (!ptr_is_owned(_res)) return;
29177         void* _res_ptr = untag_ptr(_res);
29178         CHECK_ACCESS(_res_ptr);
29179         LDKCResult_TxOutUtxoLookupErrorZ _res_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(_res_ptr);
29180         FREE(untag_ptr(_res));
29181         CResult_TxOutUtxoLookupErrorZ_free(_res_conv);
29182 }
29183
29184 static inline uint64_t CResult_TxOutUtxoLookupErrorZ_clone_ptr(LDKCResult_TxOutUtxoLookupErrorZ *NONNULL_PTR arg) {
29185         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29186         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(arg);
29187         return tag_ptr(ret_conv, true);
29188 }
29189 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_clone_ptr(int64_t arg) {
29190         LDKCResult_TxOutUtxoLookupErrorZ* arg_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(arg);
29191         int64_t ret_conv = CResult_TxOutUtxoLookupErrorZ_clone_ptr(arg_conv);
29192         return ret_conv;
29193 }
29194
29195 int64_t  CS_LDK_CResult_TxOutUtxoLookupErrorZ_clone(int64_t orig) {
29196         LDKCResult_TxOutUtxoLookupErrorZ* orig_conv = (LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(orig);
29197         LDKCResult_TxOutUtxoLookupErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutUtxoLookupErrorZ), "LDKCResult_TxOutUtxoLookupErrorZ");
29198         *ret_conv = CResult_TxOutUtxoLookupErrorZ_clone(orig_conv);
29199         return tag_ptr(ret_conv, true);
29200 }
29201
29202 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_ok(int64_t o) {
29203         LDKOnionMessagePath o_conv;
29204         o_conv.inner = untag_ptr(o);
29205         o_conv.is_owned = ptr_is_owned(o);
29206         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29207         o_conv = OnionMessagePath_clone(&o_conv);
29208         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29209         *ret_conv = CResult_OnionMessagePathNoneZ_ok(o_conv);
29210         return tag_ptr(ret_conv, true);
29211 }
29212
29213 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_err() {
29214         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29215         *ret_conv = CResult_OnionMessagePathNoneZ_err();
29216         return tag_ptr(ret_conv, true);
29217 }
29218
29219 jboolean  CS_LDK_CResult_OnionMessagePathNoneZ_is_ok(int64_t o) {
29220         LDKCResult_OnionMessagePathNoneZ* o_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(o);
29221         jboolean ret_conv = CResult_OnionMessagePathNoneZ_is_ok(o_conv);
29222         return ret_conv;
29223 }
29224
29225 void  CS_LDK_CResult_OnionMessagePathNoneZ_free(int64_t _res) {
29226         if (!ptr_is_owned(_res)) return;
29227         void* _res_ptr = untag_ptr(_res);
29228         CHECK_ACCESS(_res_ptr);
29229         LDKCResult_OnionMessagePathNoneZ _res_conv = *(LDKCResult_OnionMessagePathNoneZ*)(_res_ptr);
29230         FREE(untag_ptr(_res));
29231         CResult_OnionMessagePathNoneZ_free(_res_conv);
29232 }
29233
29234 static inline uint64_t CResult_OnionMessagePathNoneZ_clone_ptr(LDKCResult_OnionMessagePathNoneZ *NONNULL_PTR arg) {
29235         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29236         *ret_conv = CResult_OnionMessagePathNoneZ_clone(arg);
29237         return tag_ptr(ret_conv, true);
29238 }
29239 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_clone_ptr(int64_t arg) {
29240         LDKCResult_OnionMessagePathNoneZ* arg_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(arg);
29241         int64_t ret_conv = CResult_OnionMessagePathNoneZ_clone_ptr(arg_conv);
29242         return ret_conv;
29243 }
29244
29245 int64_t  CS_LDK_CResult_OnionMessagePathNoneZ_clone(int64_t orig) {
29246         LDKCResult_OnionMessagePathNoneZ* orig_conv = (LDKCResult_OnionMessagePathNoneZ*)untag_ptr(orig);
29247         LDKCResult_OnionMessagePathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessagePathNoneZ), "LDKCResult_OnionMessagePathNoneZ");
29248         *ret_conv = CResult_OnionMessagePathNoneZ_clone(orig_conv);
29249         return tag_ptr(ret_conv, true);
29250 }
29251
29252 static inline uint64_t C2Tuple_PublicKeyOnionMessageZ_clone_ptr(LDKC2Tuple_PublicKeyOnionMessageZ *NONNULL_PTR arg) {
29253         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
29254         *ret_conv = C2Tuple_PublicKeyOnionMessageZ_clone(arg);
29255         return tag_ptr(ret_conv, true);
29256 }
29257 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_clone_ptr(int64_t arg) {
29258         LDKC2Tuple_PublicKeyOnionMessageZ* arg_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(arg);
29259         int64_t ret_conv = C2Tuple_PublicKeyOnionMessageZ_clone_ptr(arg_conv);
29260         return ret_conv;
29261 }
29262
29263 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_clone(int64_t orig) {
29264         LDKC2Tuple_PublicKeyOnionMessageZ* orig_conv = (LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(orig);
29265         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
29266         *ret_conv = C2Tuple_PublicKeyOnionMessageZ_clone(orig_conv);
29267         return tag_ptr(ret_conv, true);
29268 }
29269
29270 int64_t  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_new(int8_tArray a, int64_t b) {
29271         LDKPublicKey a_ref;
29272         CHECK(a->arr_len == 33);
29273         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
29274         LDKOnionMessage b_conv;
29275         b_conv.inner = untag_ptr(b);
29276         b_conv.is_owned = ptr_is_owned(b);
29277         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29278         b_conv = OnionMessage_clone(&b_conv);
29279         LDKC2Tuple_PublicKeyOnionMessageZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyOnionMessageZ), "LDKC2Tuple_PublicKeyOnionMessageZ");
29280         *ret_conv = C2Tuple_PublicKeyOnionMessageZ_new(a_ref, b_conv);
29281         return tag_ptr(ret_conv, true);
29282 }
29283
29284 void  CS_LDK_C2Tuple_PublicKeyOnionMessageZ_free(int64_t _res) {
29285         if (!ptr_is_owned(_res)) return;
29286         void* _res_ptr = untag_ptr(_res);
29287         CHECK_ACCESS(_res_ptr);
29288         LDKC2Tuple_PublicKeyOnionMessageZ _res_conv = *(LDKC2Tuple_PublicKeyOnionMessageZ*)(_res_ptr);
29289         FREE(untag_ptr(_res));
29290         C2Tuple_PublicKeyOnionMessageZ_free(_res_conv);
29291 }
29292
29293 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_ok(int64_t o) {
29294         void* o_ptr = untag_ptr(o);
29295         CHECK_ACCESS(o_ptr);
29296         LDKC2Tuple_PublicKeyOnionMessageZ o_conv = *(LDKC2Tuple_PublicKeyOnionMessageZ*)(o_ptr);
29297         o_conv = C2Tuple_PublicKeyOnionMessageZ_clone((LDKC2Tuple_PublicKeyOnionMessageZ*)untag_ptr(o));
29298         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ), "LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ");
29299         *ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_ok(o_conv);
29300         return tag_ptr(ret_conv, true);
29301 }
29302
29303 int64_t  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_err(int64_t e) {
29304         void* e_ptr = untag_ptr(e);
29305         CHECK_ACCESS(e_ptr);
29306         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
29307         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
29308         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ), "LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ");
29309         *ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_err(e_conv);
29310         return tag_ptr(ret_conv, true);
29311 }
29312
29313 jboolean  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_is_ok(int64_t o) {
29314         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* o_conv = (LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)untag_ptr(o);
29315         jboolean ret_conv = CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_is_ok(o_conv);
29316         return ret_conv;
29317 }
29318
29319 void  CS_LDK_CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_free(int64_t _res) {
29320         if (!ptr_is_owned(_res)) return;
29321         void* _res_ptr = untag_ptr(_res);
29322         CHECK_ACCESS(_res_ptr);
29323         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ _res_conv = *(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ*)(_res_ptr);
29324         FREE(untag_ptr(_res));
29325         CResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ_free(_res_conv);
29326 }
29327
29328 int64_t  CS_LDK_CResult_PeeledOnionNoneZ_ok(int64_t o) {
29329         void* o_ptr = untag_ptr(o);
29330         CHECK_ACCESS(o_ptr);
29331         LDKPeeledOnion o_conv = *(LDKPeeledOnion*)(o_ptr);
29332         o_conv = PeeledOnion_clone((LDKPeeledOnion*)untag_ptr(o));
29333         LDKCResult_PeeledOnionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PeeledOnionNoneZ), "LDKCResult_PeeledOnionNoneZ");
29334         *ret_conv = CResult_PeeledOnionNoneZ_ok(o_conv);
29335         return tag_ptr(ret_conv, true);
29336 }
29337
29338 int64_t  CS_LDK_CResult_PeeledOnionNoneZ_err() {
29339         LDKCResult_PeeledOnionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PeeledOnionNoneZ), "LDKCResult_PeeledOnionNoneZ");
29340         *ret_conv = CResult_PeeledOnionNoneZ_err();
29341         return tag_ptr(ret_conv, true);
29342 }
29343
29344 jboolean  CS_LDK_CResult_PeeledOnionNoneZ_is_ok(int64_t o) {
29345         LDKCResult_PeeledOnionNoneZ* o_conv = (LDKCResult_PeeledOnionNoneZ*)untag_ptr(o);
29346         jboolean ret_conv = CResult_PeeledOnionNoneZ_is_ok(o_conv);
29347         return ret_conv;
29348 }
29349
29350 void  CS_LDK_CResult_PeeledOnionNoneZ_free(int64_t _res) {
29351         if (!ptr_is_owned(_res)) return;
29352         void* _res_ptr = untag_ptr(_res);
29353         CHECK_ACCESS(_res_ptr);
29354         LDKCResult_PeeledOnionNoneZ _res_conv = *(LDKCResult_PeeledOnionNoneZ*)(_res_ptr);
29355         FREE(untag_ptr(_res));
29356         CResult_PeeledOnionNoneZ_free(_res_conv);
29357 }
29358
29359 int64_t  CS_LDK_CResult_NoneSendErrorZ_ok() {
29360         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
29361         *ret_conv = CResult_NoneSendErrorZ_ok();
29362         return tag_ptr(ret_conv, true);
29363 }
29364
29365 int64_t  CS_LDK_CResult_NoneSendErrorZ_err(int64_t e) {
29366         void* e_ptr = untag_ptr(e);
29367         CHECK_ACCESS(e_ptr);
29368         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
29369         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
29370         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
29371         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
29372         return tag_ptr(ret_conv, true);
29373 }
29374
29375 jboolean  CS_LDK_CResult_NoneSendErrorZ_is_ok(int64_t o) {
29376         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
29377         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
29378         return ret_conv;
29379 }
29380
29381 void  CS_LDK_CResult_NoneSendErrorZ_free(int64_t _res) {
29382         if (!ptr_is_owned(_res)) return;
29383         void* _res_ptr = untag_ptr(_res);
29384         CHECK_ACCESS(_res_ptr);
29385         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
29386         FREE(untag_ptr(_res));
29387         CResult_NoneSendErrorZ_free(_res_conv);
29388 }
29389
29390 int64_t  CS_LDK_CResult_BlindedPathNoneZ_ok(int64_t o) {
29391         LDKBlindedPath o_conv;
29392         o_conv.inner = untag_ptr(o);
29393         o_conv.is_owned = ptr_is_owned(o);
29394         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29395         o_conv = BlindedPath_clone(&o_conv);
29396         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29397         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
29398         return tag_ptr(ret_conv, true);
29399 }
29400
29401 int64_t  CS_LDK_CResult_BlindedPathNoneZ_err() {
29402         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29403         *ret_conv = CResult_BlindedPathNoneZ_err();
29404         return tag_ptr(ret_conv, true);
29405 }
29406
29407 jboolean  CS_LDK_CResult_BlindedPathNoneZ_is_ok(int64_t o) {
29408         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
29409         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
29410         return ret_conv;
29411 }
29412
29413 void  CS_LDK_CResult_BlindedPathNoneZ_free(int64_t _res) {
29414         if (!ptr_is_owned(_res)) return;
29415         void* _res_ptr = untag_ptr(_res);
29416         CHECK_ACCESS(_res_ptr);
29417         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
29418         FREE(untag_ptr(_res));
29419         CResult_BlindedPathNoneZ_free(_res_conv);
29420 }
29421
29422 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
29423         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29424         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
29425         return tag_ptr(ret_conv, true);
29426 }
29427 int64_t  CS_LDK_CResult_BlindedPathNoneZ_clone_ptr(int64_t arg) {
29428         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
29429         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
29430         return ret_conv;
29431 }
29432
29433 int64_t  CS_LDK_CResult_BlindedPathNoneZ_clone(int64_t orig) {
29434         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
29435         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
29436         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
29437         return tag_ptr(ret_conv, true);
29438 }
29439
29440 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(int64_t o) {
29441         void* o_ptr = untag_ptr(o);
29442         CHECK_ACCESS(o_ptr);
29443         LDKC2Tuple_BlindedPayInfoBlindedPathZ o_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(o_ptr);
29444         o_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(o));
29445         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29446         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_ok(o_conv);
29447         return tag_ptr(ret_conv, true);
29448 }
29449
29450 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err() {
29451         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29452         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_err();
29453         return tag_ptr(ret_conv, true);
29454 }
29455
29456 jboolean  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_is_ok(int64_t o) {
29457         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* o_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(o);
29458         jboolean ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_is_ok(o_conv);
29459         return ret_conv;
29460 }
29461
29462 void  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(int64_t _res) {
29463         if (!ptr_is_owned(_res)) return;
29464         void* _res_ptr = untag_ptr(_res);
29465         CHECK_ACCESS(_res_ptr);
29466         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ _res_conv = *(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)(_res_ptr);
29467         FREE(untag_ptr(_res));
29468         CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_free(_res_conv);
29469 }
29470
29471 static inline uint64_t CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone_ptr(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ *NONNULL_PTR arg) {
29472         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29473         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(arg);
29474         return tag_ptr(ret_conv, true);
29475 }
29476 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone_ptr(int64_t arg) {
29477         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* arg_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(arg);
29478         int64_t ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone_ptr(arg_conv);
29479         return ret_conv;
29480 }
29481
29482 int64_t  CS_LDK_CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(int64_t orig) {
29483         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* orig_conv = (LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ*)untag_ptr(orig);
29484         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
29485         *ret_conv = CResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ_clone(orig_conv);
29486         return tag_ptr(ret_conv, true);
29487 }
29488
29489 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_ok(int64_t o) {
29490         LDKBlindedPath o_conv;
29491         o_conv.inner = untag_ptr(o);
29492         o_conv.is_owned = ptr_is_owned(o);
29493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29494         o_conv = BlindedPath_clone(&o_conv);
29495         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29496         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
29497         return tag_ptr(ret_conv, true);
29498 }
29499
29500 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_err(int64_t e) {
29501         void* e_ptr = untag_ptr(e);
29502         CHECK_ACCESS(e_ptr);
29503         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
29504         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
29505         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29506         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
29507         return tag_ptr(ret_conv, true);
29508 }
29509
29510 jboolean  CS_LDK_CResult_BlindedPathDecodeErrorZ_is_ok(int64_t o) {
29511         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
29512         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
29513         return ret_conv;
29514 }
29515
29516 void  CS_LDK_CResult_BlindedPathDecodeErrorZ_free(int64_t _res) {
29517         if (!ptr_is_owned(_res)) return;
29518         void* _res_ptr = untag_ptr(_res);
29519         CHECK_ACCESS(_res_ptr);
29520         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
29521         FREE(untag_ptr(_res));
29522         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
29523 }
29524
29525 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
29526         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29527         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
29528         return tag_ptr(ret_conv, true);
29529 }
29530 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_clone_ptr(int64_t arg) {
29531         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
29532         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
29533         return ret_conv;
29534 }
29535
29536 int64_t  CS_LDK_CResult_BlindedPathDecodeErrorZ_clone(int64_t orig) {
29537         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
29538         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
29539         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
29540         return tag_ptr(ret_conv, true);
29541 }
29542
29543 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_ok(int64_t o) {
29544         LDKBlindedHop o_conv;
29545         o_conv.inner = untag_ptr(o);
29546         o_conv.is_owned = ptr_is_owned(o);
29547         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29548         o_conv = BlindedHop_clone(&o_conv);
29549         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29550         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
29551         return tag_ptr(ret_conv, true);
29552 }
29553
29554 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_err(int64_t e) {
29555         void* e_ptr = untag_ptr(e);
29556         CHECK_ACCESS(e_ptr);
29557         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
29558         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
29559         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29560         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
29561         return tag_ptr(ret_conv, true);
29562 }
29563
29564 jboolean  CS_LDK_CResult_BlindedHopDecodeErrorZ_is_ok(int64_t o) {
29565         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
29566         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
29567         return ret_conv;
29568 }
29569
29570 void  CS_LDK_CResult_BlindedHopDecodeErrorZ_free(int64_t _res) {
29571         if (!ptr_is_owned(_res)) return;
29572         void* _res_ptr = untag_ptr(_res);
29573         CHECK_ACCESS(_res_ptr);
29574         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
29575         FREE(untag_ptr(_res));
29576         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
29577 }
29578
29579 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
29580         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29581         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
29582         return tag_ptr(ret_conv, true);
29583 }
29584 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_clone_ptr(int64_t arg) {
29585         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
29586         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
29587         return ret_conv;
29588 }
29589
29590 int64_t  CS_LDK_CResult_BlindedHopDecodeErrorZ_clone(int64_t orig) {
29591         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
29592         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
29593         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
29594         return tag_ptr(ret_conv, true);
29595 }
29596
29597 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_ok(int64_t o) {
29598         LDKInvoiceError o_conv;
29599         o_conv.inner = untag_ptr(o);
29600         o_conv.is_owned = ptr_is_owned(o);
29601         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29602         o_conv = InvoiceError_clone(&o_conv);
29603         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29604         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_ok(o_conv);
29605         return tag_ptr(ret_conv, true);
29606 }
29607
29608 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_err(int64_t e) {
29609         void* e_ptr = untag_ptr(e);
29610         CHECK_ACCESS(e_ptr);
29611         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
29612         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
29613         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29614         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_err(e_conv);
29615         return tag_ptr(ret_conv, true);
29616 }
29617
29618 jboolean  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_is_ok(int64_t o) {
29619         LDKCResult_InvoiceErrorDecodeErrorZ* o_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(o);
29620         jboolean ret_conv = CResult_InvoiceErrorDecodeErrorZ_is_ok(o_conv);
29621         return ret_conv;
29622 }
29623
29624 void  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_free(int64_t _res) {
29625         if (!ptr_is_owned(_res)) return;
29626         void* _res_ptr = untag_ptr(_res);
29627         CHECK_ACCESS(_res_ptr);
29628         LDKCResult_InvoiceErrorDecodeErrorZ _res_conv = *(LDKCResult_InvoiceErrorDecodeErrorZ*)(_res_ptr);
29629         FREE(untag_ptr(_res));
29630         CResult_InvoiceErrorDecodeErrorZ_free(_res_conv);
29631 }
29632
29633 static inline uint64_t CResult_InvoiceErrorDecodeErrorZ_clone_ptr(LDKCResult_InvoiceErrorDecodeErrorZ *NONNULL_PTR arg) {
29634         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29635         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_clone(arg);
29636         return tag_ptr(ret_conv, true);
29637 }
29638 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_clone_ptr(int64_t arg) {
29639         LDKCResult_InvoiceErrorDecodeErrorZ* arg_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(arg);
29640         int64_t ret_conv = CResult_InvoiceErrorDecodeErrorZ_clone_ptr(arg_conv);
29641         return ret_conv;
29642 }
29643
29644 int64_t  CS_LDK_CResult_InvoiceErrorDecodeErrorZ_clone(int64_t orig) {
29645         LDKCResult_InvoiceErrorDecodeErrorZ* orig_conv = (LDKCResult_InvoiceErrorDecodeErrorZ*)untag_ptr(orig);
29646         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
29647         *ret_conv = CResult_InvoiceErrorDecodeErrorZ_clone(orig_conv);
29648         return tag_ptr(ret_conv, true);
29649 }
29650
29651 int64_t  CS_LDK_COption_FilterZ_some(int64_t o) {
29652         void* o_ptr = untag_ptr(o);
29653         CHECK_ACCESS(o_ptr);
29654         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
29655         if (o_conv.free == LDKFilter_JCalls_free) {
29656                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29657                 LDKFilter_JCalls_cloned(&o_conv);
29658         }
29659         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
29660         *ret_copy = COption_FilterZ_some(o_conv);
29661         int64_t ret_ref = tag_ptr(ret_copy, true);
29662         return ret_ref;
29663 }
29664
29665 int64_t  CS_LDK_COption_FilterZ_none() {
29666         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
29667         *ret_copy = COption_FilterZ_none();
29668         int64_t ret_ref = tag_ptr(ret_copy, true);
29669         return ret_ref;
29670 }
29671
29672 void  CS_LDK_COption_FilterZ_free(int64_t _res) {
29673         if (!ptr_is_owned(_res)) return;
29674         void* _res_ptr = untag_ptr(_res);
29675         CHECK_ACCESS(_res_ptr);
29676         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
29677         FREE(untag_ptr(_res));
29678         COption_FilterZ_free(_res_conv);
29679 }
29680
29681 int64_t  CS_LDK_CResult_LockedChannelMonitorNoneZ_ok(int64_t o) {
29682         LDKLockedChannelMonitor o_conv;
29683         o_conv.inner = untag_ptr(o);
29684         o_conv.is_owned = ptr_is_owned(o);
29685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
29686         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
29687         
29688         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29689         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
29690         return tag_ptr(ret_conv, true);
29691 }
29692
29693 int64_t  CS_LDK_CResult_LockedChannelMonitorNoneZ_err() {
29694         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
29695         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
29696         return tag_ptr(ret_conv, true);
29697 }
29698
29699 jboolean  CS_LDK_CResult_LockedChannelMonitorNoneZ_is_ok(int64_t o) {
29700         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
29701         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
29702         return ret_conv;
29703 }
29704
29705 void  CS_LDK_CResult_LockedChannelMonitorNoneZ_free(int64_t _res) {
29706         if (!ptr_is_owned(_res)) return;
29707         void* _res_ptr = untag_ptr(_res);
29708         CHECK_ACCESS(_res_ptr);
29709         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
29710         FREE(untag_ptr(_res));
29711         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
29712 }
29713
29714 void  CS_LDK_CVec_OutPointZ_free(int64_tArray _res) {
29715         LDKCVec_OutPointZ _res_constr;
29716         _res_constr.datalen = _res->arr_len;
29717         if (_res_constr.datalen > 0)
29718                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
29719         else
29720                 _res_constr.data = NULL;
29721         int64_t* _res_vals = _res->elems;
29722         for (size_t k = 0; k < _res_constr.datalen; k++) {
29723                 int64_t _res_conv_10 = _res_vals[k];
29724                 LDKOutPoint _res_conv_10_conv;
29725                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
29726                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
29727                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
29728                 _res_constr.data[k] = _res_conv_10_conv;
29729         }
29730         FREE(_res);
29731         CVec_OutPointZ_free(_res_constr);
29732 }
29733
29734 void  CS_LDK_CVec_MonitorUpdateIdZ_free(int64_tArray _res) {
29735         LDKCVec_MonitorUpdateIdZ _res_constr;
29736         _res_constr.datalen = _res->arr_len;
29737         if (_res_constr.datalen > 0)
29738                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
29739         else
29740                 _res_constr.data = NULL;
29741         int64_t* _res_vals = _res->elems;
29742         for (size_t r = 0; r < _res_constr.datalen; r++) {
29743                 int64_t _res_conv_17 = _res_vals[r];
29744                 LDKMonitorUpdateId _res_conv_17_conv;
29745                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
29746                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
29747                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
29748                 _res_constr.data[r] = _res_conv_17_conv;
29749         }
29750         FREE(_res);
29751         CVec_MonitorUpdateIdZ_free(_res_constr);
29752 }
29753
29754 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
29755         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29756         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
29757         return tag_ptr(ret_conv, true);
29758 }
29759 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(int64_t arg) {
29760         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
29761         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
29762         return ret_conv;
29763 }
29764
29765 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(int64_t orig) {
29766         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
29767         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29768         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
29769         return tag_ptr(ret_conv, true);
29770 }
29771
29772 int64_t  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(int64_t a, int64_tArray b) {
29773         LDKOutPoint a_conv;
29774         a_conv.inner = untag_ptr(a);
29775         a_conv.is_owned = ptr_is_owned(a);
29776         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29777         a_conv = OutPoint_clone(&a_conv);
29778         LDKCVec_MonitorUpdateIdZ b_constr;
29779         b_constr.datalen = b->arr_len;
29780         if (b_constr.datalen > 0)
29781                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
29782         else
29783                 b_constr.data = NULL;
29784         int64_t* b_vals = b->elems;
29785         for (size_t r = 0; r < b_constr.datalen; r++) {
29786                 int64_t b_conv_17 = b_vals[r];
29787                 LDKMonitorUpdateId b_conv_17_conv;
29788                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
29789                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
29790                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
29791                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
29792                 b_constr.data[r] = b_conv_17_conv;
29793         }
29794         FREE(b);
29795         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29796         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
29797         return tag_ptr(ret_conv, true);
29798 }
29799
29800 void  CS_LDK_C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(int64_t _res) {
29801         if (!ptr_is_owned(_res)) return;
29802         void* _res_ptr = untag_ptr(_res);
29803         CHECK_ACCESS(_res_ptr);
29804         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
29805         FREE(untag_ptr(_res));
29806         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
29807 }
29808
29809 void  CS_LDK_CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(int64_tArray _res) {
29810         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
29811         _res_constr.datalen = _res->arr_len;
29812         if (_res_constr.datalen > 0)
29813                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
29814         else
29815                 _res_constr.data = NULL;
29816         int64_t* _res_vals = _res->elems;
29817         for (size_t p = 0; p < _res_constr.datalen; p++) {
29818                 int64_t _res_conv_41 = _res_vals[p];
29819                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
29820                 CHECK_ACCESS(_res_conv_41_ptr);
29821                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
29822                 FREE(untag_ptr(_res_conv_41));
29823                 _res_constr.data[p] = _res_conv_41_conv;
29824         }
29825         FREE(_res);
29826         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
29827 }
29828
29829 void  CS_LDK_APIError_free(int64_t this_ptr) {
29830         if (!ptr_is_owned(this_ptr)) return;
29831         void* this_ptr_ptr = untag_ptr(this_ptr);
29832         CHECK_ACCESS(this_ptr_ptr);
29833         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
29834         FREE(untag_ptr(this_ptr));
29835         APIError_free(this_ptr_conv);
29836 }
29837
29838 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
29839         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29840         *ret_copy = APIError_clone(arg);
29841         int64_t ret_ref = tag_ptr(ret_copy, true);
29842         return ret_ref;
29843 }
29844 int64_t  CS_LDK_APIError_clone_ptr(int64_t arg) {
29845         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
29846         int64_t ret_conv = APIError_clone_ptr(arg_conv);
29847         return ret_conv;
29848 }
29849
29850 int64_t  CS_LDK_APIError_clone(int64_t orig) {
29851         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
29852         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29853         *ret_copy = APIError_clone(orig_conv);
29854         int64_t ret_ref = tag_ptr(ret_copy, true);
29855         return ret_ref;
29856 }
29857
29858 int64_t  CS_LDK_APIError_apimisuse_error(jstring err) {
29859         LDKStr err_conv = str_ref_to_owned_c(err);
29860         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29861         *ret_copy = APIError_apimisuse_error(err_conv);
29862         int64_t ret_ref = tag_ptr(ret_copy, true);
29863         return ret_ref;
29864 }
29865
29866 int64_t  CS_LDK_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
29867         LDKStr err_conv = str_ref_to_owned_c(err);
29868         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29869         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
29870         int64_t ret_ref = tag_ptr(ret_copy, true);
29871         return ret_ref;
29872 }
29873
29874 int64_t  CS_LDK_APIError_invalid_route(jstring err) {
29875         LDKStr err_conv = str_ref_to_owned_c(err);
29876         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29877         *ret_copy = APIError_invalid_route(err_conv);
29878         int64_t ret_ref = tag_ptr(ret_copy, true);
29879         return ret_ref;
29880 }
29881
29882 int64_t  CS_LDK_APIError_channel_unavailable(jstring err) {
29883         LDKStr err_conv = str_ref_to_owned_c(err);
29884         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29885         *ret_copy = APIError_channel_unavailable(err_conv);
29886         int64_t ret_ref = tag_ptr(ret_copy, true);
29887         return ret_ref;
29888 }
29889
29890 int64_t  CS_LDK_APIError_monitor_update_in_progress() {
29891         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29892         *ret_copy = APIError_monitor_update_in_progress();
29893         int64_t ret_ref = tag_ptr(ret_copy, true);
29894         return ret_ref;
29895 }
29896
29897 int64_t  CS_LDK_APIError_incompatible_shutdown_script(int64_t script) {
29898         LDKShutdownScript script_conv;
29899         script_conv.inner = untag_ptr(script);
29900         script_conv.is_owned = ptr_is_owned(script);
29901         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
29902         script_conv = ShutdownScript_clone(&script_conv);
29903         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
29904         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
29905         int64_t ret_ref = tag_ptr(ret_copy, true);
29906         return ret_ref;
29907 }
29908
29909 jboolean  CS_LDK_APIError_eq(int64_t a, int64_t b) {
29910         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
29911         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
29912         jboolean ret_conv = APIError_eq(a_conv, b_conv);
29913         return ret_conv;
29914 }
29915
29916 int8_tArray  CS_LDK_APIError_write(int64_t obj) {
29917         LDKAPIError* obj_conv = (LDKAPIError*)untag_ptr(obj);
29918         LDKCVec_u8Z ret_var = APIError_write(obj_conv);
29919         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29920         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29921         CVec_u8Z_free(ret_var);
29922         return ret_arr;
29923 }
29924
29925 int64_t  CS_LDK_APIError_read(int8_tArray ser) {
29926         LDKu8slice ser_ref;
29927         ser_ref.datalen = ser->arr_len;
29928         ser_ref.data = ser->elems;
29929         LDKCResult_COption_APIErrorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_APIErrorZDecodeErrorZ), "LDKCResult_COption_APIErrorZDecodeErrorZ");
29930         *ret_conv = APIError_read(ser_ref);
29931         FREE(ser);
29932         return tag_ptr(ret_conv, true);
29933 }
29934
29935 void  CS_LDK_BigSize_free(int64_t this_obj) {
29936         LDKBigSize this_obj_conv;
29937         this_obj_conv.inner = untag_ptr(this_obj);
29938         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29940         BigSize_free(this_obj_conv);
29941 }
29942
29943 int64_t  CS_LDK_BigSize_get_a(int64_t this_ptr) {
29944         LDKBigSize this_ptr_conv;
29945         this_ptr_conv.inner = untag_ptr(this_ptr);
29946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29948         this_ptr_conv.is_owned = false;
29949         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
29950         return ret_conv;
29951 }
29952
29953 void  CS_LDK_BigSize_set_a(int64_t this_ptr, int64_t val) {
29954         LDKBigSize this_ptr_conv;
29955         this_ptr_conv.inner = untag_ptr(this_ptr);
29956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29958         this_ptr_conv.is_owned = false;
29959         BigSize_set_a(&this_ptr_conv, val);
29960 }
29961
29962 int64_t  CS_LDK_BigSize_new(int64_t a_arg) {
29963         LDKBigSize ret_var = BigSize_new(a_arg);
29964         int64_t ret_ref = 0;
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29967         return ret_ref;
29968 }
29969
29970 static inline uint64_t BigSize_clone_ptr(LDKBigSize *NONNULL_PTR arg) {
29971         LDKBigSize ret_var = BigSize_clone(arg);
29972         int64_t ret_ref = 0;
29973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29975         return ret_ref;
29976 }
29977 int64_t  CS_LDK_BigSize_clone_ptr(int64_t arg) {
29978         LDKBigSize arg_conv;
29979         arg_conv.inner = untag_ptr(arg);
29980         arg_conv.is_owned = ptr_is_owned(arg);
29981         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29982         arg_conv.is_owned = false;
29983         int64_t ret_conv = BigSize_clone_ptr(&arg_conv);
29984         return ret_conv;
29985 }
29986
29987 int64_t  CS_LDK_BigSize_clone(int64_t orig) {
29988         LDKBigSize orig_conv;
29989         orig_conv.inner = untag_ptr(orig);
29990         orig_conv.is_owned = ptr_is_owned(orig);
29991         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29992         orig_conv.is_owned = false;
29993         LDKBigSize ret_var = BigSize_clone(&orig_conv);
29994         int64_t ret_ref = 0;
29995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29997         return ret_ref;
29998 }
29999
30000 int64_t  CS_LDK_BigSize_hash(int64_t o) {
30001         LDKBigSize o_conv;
30002         o_conv.inner = untag_ptr(o);
30003         o_conv.is_owned = ptr_is_owned(o);
30004         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30005         o_conv.is_owned = false;
30006         int64_t ret_conv = BigSize_hash(&o_conv);
30007         return ret_conv;
30008 }
30009
30010 jboolean  CS_LDK_BigSize_eq(int64_t a, int64_t b) {
30011         LDKBigSize a_conv;
30012         a_conv.inner = untag_ptr(a);
30013         a_conv.is_owned = ptr_is_owned(a);
30014         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30015         a_conv.is_owned = false;
30016         LDKBigSize b_conv;
30017         b_conv.inner = untag_ptr(b);
30018         b_conv.is_owned = ptr_is_owned(b);
30019         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30020         b_conv.is_owned = false;
30021         jboolean ret_conv = BigSize_eq(&a_conv, &b_conv);
30022         return ret_conv;
30023 }
30024
30025 int8_tArray  CS_LDK_BigSize_write(int64_t obj) {
30026         LDKBigSize obj_conv;
30027         obj_conv.inner = untag_ptr(obj);
30028         obj_conv.is_owned = ptr_is_owned(obj);
30029         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30030         obj_conv.is_owned = false;
30031         LDKCVec_u8Z ret_var = BigSize_write(&obj_conv);
30032         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30033         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30034         CVec_u8Z_free(ret_var);
30035         return ret_arr;
30036 }
30037
30038 int64_t  CS_LDK_BigSize_read(int8_tArray ser) {
30039         LDKu8slice ser_ref;
30040         ser_ref.datalen = ser->arr_len;
30041         ser_ref.data = ser->elems;
30042         LDKCResult_BigSizeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BigSizeDecodeErrorZ), "LDKCResult_BigSizeDecodeErrorZ");
30043         *ret_conv = BigSize_read(ser_ref);
30044         FREE(ser);
30045         return tag_ptr(ret_conv, true);
30046 }
30047
30048 void  CS_LDK_Hostname_free(int64_t this_obj) {
30049         LDKHostname this_obj_conv;
30050         this_obj_conv.inner = untag_ptr(this_obj);
30051         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30053         Hostname_free(this_obj_conv);
30054 }
30055
30056 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
30057         LDKHostname ret_var = Hostname_clone(arg);
30058         int64_t ret_ref = 0;
30059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30061         return ret_ref;
30062 }
30063 int64_t  CS_LDK_Hostname_clone_ptr(int64_t arg) {
30064         LDKHostname arg_conv;
30065         arg_conv.inner = untag_ptr(arg);
30066         arg_conv.is_owned = ptr_is_owned(arg);
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30068         arg_conv.is_owned = false;
30069         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
30070         return ret_conv;
30071 }
30072
30073 int64_t  CS_LDK_Hostname_clone(int64_t orig) {
30074         LDKHostname orig_conv;
30075         orig_conv.inner = untag_ptr(orig);
30076         orig_conv.is_owned = ptr_is_owned(orig);
30077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30078         orig_conv.is_owned = false;
30079         LDKHostname ret_var = Hostname_clone(&orig_conv);
30080         int64_t ret_ref = 0;
30081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30082         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30083         return ret_ref;
30084 }
30085
30086 jboolean  CS_LDK_Hostname_eq(int64_t a, int64_t b) {
30087         LDKHostname a_conv;
30088         a_conv.inner = untag_ptr(a);
30089         a_conv.is_owned = ptr_is_owned(a);
30090         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30091         a_conv.is_owned = false;
30092         LDKHostname b_conv;
30093         b_conv.inner = untag_ptr(b);
30094         b_conv.is_owned = ptr_is_owned(b);
30095         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30096         b_conv.is_owned = false;
30097         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
30098         return ret_conv;
30099 }
30100
30101 int8_t  CS_LDK_Hostname_len(int64_t this_arg) {
30102         LDKHostname this_arg_conv;
30103         this_arg_conv.inner = untag_ptr(this_arg);
30104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30106         this_arg_conv.is_owned = false;
30107         int8_t ret_conv = Hostname_len(&this_arg_conv);
30108         return ret_conv;
30109 }
30110
30111 int8_tArray  CS_LDK_Hostname_write(int64_t obj) {
30112         LDKHostname obj_conv;
30113         obj_conv.inner = untag_ptr(obj);
30114         obj_conv.is_owned = ptr_is_owned(obj);
30115         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30116         obj_conv.is_owned = false;
30117         LDKCVec_u8Z ret_var = Hostname_write(&obj_conv);
30118         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30119         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30120         CVec_u8Z_free(ret_var);
30121         return ret_arr;
30122 }
30123
30124 int64_t  CS_LDK_Hostname_read(int8_tArray ser) {
30125         LDKu8slice ser_ref;
30126         ser_ref.datalen = ser->arr_len;
30127         ser_ref.data = ser->elems;
30128         LDKCResult_HostnameDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HostnameDecodeErrorZ), "LDKCResult_HostnameDecodeErrorZ");
30129         *ret_conv = Hostname_read(ser_ref);
30130         FREE(ser);
30131         return tag_ptr(ret_conv, true);
30132 }
30133
30134 void  CS_LDK_TransactionU16LenLimited_free(int64_t this_obj) {
30135         LDKTransactionU16LenLimited this_obj_conv;
30136         this_obj_conv.inner = untag_ptr(this_obj);
30137         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30139         TransactionU16LenLimited_free(this_obj_conv);
30140 }
30141
30142 static inline uint64_t TransactionU16LenLimited_clone_ptr(LDKTransactionU16LenLimited *NONNULL_PTR arg) {
30143         LDKTransactionU16LenLimited ret_var = TransactionU16LenLimited_clone(arg);
30144         int64_t ret_ref = 0;
30145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30147         return ret_ref;
30148 }
30149 int64_t  CS_LDK_TransactionU16LenLimited_clone_ptr(int64_t arg) {
30150         LDKTransactionU16LenLimited arg_conv;
30151         arg_conv.inner = untag_ptr(arg);
30152         arg_conv.is_owned = ptr_is_owned(arg);
30153         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30154         arg_conv.is_owned = false;
30155         int64_t ret_conv = TransactionU16LenLimited_clone_ptr(&arg_conv);
30156         return ret_conv;
30157 }
30158
30159 int64_t  CS_LDK_TransactionU16LenLimited_clone(int64_t orig) {
30160         LDKTransactionU16LenLimited orig_conv;
30161         orig_conv.inner = untag_ptr(orig);
30162         orig_conv.is_owned = ptr_is_owned(orig);
30163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30164         orig_conv.is_owned = false;
30165         LDKTransactionU16LenLimited ret_var = TransactionU16LenLimited_clone(&orig_conv);
30166         int64_t ret_ref = 0;
30167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30169         return ret_ref;
30170 }
30171
30172 jboolean  CS_LDK_TransactionU16LenLimited_eq(int64_t a, int64_t b) {
30173         LDKTransactionU16LenLimited a_conv;
30174         a_conv.inner = untag_ptr(a);
30175         a_conv.is_owned = ptr_is_owned(a);
30176         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30177         a_conv.is_owned = false;
30178         LDKTransactionU16LenLimited b_conv;
30179         b_conv.inner = untag_ptr(b);
30180         b_conv.is_owned = ptr_is_owned(b);
30181         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30182         b_conv.is_owned = false;
30183         jboolean ret_conv = TransactionU16LenLimited_eq(&a_conv, &b_conv);
30184         return ret_conv;
30185 }
30186
30187 int64_t  CS_LDK_TransactionU16LenLimited_new(int8_tArray transaction) {
30188         LDKTransaction transaction_ref;
30189         transaction_ref.datalen = transaction->arr_len;
30190         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
30191         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
30192         transaction_ref.data_is_owned = true;
30193         LDKCResult_TransactionU16LenLimitedNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedNoneZ), "LDKCResult_TransactionU16LenLimitedNoneZ");
30194         *ret_conv = TransactionU16LenLimited_new(transaction_ref);
30195         return tag_ptr(ret_conv, true);
30196 }
30197
30198 int8_tArray  CS_LDK_TransactionU16LenLimited_into_transaction(int64_t this_arg) {
30199         LDKTransactionU16LenLimited this_arg_conv;
30200         this_arg_conv.inner = untag_ptr(this_arg);
30201         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30203         this_arg_conv = TransactionU16LenLimited_clone(&this_arg_conv);
30204         LDKTransaction ret_var = TransactionU16LenLimited_into_transaction(this_arg_conv);
30205         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30206         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30207         Transaction_free(ret_var);
30208         return ret_arr;
30209 }
30210
30211 int8_tArray  CS_LDK_TransactionU16LenLimited_write(int64_t obj) {
30212         LDKTransactionU16LenLimited obj_conv;
30213         obj_conv.inner = untag_ptr(obj);
30214         obj_conv.is_owned = ptr_is_owned(obj);
30215         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30216         obj_conv.is_owned = false;
30217         LDKCVec_u8Z ret_var = TransactionU16LenLimited_write(&obj_conv);
30218         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30219         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30220         CVec_u8Z_free(ret_var);
30221         return ret_arr;
30222 }
30223
30224 int64_t  CS_LDK_TransactionU16LenLimited_read(int8_tArray ser) {
30225         LDKu8slice ser_ref;
30226         ser_ref.datalen = ser->arr_len;
30227         ser_ref.data = ser->elems;
30228         LDKCResult_TransactionU16LenLimitedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionU16LenLimitedDecodeErrorZ), "LDKCResult_TransactionU16LenLimitedDecodeErrorZ");
30229         *ret_conv = TransactionU16LenLimited_read(ser_ref);
30230         FREE(ser);
30231         return tag_ptr(ret_conv, true);
30232 }
30233
30234 int64_t  CS_LDK_sign(int8_tArray msg, int8_tArray sk) {
30235         LDKu8slice msg_ref;
30236         msg_ref.datalen = msg->arr_len;
30237         msg_ref.data = msg->elems;
30238         uint8_t sk_arr[32];
30239         CHECK(sk->arr_len == 32);
30240         memcpy(sk_arr, sk->elems, 32); FREE(sk);
30241         uint8_t (*sk_ref)[32] = &sk_arr;
30242         LDKCResult_StrSecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StrSecp256k1ErrorZ), "LDKCResult_StrSecp256k1ErrorZ");
30243         *ret_conv = sign(msg_ref, sk_ref);
30244         FREE(msg);
30245         return tag_ptr(ret_conv, true);
30246 }
30247
30248 int64_t  CS_LDK_recover_pk(int8_tArray msg, jstring sig) {
30249         LDKu8slice msg_ref;
30250         msg_ref.datalen = msg->arr_len;
30251         msg_ref.data = msg->elems;
30252         LDKStr sig_conv = str_ref_to_owned_c(sig);
30253         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
30254         *ret_conv = recover_pk(msg_ref, sig_conv);
30255         FREE(msg);
30256         return tag_ptr(ret_conv, true);
30257 }
30258
30259 jboolean  CS_LDK_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
30260         LDKu8slice msg_ref;
30261         msg_ref.datalen = msg->arr_len;
30262         msg_ref.data = msg->elems;
30263         LDKStr sig_conv = str_ref_to_owned_c(sig);
30264         LDKPublicKey pk_ref;
30265         CHECK(pk->arr_len == 33);
30266         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
30267         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
30268         FREE(msg);
30269         return ret_conv;
30270 }
30271
30272 int8_tArray  CS_LDK_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
30273         LDKu8slice hrp_bytes_ref;
30274         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
30275         hrp_bytes_ref.data = hrp_bytes->elems;
30276         LDKCVec_U5Z data_without_signature_constr;
30277         data_without_signature_constr.datalen = data_without_signature->arr_len;
30278         if (data_without_signature_constr.datalen > 0)
30279                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
30280         else
30281                 data_without_signature_constr.data = NULL;
30282         int8_t* data_without_signature_vals = (void*) data_without_signature->elems;
30283         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
30284                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
30285                 
30286                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
30287         }
30288         FREE(data_without_signature);
30289         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
30290         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30291         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30292         CVec_u8Z_free(ret_var);
30293         FREE(hrp_bytes);
30294         return ret_arr;
30295 }
30296
30297 void  CS_LDK_KVStore_free(int64_t this_ptr) {
30298         if (!ptr_is_owned(this_ptr)) return;
30299         void* this_ptr_ptr = untag_ptr(this_ptr);
30300         CHECK_ACCESS(this_ptr_ptr);
30301         LDKKVStore this_ptr_conv = *(LDKKVStore*)(this_ptr_ptr);
30302         FREE(untag_ptr(this_ptr));
30303         KVStore_free(this_ptr_conv);
30304 }
30305
30306 void  CS_LDK_Persister_free(int64_t this_ptr) {
30307         if (!ptr_is_owned(this_ptr)) return;
30308         void* this_ptr_ptr = untag_ptr(this_ptr);
30309         CHECK_ACCESS(this_ptr_ptr);
30310         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
30311         FREE(untag_ptr(this_ptr));
30312         Persister_free(this_ptr_conv);
30313 }
30314
30315 int64_t  CS_LDK_read_channel_monitors(int64_t kv_store, int64_t entropy_source, int64_t signer_provider) {
30316         void* kv_store_ptr = untag_ptr(kv_store);
30317         CHECK_ACCESS(kv_store_ptr);
30318         LDKKVStore kv_store_conv = *(LDKKVStore*)(kv_store_ptr);
30319         if (kv_store_conv.free == LDKKVStore_JCalls_free) {
30320                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30321                 LDKKVStore_JCalls_cloned(&kv_store_conv);
30322         }
30323         void* entropy_source_ptr = untag_ptr(entropy_source);
30324         CHECK_ACCESS(entropy_source_ptr);
30325         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
30326         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
30327                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30328                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
30329         }
30330         void* signer_provider_ptr = untag_ptr(signer_provider);
30331         CHECK_ACCESS(signer_provider_ptr);
30332         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
30333         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
30334                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30335                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
30336         }
30337         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
30338         *ret_conv = read_channel_monitors(kv_store_conv, entropy_source_conv, signer_provider_conv);
30339         return tag_ptr(ret_conv, true);
30340 }
30341
30342 void  CS_LDK_MonitorUpdatingPersister_free(int64_t this_obj) {
30343         LDKMonitorUpdatingPersister this_obj_conv;
30344         this_obj_conv.inner = untag_ptr(this_obj);
30345         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30347         MonitorUpdatingPersister_free(this_obj_conv);
30348 }
30349
30350 int64_t  CS_LDK_MonitorUpdatingPersister_new(int64_t kv_store, int64_t logger, int64_t maximum_pending_updates, int64_t entropy_source, int64_t signer_provider) {
30351         void* kv_store_ptr = untag_ptr(kv_store);
30352         CHECK_ACCESS(kv_store_ptr);
30353         LDKKVStore kv_store_conv = *(LDKKVStore*)(kv_store_ptr);
30354         if (kv_store_conv.free == LDKKVStore_JCalls_free) {
30355                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30356                 LDKKVStore_JCalls_cloned(&kv_store_conv);
30357         }
30358         void* logger_ptr = untag_ptr(logger);
30359         CHECK_ACCESS(logger_ptr);
30360         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
30361         if (logger_conv.free == LDKLogger_JCalls_free) {
30362                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30363                 LDKLogger_JCalls_cloned(&logger_conv);
30364         }
30365         void* entropy_source_ptr = untag_ptr(entropy_source);
30366         CHECK_ACCESS(entropy_source_ptr);
30367         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
30368         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
30369                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30370                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
30371         }
30372         void* signer_provider_ptr = untag_ptr(signer_provider);
30373         CHECK_ACCESS(signer_provider_ptr);
30374         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
30375         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
30376                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30377                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
30378         }
30379         LDKMonitorUpdatingPersister ret_var = MonitorUpdatingPersister_new(kv_store_conv, logger_conv, maximum_pending_updates, entropy_source_conv, signer_provider_conv);
30380         int64_t ret_ref = 0;
30381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30382         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30383         return ret_ref;
30384 }
30385
30386 int64_t  CS_LDK_MonitorUpdatingPersister_read_all_channel_monitors_with_updates(int64_t this_arg, int64_t broadcaster, int64_t fee_estimator) {
30387         LDKMonitorUpdatingPersister this_arg_conv;
30388         this_arg_conv.inner = untag_ptr(this_arg);
30389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30391         this_arg_conv.is_owned = false;
30392         void* broadcaster_ptr = untag_ptr(broadcaster);
30393         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
30394         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
30395         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30396         if (ptr_is_owned(fee_estimator)) { CHECK_ACCESS(fee_estimator_ptr); }
30397         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
30398         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ");
30399         *ret_conv = MonitorUpdatingPersister_read_all_channel_monitors_with_updates(&this_arg_conv, broadcaster_conv, fee_estimator_conv);
30400         return tag_ptr(ret_conv, true);
30401 }
30402
30403 int64_t  CS_LDK_MonitorUpdatingPersister_read_channel_monitor_with_updates(int64_t this_arg, int64_t broadcaster, int64_t fee_estimator, jstring monitor_key) {
30404         LDKMonitorUpdatingPersister this_arg_conv;
30405         this_arg_conv.inner = untag_ptr(this_arg);
30406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30408         this_arg_conv.is_owned = false;
30409         void* broadcaster_ptr = untag_ptr(broadcaster);
30410         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
30411         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
30412         void* fee_estimator_ptr = untag_ptr(fee_estimator);
30413         if (ptr_is_owned(fee_estimator)) { CHECK_ACCESS(fee_estimator_ptr); }
30414         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
30415         LDKStr monitor_key_conv = str_ref_to_owned_c(monitor_key);
30416         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ");
30417         *ret_conv = MonitorUpdatingPersister_read_channel_monitor_with_updates(&this_arg_conv, broadcaster_conv, fee_estimator_conv, monitor_key_conv);
30418         return tag_ptr(ret_conv, true);
30419 }
30420
30421 int64_t  CS_LDK_MonitorUpdatingPersister_cleanup_stale_updates(int64_t this_arg, jboolean lazy) {
30422         LDKMonitorUpdatingPersister this_arg_conv;
30423         this_arg_conv.inner = untag_ptr(this_arg);
30424         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30426         this_arg_conv.is_owned = false;
30427         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
30428         *ret_conv = MonitorUpdatingPersister_cleanup_stale_updates(&this_arg_conv, lazy);
30429         return tag_ptr(ret_conv, true);
30430 }
30431
30432 int64_t  CS_LDK_MonitorUpdatingPersister_as_Persist(int64_t this_arg) {
30433         LDKMonitorUpdatingPersister this_arg_conv;
30434         this_arg_conv.inner = untag_ptr(this_arg);
30435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30437         this_arg_conv.is_owned = false;
30438         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
30439         *ret_ret = MonitorUpdatingPersister_as_Persist(&this_arg_conv);
30440         return tag_ptr(ret_ret, true);
30441 }
30442
30443 void  CS_LDK_UntrustedString_free(int64_t this_obj) {
30444         LDKUntrustedString this_obj_conv;
30445         this_obj_conv.inner = untag_ptr(this_obj);
30446         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30448         UntrustedString_free(this_obj_conv);
30449 }
30450
30451 jstring  CS_LDK_UntrustedString_get_a(int64_t this_ptr) {
30452         LDKUntrustedString this_ptr_conv;
30453         this_ptr_conv.inner = untag_ptr(this_ptr);
30454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30456         this_ptr_conv.is_owned = false;
30457         LDKStr ret_str = UntrustedString_get_a(&this_ptr_conv);
30458         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30459         Str_free(ret_str);
30460         return ret_conv;
30461 }
30462
30463 void  CS_LDK_UntrustedString_set_a(int64_t this_ptr, jstring val) {
30464         LDKUntrustedString this_ptr_conv;
30465         this_ptr_conv.inner = untag_ptr(this_ptr);
30466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30468         this_ptr_conv.is_owned = false;
30469         LDKStr val_conv = str_ref_to_owned_c(val);
30470         UntrustedString_set_a(&this_ptr_conv, val_conv);
30471 }
30472
30473 int64_t  CS_LDK_UntrustedString_new(jstring a_arg) {
30474         LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
30475         LDKUntrustedString ret_var = UntrustedString_new(a_arg_conv);
30476         int64_t ret_ref = 0;
30477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30479         return ret_ref;
30480 }
30481
30482 static inline uint64_t UntrustedString_clone_ptr(LDKUntrustedString *NONNULL_PTR arg) {
30483         LDKUntrustedString ret_var = UntrustedString_clone(arg);
30484         int64_t ret_ref = 0;
30485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30487         return ret_ref;
30488 }
30489 int64_t  CS_LDK_UntrustedString_clone_ptr(int64_t arg) {
30490         LDKUntrustedString arg_conv;
30491         arg_conv.inner = untag_ptr(arg);
30492         arg_conv.is_owned = ptr_is_owned(arg);
30493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30494         arg_conv.is_owned = false;
30495         int64_t ret_conv = UntrustedString_clone_ptr(&arg_conv);
30496         return ret_conv;
30497 }
30498
30499 int64_t  CS_LDK_UntrustedString_clone(int64_t orig) {
30500         LDKUntrustedString orig_conv;
30501         orig_conv.inner = untag_ptr(orig);
30502         orig_conv.is_owned = ptr_is_owned(orig);
30503         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30504         orig_conv.is_owned = false;
30505         LDKUntrustedString ret_var = UntrustedString_clone(&orig_conv);
30506         int64_t ret_ref = 0;
30507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30509         return ret_ref;
30510 }
30511
30512 jboolean  CS_LDK_UntrustedString_eq(int64_t a, int64_t b) {
30513         LDKUntrustedString a_conv;
30514         a_conv.inner = untag_ptr(a);
30515         a_conv.is_owned = ptr_is_owned(a);
30516         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30517         a_conv.is_owned = false;
30518         LDKUntrustedString b_conv;
30519         b_conv.inner = untag_ptr(b);
30520         b_conv.is_owned = ptr_is_owned(b);
30521         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30522         b_conv.is_owned = false;
30523         jboolean ret_conv = UntrustedString_eq(&a_conv, &b_conv);
30524         return ret_conv;
30525 }
30526
30527 int8_tArray  CS_LDK_UntrustedString_write(int64_t obj) {
30528         LDKUntrustedString obj_conv;
30529         obj_conv.inner = untag_ptr(obj);
30530         obj_conv.is_owned = ptr_is_owned(obj);
30531         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30532         obj_conv.is_owned = false;
30533         LDKCVec_u8Z ret_var = UntrustedString_write(&obj_conv);
30534         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30535         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30536         CVec_u8Z_free(ret_var);
30537         return ret_arr;
30538 }
30539
30540 int64_t  CS_LDK_UntrustedString_read(int8_tArray ser) {
30541         LDKu8slice ser_ref;
30542         ser_ref.datalen = ser->arr_len;
30543         ser_ref.data = ser->elems;
30544         LDKCResult_UntrustedStringDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UntrustedStringDecodeErrorZ), "LDKCResult_UntrustedStringDecodeErrorZ");
30545         *ret_conv = UntrustedString_read(ser_ref);
30546         FREE(ser);
30547         return tag_ptr(ret_conv, true);
30548 }
30549
30550 void  CS_LDK_PrintableString_free(int64_t this_obj) {
30551         LDKPrintableString this_obj_conv;
30552         this_obj_conv.inner = untag_ptr(this_obj);
30553         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30555         PrintableString_free(this_obj_conv);
30556 }
30557
30558 jstring  CS_LDK_PrintableString_get_a(int64_t this_ptr) {
30559         LDKPrintableString this_ptr_conv;
30560         this_ptr_conv.inner = untag_ptr(this_ptr);
30561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30563         this_ptr_conv.is_owned = false;
30564         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
30565         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30566         Str_free(ret_str);
30567         return ret_conv;
30568 }
30569
30570 void  CS_LDK_PrintableString_set_a(int64_t this_ptr, jstring val) {
30571         LDKPrintableString this_ptr_conv;
30572         this_ptr_conv.inner = untag_ptr(this_ptr);
30573         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30575         this_ptr_conv.is_owned = false;
30576         LDKStr val_conv = str_ref_to_owned_c(val);
30577         PrintableString_set_a(&this_ptr_conv, val_conv);
30578 }
30579
30580 int64_t  CS_LDK_PrintableString_new(jstring a_arg) {
30581         LDKStr a_arg_conv = str_ref_to_owned_c(a_arg);
30582         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
30583         int64_t ret_ref = 0;
30584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30586         return ret_ref;
30587 }
30588
30589 void  CS_LDK_FutureCallback_free(int64_t this_ptr) {
30590         if (!ptr_is_owned(this_ptr)) return;
30591         void* this_ptr_ptr = untag_ptr(this_ptr);
30592         CHECK_ACCESS(this_ptr_ptr);
30593         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
30594         FREE(untag_ptr(this_ptr));
30595         FutureCallback_free(this_ptr_conv);
30596 }
30597
30598 void  CS_LDK_Future_free(int64_t this_obj) {
30599         LDKFuture this_obj_conv;
30600         this_obj_conv.inner = untag_ptr(this_obj);
30601         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30603         Future_free(this_obj_conv);
30604 }
30605
30606 static inline uint64_t Future_clone_ptr(LDKFuture *NONNULL_PTR arg) {
30607         LDKFuture ret_var = Future_clone(arg);
30608         int64_t ret_ref = 0;
30609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30610         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30611         return ret_ref;
30612 }
30613 int64_t  CS_LDK_Future_clone_ptr(int64_t arg) {
30614         LDKFuture arg_conv;
30615         arg_conv.inner = untag_ptr(arg);
30616         arg_conv.is_owned = ptr_is_owned(arg);
30617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30618         arg_conv.is_owned = false;
30619         int64_t ret_conv = Future_clone_ptr(&arg_conv);
30620         return ret_conv;
30621 }
30622
30623 int64_t  CS_LDK_Future_clone(int64_t orig) {
30624         LDKFuture orig_conv;
30625         orig_conv.inner = untag_ptr(orig);
30626         orig_conv.is_owned = ptr_is_owned(orig);
30627         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30628         orig_conv.is_owned = false;
30629         LDKFuture ret_var = Future_clone(&orig_conv);
30630         int64_t ret_ref = 0;
30631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30632         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30633         return ret_ref;
30634 }
30635
30636 void  CS_LDK_Future_register_callback_fn(int64_t this_arg, int64_t callback) {
30637         LDKFuture this_arg_conv;
30638         this_arg_conv.inner = untag_ptr(this_arg);
30639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30641         this_arg_conv.is_owned = false;
30642         void* callback_ptr = untag_ptr(callback);
30643         CHECK_ACCESS(callback_ptr);
30644         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
30645         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
30646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
30647                 LDKFutureCallback_JCalls_cloned(&callback_conv);
30648         }
30649         Future_register_callback_fn(&this_arg_conv, callback_conv);
30650 }
30651
30652 void  CS_LDK_Future_wait(int64_t this_arg) {
30653         LDKFuture this_arg_conv;
30654         this_arg_conv.inner = untag_ptr(this_arg);
30655         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30657         this_arg_conv = Future_clone(&this_arg_conv);
30658         Future_wait(this_arg_conv);
30659 }
30660
30661 jboolean  CS_LDK_Future_wait_timeout(int64_t this_arg, int64_t max_wait) {
30662         LDKFuture this_arg_conv;
30663         this_arg_conv.inner = untag_ptr(this_arg);
30664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30666         this_arg_conv = Future_clone(&this_arg_conv);
30667         jboolean ret_conv = Future_wait_timeout(this_arg_conv, max_wait);
30668         return ret_conv;
30669 }
30670
30671 void  CS_LDK_Sleeper_free(int64_t this_obj) {
30672         LDKSleeper this_obj_conv;
30673         this_obj_conv.inner = untag_ptr(this_obj);
30674         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30676         Sleeper_free(this_obj_conv);
30677 }
30678
30679 int64_t  CS_LDK_Sleeper_from_single_future(int64_t future) {
30680         LDKFuture future_conv;
30681         future_conv.inner = untag_ptr(future);
30682         future_conv.is_owned = ptr_is_owned(future);
30683         CHECK_INNER_FIELD_ACCESS_OR_NULL(future_conv);
30684         future_conv = Future_clone(&future_conv);
30685         LDKSleeper ret_var = Sleeper_from_single_future(future_conv);
30686         int64_t ret_ref = 0;
30687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30688         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30689         return ret_ref;
30690 }
30691
30692 int64_t  CS_LDK_Sleeper_from_two_futures(int64_t fut_a, int64_t fut_b) {
30693         LDKFuture fut_a_conv;
30694         fut_a_conv.inner = untag_ptr(fut_a);
30695         fut_a_conv.is_owned = ptr_is_owned(fut_a);
30696         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_a_conv);
30697         fut_a_conv = Future_clone(&fut_a_conv);
30698         LDKFuture fut_b_conv;
30699         fut_b_conv.inner = untag_ptr(fut_b);
30700         fut_b_conv.is_owned = ptr_is_owned(fut_b);
30701         CHECK_INNER_FIELD_ACCESS_OR_NULL(fut_b_conv);
30702         fut_b_conv = Future_clone(&fut_b_conv);
30703         LDKSleeper ret_var = Sleeper_from_two_futures(fut_a_conv, fut_b_conv);
30704         int64_t ret_ref = 0;
30705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30707         return ret_ref;
30708 }
30709
30710 int64_t  CS_LDK_Sleeper_new(int64_tArray futures) {
30711         LDKCVec_FutureZ futures_constr;
30712         futures_constr.datalen = futures->arr_len;
30713         if (futures_constr.datalen > 0)
30714                 futures_constr.data = MALLOC(futures_constr.datalen * sizeof(LDKFuture), "LDKCVec_FutureZ Elements");
30715         else
30716                 futures_constr.data = NULL;
30717         int64_t* futures_vals = futures->elems;
30718         for (size_t i = 0; i < futures_constr.datalen; i++) {
30719                 int64_t futures_conv_8 = futures_vals[i];
30720                 LDKFuture futures_conv_8_conv;
30721                 futures_conv_8_conv.inner = untag_ptr(futures_conv_8);
30722                 futures_conv_8_conv.is_owned = ptr_is_owned(futures_conv_8);
30723                 CHECK_INNER_FIELD_ACCESS_OR_NULL(futures_conv_8_conv);
30724                 futures_conv_8_conv = Future_clone(&futures_conv_8_conv);
30725                 futures_constr.data[i] = futures_conv_8_conv;
30726         }
30727         FREE(futures);
30728         LDKSleeper ret_var = Sleeper_new(futures_constr);
30729         int64_t ret_ref = 0;
30730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30731         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30732         return ret_ref;
30733 }
30734
30735 void  CS_LDK_Sleeper_wait(int64_t this_arg) {
30736         LDKSleeper this_arg_conv;
30737         this_arg_conv.inner = untag_ptr(this_arg);
30738         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30740         this_arg_conv.is_owned = false;
30741         Sleeper_wait(&this_arg_conv);
30742 }
30743
30744 jboolean  CS_LDK_Sleeper_wait_timeout(int64_t this_arg, int64_t max_wait) {
30745         LDKSleeper this_arg_conv;
30746         this_arg_conv.inner = untag_ptr(this_arg);
30747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30749         this_arg_conv.is_owned = false;
30750         jboolean ret_conv = Sleeper_wait_timeout(&this_arg_conv, max_wait);
30751         return ret_conv;
30752 }
30753
30754 int32_t  CS_LDK_Level_clone(int64_t orig) {
30755         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
30756         int32_t ret_conv = LDKLevel_to_cs(Level_clone(orig_conv));
30757         return ret_conv;
30758 }
30759
30760 int32_t  CS_LDK_Level_gossip() {
30761         int32_t ret_conv = LDKLevel_to_cs(Level_gossip());
30762         return ret_conv;
30763 }
30764
30765 int32_t  CS_LDK_Level_trace() {
30766         int32_t ret_conv = LDKLevel_to_cs(Level_trace());
30767         return ret_conv;
30768 }
30769
30770 int32_t  CS_LDK_Level_debug() {
30771         int32_t ret_conv = LDKLevel_to_cs(Level_debug());
30772         return ret_conv;
30773 }
30774
30775 int32_t  CS_LDK_Level_info() {
30776         int32_t ret_conv = LDKLevel_to_cs(Level_info());
30777         return ret_conv;
30778 }
30779
30780 int32_t  CS_LDK_Level_warn() {
30781         int32_t ret_conv = LDKLevel_to_cs(Level_warn());
30782         return ret_conv;
30783 }
30784
30785 int32_t  CS_LDK_Level_error() {
30786         int32_t ret_conv = LDKLevel_to_cs(Level_error());
30787         return ret_conv;
30788 }
30789
30790 jboolean  CS_LDK_Level_eq(int64_t a, int64_t b) {
30791         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
30792         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
30793         jboolean ret_conv = Level_eq(a_conv, b_conv);
30794         return ret_conv;
30795 }
30796
30797 int64_t  CS_LDK_Level_hash(int64_t o) {
30798         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
30799         int64_t ret_conv = Level_hash(o_conv);
30800         return ret_conv;
30801 }
30802
30803 int32_t  CS_LDK_Level_max() {
30804         int32_t ret_conv = LDKLevel_to_cs(Level_max());
30805         return ret_conv;
30806 }
30807
30808 void  CS_LDK_Record_free(int64_t this_obj) {
30809         LDKRecord this_obj_conv;
30810         this_obj_conv.inner = untag_ptr(this_obj);
30811         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30813         Record_free(this_obj_conv);
30814 }
30815
30816 int32_t  CS_LDK_Record_get_level(int64_t this_ptr) {
30817         LDKRecord this_ptr_conv;
30818         this_ptr_conv.inner = untag_ptr(this_ptr);
30819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30821         this_ptr_conv.is_owned = false;
30822         int32_t ret_conv = LDKLevel_to_cs(Record_get_level(&this_ptr_conv));
30823         return ret_conv;
30824 }
30825
30826 void  CS_LDK_Record_set_level(int64_t this_ptr, int32_t val) {
30827         LDKRecord this_ptr_conv;
30828         this_ptr_conv.inner = untag_ptr(this_ptr);
30829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30831         this_ptr_conv.is_owned = false;
30832         LDKLevel val_conv = LDKLevel_from_cs(val);
30833         Record_set_level(&this_ptr_conv, val_conv);
30834 }
30835
30836 jstring  CS_LDK_Record_get_args(int64_t this_ptr) {
30837         LDKRecord this_ptr_conv;
30838         this_ptr_conv.inner = untag_ptr(this_ptr);
30839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30841         this_ptr_conv.is_owned = false;
30842         LDKStr ret_str = Record_get_args(&this_ptr_conv);
30843         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30844         Str_free(ret_str);
30845         return ret_conv;
30846 }
30847
30848 void  CS_LDK_Record_set_args(int64_t this_ptr, jstring val) {
30849         LDKRecord this_ptr_conv;
30850         this_ptr_conv.inner = untag_ptr(this_ptr);
30851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30853         this_ptr_conv.is_owned = false;
30854         LDKStr val_conv = str_ref_to_owned_c(val);
30855         Record_set_args(&this_ptr_conv, val_conv);
30856 }
30857
30858 jstring  CS_LDK_Record_get_module_path(int64_t this_ptr) {
30859         LDKRecord this_ptr_conv;
30860         this_ptr_conv.inner = untag_ptr(this_ptr);
30861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30863         this_ptr_conv.is_owned = false;
30864         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
30865         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30866         Str_free(ret_str);
30867         return ret_conv;
30868 }
30869
30870 void  CS_LDK_Record_set_module_path(int64_t this_ptr, jstring val) {
30871         LDKRecord this_ptr_conv;
30872         this_ptr_conv.inner = untag_ptr(this_ptr);
30873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30875         this_ptr_conv.is_owned = false;
30876         LDKStr val_conv = str_ref_to_owned_c(val);
30877         Record_set_module_path(&this_ptr_conv, val_conv);
30878 }
30879
30880 jstring  CS_LDK_Record_get_file(int64_t this_ptr) {
30881         LDKRecord this_ptr_conv;
30882         this_ptr_conv.inner = untag_ptr(this_ptr);
30883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30885         this_ptr_conv.is_owned = false;
30886         LDKStr ret_str = Record_get_file(&this_ptr_conv);
30887         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
30888         Str_free(ret_str);
30889         return ret_conv;
30890 }
30891
30892 void  CS_LDK_Record_set_file(int64_t this_ptr, jstring val) {
30893         LDKRecord this_ptr_conv;
30894         this_ptr_conv.inner = untag_ptr(this_ptr);
30895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30897         this_ptr_conv.is_owned = false;
30898         LDKStr val_conv = str_ref_to_owned_c(val);
30899         Record_set_file(&this_ptr_conv, val_conv);
30900 }
30901
30902 int32_t  CS_LDK_Record_get_line(int64_t this_ptr) {
30903         LDKRecord this_ptr_conv;
30904         this_ptr_conv.inner = untag_ptr(this_ptr);
30905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30907         this_ptr_conv.is_owned = false;
30908         int32_t ret_conv = Record_get_line(&this_ptr_conv);
30909         return ret_conv;
30910 }
30911
30912 void  CS_LDK_Record_set_line(int64_t this_ptr, int32_t val) {
30913         LDKRecord this_ptr_conv;
30914         this_ptr_conv.inner = untag_ptr(this_ptr);
30915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30917         this_ptr_conv.is_owned = false;
30918         Record_set_line(&this_ptr_conv, val);
30919 }
30920
30921 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
30922         LDKRecord ret_var = Record_clone(arg);
30923         int64_t ret_ref = 0;
30924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30926         return ret_ref;
30927 }
30928 int64_t  CS_LDK_Record_clone_ptr(int64_t arg) {
30929         LDKRecord arg_conv;
30930         arg_conv.inner = untag_ptr(arg);
30931         arg_conv.is_owned = ptr_is_owned(arg);
30932         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30933         arg_conv.is_owned = false;
30934         int64_t ret_conv = Record_clone_ptr(&arg_conv);
30935         return ret_conv;
30936 }
30937
30938 int64_t  CS_LDK_Record_clone(int64_t orig) {
30939         LDKRecord orig_conv;
30940         orig_conv.inner = untag_ptr(orig);
30941         orig_conv.is_owned = ptr_is_owned(orig);
30942         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30943         orig_conv.is_owned = false;
30944         LDKRecord ret_var = Record_clone(&orig_conv);
30945         int64_t ret_ref = 0;
30946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30947         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30948         return ret_ref;
30949 }
30950
30951 void  CS_LDK_Logger_free(int64_t this_ptr) {
30952         if (!ptr_is_owned(this_ptr)) return;
30953         void* this_ptr_ptr = untag_ptr(this_ptr);
30954         CHECK_ACCESS(this_ptr_ptr);
30955         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
30956         FREE(untag_ptr(this_ptr));
30957         Logger_free(this_ptr_conv);
30958 }
30959
30960 void  CS_LDK_ChannelHandshakeConfig_free(int64_t this_obj) {
30961         LDKChannelHandshakeConfig this_obj_conv;
30962         this_obj_conv.inner = untag_ptr(this_obj);
30963         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30965         ChannelHandshakeConfig_free(this_obj_conv);
30966 }
30967
30968 int32_t  CS_LDK_ChannelHandshakeConfig_get_minimum_depth(int64_t this_ptr) {
30969         LDKChannelHandshakeConfig this_ptr_conv;
30970         this_ptr_conv.inner = untag_ptr(this_ptr);
30971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30973         this_ptr_conv.is_owned = false;
30974         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
30975         return ret_conv;
30976 }
30977
30978 void  CS_LDK_ChannelHandshakeConfig_set_minimum_depth(int64_t this_ptr, int32_t val) {
30979         LDKChannelHandshakeConfig this_ptr_conv;
30980         this_ptr_conv.inner = untag_ptr(this_ptr);
30981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30983         this_ptr_conv.is_owned = false;
30984         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
30985 }
30986
30987 int16_t  CS_LDK_ChannelHandshakeConfig_get_our_to_self_delay(int64_t this_ptr) {
30988         LDKChannelHandshakeConfig this_ptr_conv;
30989         this_ptr_conv.inner = untag_ptr(this_ptr);
30990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30992         this_ptr_conv.is_owned = false;
30993         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
30994         return ret_conv;
30995 }
30996
30997 void  CS_LDK_ChannelHandshakeConfig_set_our_to_self_delay(int64_t this_ptr, int16_t val) {
30998         LDKChannelHandshakeConfig this_ptr_conv;
30999         this_ptr_conv.inner = untag_ptr(this_ptr);
31000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31002         this_ptr_conv.is_owned = false;
31003         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
31004 }
31005
31006 int64_t  CS_LDK_ChannelHandshakeConfig_get_our_htlc_minimum_msat(int64_t this_ptr) {
31007         LDKChannelHandshakeConfig this_ptr_conv;
31008         this_ptr_conv.inner = untag_ptr(this_ptr);
31009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31011         this_ptr_conv.is_owned = false;
31012         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
31013         return ret_conv;
31014 }
31015
31016 void  CS_LDK_ChannelHandshakeConfig_set_our_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
31017         LDKChannelHandshakeConfig this_ptr_conv;
31018         this_ptr_conv.inner = untag_ptr(this_ptr);
31019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31021         this_ptr_conv.is_owned = false;
31022         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
31023 }
31024
31025 int8_t  CS_LDK_ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(int64_t this_ptr) {
31026         LDKChannelHandshakeConfig this_ptr_conv;
31027         this_ptr_conv.inner = untag_ptr(this_ptr);
31028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31030         this_ptr_conv.is_owned = false;
31031         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
31032         return ret_conv;
31033 }
31034
31035 void  CS_LDK_ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(int64_t this_ptr, int8_t val) {
31036         LDKChannelHandshakeConfig this_ptr_conv;
31037         this_ptr_conv.inner = untag_ptr(this_ptr);
31038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31040         this_ptr_conv.is_owned = false;
31041         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
31042 }
31043
31044 jboolean  CS_LDK_ChannelHandshakeConfig_get_negotiate_scid_privacy(int64_t this_ptr) {
31045         LDKChannelHandshakeConfig this_ptr_conv;
31046         this_ptr_conv.inner = untag_ptr(this_ptr);
31047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31049         this_ptr_conv.is_owned = false;
31050         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
31051         return ret_conv;
31052 }
31053
31054 void  CS_LDK_ChannelHandshakeConfig_set_negotiate_scid_privacy(int64_t this_ptr, jboolean val) {
31055         LDKChannelHandshakeConfig this_ptr_conv;
31056         this_ptr_conv.inner = untag_ptr(this_ptr);
31057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31059         this_ptr_conv.is_owned = false;
31060         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
31061 }
31062
31063 jboolean  CS_LDK_ChannelHandshakeConfig_get_announced_channel(int64_t this_ptr) {
31064         LDKChannelHandshakeConfig this_ptr_conv;
31065         this_ptr_conv.inner = untag_ptr(this_ptr);
31066         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31068         this_ptr_conv.is_owned = false;
31069         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
31070         return ret_conv;
31071 }
31072
31073 void  CS_LDK_ChannelHandshakeConfig_set_announced_channel(int64_t this_ptr, jboolean val) {
31074         LDKChannelHandshakeConfig this_ptr_conv;
31075         this_ptr_conv.inner = untag_ptr(this_ptr);
31076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31078         this_ptr_conv.is_owned = false;
31079         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
31080 }
31081
31082 jboolean  CS_LDK_ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(int64_t this_ptr) {
31083         LDKChannelHandshakeConfig this_ptr_conv;
31084         this_ptr_conv.inner = untag_ptr(this_ptr);
31085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31087         this_ptr_conv.is_owned = false;
31088         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
31089         return ret_conv;
31090 }
31091
31092 void  CS_LDK_ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(int64_t this_ptr, jboolean val) {
31093         LDKChannelHandshakeConfig this_ptr_conv;
31094         this_ptr_conv.inner = untag_ptr(this_ptr);
31095         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31097         this_ptr_conv.is_owned = false;
31098         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
31099 }
31100
31101 int32_t  CS_LDK_ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(int64_t this_ptr) {
31102         LDKChannelHandshakeConfig this_ptr_conv;
31103         this_ptr_conv.inner = untag_ptr(this_ptr);
31104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31106         this_ptr_conv.is_owned = false;
31107         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
31108         return ret_conv;
31109 }
31110
31111 void  CS_LDK_ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(int64_t this_ptr, int32_t val) {
31112         LDKChannelHandshakeConfig this_ptr_conv;
31113         this_ptr_conv.inner = untag_ptr(this_ptr);
31114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31116         this_ptr_conv.is_owned = false;
31117         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
31118 }
31119
31120 jboolean  CS_LDK_ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(int64_t this_ptr) {
31121         LDKChannelHandshakeConfig this_ptr_conv;
31122         this_ptr_conv.inner = untag_ptr(this_ptr);
31123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31125         this_ptr_conv.is_owned = false;
31126         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_anchors_zero_fee_htlc_tx(&this_ptr_conv);
31127         return ret_conv;
31128 }
31129
31130 void  CS_LDK_ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(int64_t this_ptr, jboolean val) {
31131         LDKChannelHandshakeConfig this_ptr_conv;
31132         this_ptr_conv.inner = untag_ptr(this_ptr);
31133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31135         this_ptr_conv.is_owned = false;
31136         ChannelHandshakeConfig_set_negotiate_anchors_zero_fee_htlc_tx(&this_ptr_conv, val);
31137 }
31138
31139 int16_t  CS_LDK_ChannelHandshakeConfig_get_our_max_accepted_htlcs(int64_t this_ptr) {
31140         LDKChannelHandshakeConfig this_ptr_conv;
31141         this_ptr_conv.inner = untag_ptr(this_ptr);
31142         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31144         this_ptr_conv.is_owned = false;
31145         int16_t ret_conv = ChannelHandshakeConfig_get_our_max_accepted_htlcs(&this_ptr_conv);
31146         return ret_conv;
31147 }
31148
31149 void  CS_LDK_ChannelHandshakeConfig_set_our_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
31150         LDKChannelHandshakeConfig this_ptr_conv;
31151         this_ptr_conv.inner = untag_ptr(this_ptr);
31152         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31154         this_ptr_conv.is_owned = false;
31155         ChannelHandshakeConfig_set_our_max_accepted_htlcs(&this_ptr_conv, val);
31156 }
31157
31158 int64_t  CS_LDK_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int32_t their_channel_reserve_proportional_millionths_arg, jboolean negotiate_anchors_zero_fee_htlc_tx_arg, int16_t our_max_accepted_htlcs_arg) {
31159         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths_arg, negotiate_anchors_zero_fee_htlc_tx_arg, our_max_accepted_htlcs_arg);
31160         int64_t ret_ref = 0;
31161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31162         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31163         return ret_ref;
31164 }
31165
31166 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
31167         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
31168         int64_t ret_ref = 0;
31169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31170         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31171         return ret_ref;
31172 }
31173 int64_t  CS_LDK_ChannelHandshakeConfig_clone_ptr(int64_t arg) {
31174         LDKChannelHandshakeConfig arg_conv;
31175         arg_conv.inner = untag_ptr(arg);
31176         arg_conv.is_owned = ptr_is_owned(arg);
31177         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31178         arg_conv.is_owned = false;
31179         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
31180         return ret_conv;
31181 }
31182
31183 int64_t  CS_LDK_ChannelHandshakeConfig_clone(int64_t orig) {
31184         LDKChannelHandshakeConfig orig_conv;
31185         orig_conv.inner = untag_ptr(orig);
31186         orig_conv.is_owned = ptr_is_owned(orig);
31187         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31188         orig_conv.is_owned = false;
31189         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
31190         int64_t ret_ref = 0;
31191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31192         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31193         return ret_ref;
31194 }
31195
31196 int64_t  CS_LDK_ChannelHandshakeConfig_default() {
31197         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
31198         int64_t ret_ref = 0;
31199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31201         return ret_ref;
31202 }
31203
31204 void  CS_LDK_ChannelHandshakeLimits_free(int64_t this_obj) {
31205         LDKChannelHandshakeLimits this_obj_conv;
31206         this_obj_conv.inner = untag_ptr(this_obj);
31207         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31209         ChannelHandshakeLimits_free(this_obj_conv);
31210 }
31211
31212 int64_t  CS_LDK_ChannelHandshakeLimits_get_min_funding_satoshis(int64_t this_ptr) {
31213         LDKChannelHandshakeLimits this_ptr_conv;
31214         this_ptr_conv.inner = untag_ptr(this_ptr);
31215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31217         this_ptr_conv.is_owned = false;
31218         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
31219         return ret_conv;
31220 }
31221
31222 void  CS_LDK_ChannelHandshakeLimits_set_min_funding_satoshis(int64_t this_ptr, int64_t val) {
31223         LDKChannelHandshakeLimits this_ptr_conv;
31224         this_ptr_conv.inner = untag_ptr(this_ptr);
31225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31227         this_ptr_conv.is_owned = false;
31228         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
31229 }
31230
31231 int64_t  CS_LDK_ChannelHandshakeLimits_get_max_funding_satoshis(int64_t this_ptr) {
31232         LDKChannelHandshakeLimits this_ptr_conv;
31233         this_ptr_conv.inner = untag_ptr(this_ptr);
31234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31236         this_ptr_conv.is_owned = false;
31237         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
31238         return ret_conv;
31239 }
31240
31241 void  CS_LDK_ChannelHandshakeLimits_set_max_funding_satoshis(int64_t this_ptr, int64_t val) {
31242         LDKChannelHandshakeLimits this_ptr_conv;
31243         this_ptr_conv.inner = untag_ptr(this_ptr);
31244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31246         this_ptr_conv.is_owned = false;
31247         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
31248 }
31249
31250 int64_t  CS_LDK_ChannelHandshakeLimits_get_max_htlc_minimum_msat(int64_t this_ptr) {
31251         LDKChannelHandshakeLimits this_ptr_conv;
31252         this_ptr_conv.inner = untag_ptr(this_ptr);
31253         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31255         this_ptr_conv.is_owned = false;
31256         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
31257         return ret_conv;
31258 }
31259
31260 void  CS_LDK_ChannelHandshakeLimits_set_max_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
31261         LDKChannelHandshakeLimits this_ptr_conv;
31262         this_ptr_conv.inner = untag_ptr(this_ptr);
31263         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31265         this_ptr_conv.is_owned = false;
31266         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
31267 }
31268
31269 int64_t  CS_LDK_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(int64_t this_ptr) {
31270         LDKChannelHandshakeLimits this_ptr_conv;
31271         this_ptr_conv.inner = untag_ptr(this_ptr);
31272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31274         this_ptr_conv.is_owned = false;
31275         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
31276         return ret_conv;
31277 }
31278
31279 void  CS_LDK_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
31280         LDKChannelHandshakeLimits this_ptr_conv;
31281         this_ptr_conv.inner = untag_ptr(this_ptr);
31282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31284         this_ptr_conv.is_owned = false;
31285         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
31286 }
31287
31288 int64_t  CS_LDK_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(int64_t this_ptr) {
31289         LDKChannelHandshakeLimits this_ptr_conv;
31290         this_ptr_conv.inner = untag_ptr(this_ptr);
31291         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31293         this_ptr_conv.is_owned = false;
31294         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
31295         return ret_conv;
31296 }
31297
31298 void  CS_LDK_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(int64_t this_ptr, int64_t val) {
31299         LDKChannelHandshakeLimits this_ptr_conv;
31300         this_ptr_conv.inner = untag_ptr(this_ptr);
31301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31303         this_ptr_conv.is_owned = false;
31304         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
31305 }
31306
31307 int16_t  CS_LDK_ChannelHandshakeLimits_get_min_max_accepted_htlcs(int64_t this_ptr) {
31308         LDKChannelHandshakeLimits this_ptr_conv;
31309         this_ptr_conv.inner = untag_ptr(this_ptr);
31310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31312         this_ptr_conv.is_owned = false;
31313         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
31314         return ret_conv;
31315 }
31316
31317 void  CS_LDK_ChannelHandshakeLimits_set_min_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
31318         LDKChannelHandshakeLimits this_ptr_conv;
31319         this_ptr_conv.inner = untag_ptr(this_ptr);
31320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31322         this_ptr_conv.is_owned = false;
31323         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
31324 }
31325
31326 int32_t  CS_LDK_ChannelHandshakeLimits_get_max_minimum_depth(int64_t this_ptr) {
31327         LDKChannelHandshakeLimits this_ptr_conv;
31328         this_ptr_conv.inner = untag_ptr(this_ptr);
31329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31331         this_ptr_conv.is_owned = false;
31332         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
31333         return ret_conv;
31334 }
31335
31336 void  CS_LDK_ChannelHandshakeLimits_set_max_minimum_depth(int64_t this_ptr, int32_t val) {
31337         LDKChannelHandshakeLimits this_ptr_conv;
31338         this_ptr_conv.inner = untag_ptr(this_ptr);
31339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31341         this_ptr_conv.is_owned = false;
31342         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
31343 }
31344
31345 jboolean  CS_LDK_ChannelHandshakeLimits_get_trust_own_funding_0conf(int64_t this_ptr) {
31346         LDKChannelHandshakeLimits this_ptr_conv;
31347         this_ptr_conv.inner = untag_ptr(this_ptr);
31348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31350         this_ptr_conv.is_owned = false;
31351         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
31352         return ret_conv;
31353 }
31354
31355 void  CS_LDK_ChannelHandshakeLimits_set_trust_own_funding_0conf(int64_t this_ptr, jboolean val) {
31356         LDKChannelHandshakeLimits this_ptr_conv;
31357         this_ptr_conv.inner = untag_ptr(this_ptr);
31358         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31360         this_ptr_conv.is_owned = false;
31361         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
31362 }
31363
31364 jboolean  CS_LDK_ChannelHandshakeLimits_get_force_announced_channel_preference(int64_t this_ptr) {
31365         LDKChannelHandshakeLimits this_ptr_conv;
31366         this_ptr_conv.inner = untag_ptr(this_ptr);
31367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31369         this_ptr_conv.is_owned = false;
31370         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
31371         return ret_conv;
31372 }
31373
31374 void  CS_LDK_ChannelHandshakeLimits_set_force_announced_channel_preference(int64_t this_ptr, jboolean val) {
31375         LDKChannelHandshakeLimits this_ptr_conv;
31376         this_ptr_conv.inner = untag_ptr(this_ptr);
31377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31379         this_ptr_conv.is_owned = false;
31380         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
31381 }
31382
31383 int16_t  CS_LDK_ChannelHandshakeLimits_get_their_to_self_delay(int64_t this_ptr) {
31384         LDKChannelHandshakeLimits this_ptr_conv;
31385         this_ptr_conv.inner = untag_ptr(this_ptr);
31386         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31388         this_ptr_conv.is_owned = false;
31389         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
31390         return ret_conv;
31391 }
31392
31393 void  CS_LDK_ChannelHandshakeLimits_set_their_to_self_delay(int64_t this_ptr, int16_t val) {
31394         LDKChannelHandshakeLimits this_ptr_conv;
31395         this_ptr_conv.inner = untag_ptr(this_ptr);
31396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31398         this_ptr_conv.is_owned = false;
31399         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
31400 }
31401
31402 int64_t  CS_LDK_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_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 trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
31403         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_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, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
31404         int64_t ret_ref = 0;
31405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31407         return ret_ref;
31408 }
31409
31410 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
31411         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
31412         int64_t ret_ref = 0;
31413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31415         return ret_ref;
31416 }
31417 int64_t  CS_LDK_ChannelHandshakeLimits_clone_ptr(int64_t arg) {
31418         LDKChannelHandshakeLimits arg_conv;
31419         arg_conv.inner = untag_ptr(arg);
31420         arg_conv.is_owned = ptr_is_owned(arg);
31421         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31422         arg_conv.is_owned = false;
31423         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
31424         return ret_conv;
31425 }
31426
31427 int64_t  CS_LDK_ChannelHandshakeLimits_clone(int64_t orig) {
31428         LDKChannelHandshakeLimits orig_conv;
31429         orig_conv.inner = untag_ptr(orig);
31430         orig_conv.is_owned = ptr_is_owned(orig);
31431         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31432         orig_conv.is_owned = false;
31433         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
31434         int64_t ret_ref = 0;
31435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31436         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31437         return ret_ref;
31438 }
31439
31440 int64_t  CS_LDK_ChannelHandshakeLimits_default() {
31441         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
31442         int64_t ret_ref = 0;
31443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31445         return ret_ref;
31446 }
31447
31448 void  CS_LDK_MaxDustHTLCExposure_free(int64_t this_ptr) {
31449         if (!ptr_is_owned(this_ptr)) return;
31450         void* this_ptr_ptr = untag_ptr(this_ptr);
31451         CHECK_ACCESS(this_ptr_ptr);
31452         LDKMaxDustHTLCExposure this_ptr_conv = *(LDKMaxDustHTLCExposure*)(this_ptr_ptr);
31453         FREE(untag_ptr(this_ptr));
31454         MaxDustHTLCExposure_free(this_ptr_conv);
31455 }
31456
31457 static inline uint64_t MaxDustHTLCExposure_clone_ptr(LDKMaxDustHTLCExposure *NONNULL_PTR arg) {
31458         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31459         *ret_copy = MaxDustHTLCExposure_clone(arg);
31460         int64_t ret_ref = tag_ptr(ret_copy, true);
31461         return ret_ref;
31462 }
31463 int64_t  CS_LDK_MaxDustHTLCExposure_clone_ptr(int64_t arg) {
31464         LDKMaxDustHTLCExposure* arg_conv = (LDKMaxDustHTLCExposure*)untag_ptr(arg);
31465         int64_t ret_conv = MaxDustHTLCExposure_clone_ptr(arg_conv);
31466         return ret_conv;
31467 }
31468
31469 int64_t  CS_LDK_MaxDustHTLCExposure_clone(int64_t orig) {
31470         LDKMaxDustHTLCExposure* orig_conv = (LDKMaxDustHTLCExposure*)untag_ptr(orig);
31471         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31472         *ret_copy = MaxDustHTLCExposure_clone(orig_conv);
31473         int64_t ret_ref = tag_ptr(ret_copy, true);
31474         return ret_ref;
31475 }
31476
31477 int64_t  CS_LDK_MaxDustHTLCExposure_fixed_limit_msat(int64_t a) {
31478         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31479         *ret_copy = MaxDustHTLCExposure_fixed_limit_msat(a);
31480         int64_t ret_ref = tag_ptr(ret_copy, true);
31481         return ret_ref;
31482 }
31483
31484 int64_t  CS_LDK_MaxDustHTLCExposure_fee_rate_multiplier(int64_t a) {
31485         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31486         *ret_copy = MaxDustHTLCExposure_fee_rate_multiplier(a);
31487         int64_t ret_ref = tag_ptr(ret_copy, true);
31488         return ret_ref;
31489 }
31490
31491 jboolean  CS_LDK_MaxDustHTLCExposure_eq(int64_t a, int64_t b) {
31492         LDKMaxDustHTLCExposure* a_conv = (LDKMaxDustHTLCExposure*)untag_ptr(a);
31493         LDKMaxDustHTLCExposure* b_conv = (LDKMaxDustHTLCExposure*)untag_ptr(b);
31494         jboolean ret_conv = MaxDustHTLCExposure_eq(a_conv, b_conv);
31495         return ret_conv;
31496 }
31497
31498 int8_tArray  CS_LDK_MaxDustHTLCExposure_write(int64_t obj) {
31499         LDKMaxDustHTLCExposure* obj_conv = (LDKMaxDustHTLCExposure*)untag_ptr(obj);
31500         LDKCVec_u8Z ret_var = MaxDustHTLCExposure_write(obj_conv);
31501         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31502         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31503         CVec_u8Z_free(ret_var);
31504         return ret_arr;
31505 }
31506
31507 int64_t  CS_LDK_MaxDustHTLCExposure_read(int8_tArray ser) {
31508         LDKu8slice ser_ref;
31509         ser_ref.datalen = ser->arr_len;
31510         ser_ref.data = ser->elems;
31511         LDKCResult_MaxDustHTLCExposureDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_MaxDustHTLCExposureDecodeErrorZ), "LDKCResult_MaxDustHTLCExposureDecodeErrorZ");
31512         *ret_conv = MaxDustHTLCExposure_read(ser_ref);
31513         FREE(ser);
31514         return tag_ptr(ret_conv, true);
31515 }
31516
31517 void  CS_LDK_ChannelConfig_free(int64_t this_obj) {
31518         LDKChannelConfig this_obj_conv;
31519         this_obj_conv.inner = untag_ptr(this_obj);
31520         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31522         ChannelConfig_free(this_obj_conv);
31523 }
31524
31525 int32_t  CS_LDK_ChannelConfig_get_forwarding_fee_proportional_millionths(int64_t this_ptr) {
31526         LDKChannelConfig this_ptr_conv;
31527         this_ptr_conv.inner = untag_ptr(this_ptr);
31528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31530         this_ptr_conv.is_owned = false;
31531         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
31532         return ret_conv;
31533 }
31534
31535 void  CS_LDK_ChannelConfig_set_forwarding_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
31536         LDKChannelConfig this_ptr_conv;
31537         this_ptr_conv.inner = untag_ptr(this_ptr);
31538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31540         this_ptr_conv.is_owned = false;
31541         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
31542 }
31543
31544 int32_t  CS_LDK_ChannelConfig_get_forwarding_fee_base_msat(int64_t this_ptr) {
31545         LDKChannelConfig this_ptr_conv;
31546         this_ptr_conv.inner = untag_ptr(this_ptr);
31547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31549         this_ptr_conv.is_owned = false;
31550         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
31551         return ret_conv;
31552 }
31553
31554 void  CS_LDK_ChannelConfig_set_forwarding_fee_base_msat(int64_t this_ptr, int32_t val) {
31555         LDKChannelConfig this_ptr_conv;
31556         this_ptr_conv.inner = untag_ptr(this_ptr);
31557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31559         this_ptr_conv.is_owned = false;
31560         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
31561 }
31562
31563 int16_t  CS_LDK_ChannelConfig_get_cltv_expiry_delta(int64_t this_ptr) {
31564         LDKChannelConfig this_ptr_conv;
31565         this_ptr_conv.inner = untag_ptr(this_ptr);
31566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31568         this_ptr_conv.is_owned = false;
31569         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
31570         return ret_conv;
31571 }
31572
31573 void  CS_LDK_ChannelConfig_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
31574         LDKChannelConfig this_ptr_conv;
31575         this_ptr_conv.inner = untag_ptr(this_ptr);
31576         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31578         this_ptr_conv.is_owned = false;
31579         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
31580 }
31581
31582 int64_t  CS_LDK_ChannelConfig_get_max_dust_htlc_exposure(int64_t this_ptr) {
31583         LDKChannelConfig this_ptr_conv;
31584         this_ptr_conv.inner = untag_ptr(this_ptr);
31585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31587         this_ptr_conv.is_owned = false;
31588         LDKMaxDustHTLCExposure *ret_copy = MALLOC(sizeof(LDKMaxDustHTLCExposure), "LDKMaxDustHTLCExposure");
31589         *ret_copy = ChannelConfig_get_max_dust_htlc_exposure(&this_ptr_conv);
31590         int64_t ret_ref = tag_ptr(ret_copy, true);
31591         return ret_ref;
31592 }
31593
31594 void  CS_LDK_ChannelConfig_set_max_dust_htlc_exposure(int64_t this_ptr, int64_t val) {
31595         LDKChannelConfig this_ptr_conv;
31596         this_ptr_conv.inner = untag_ptr(this_ptr);
31597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31599         this_ptr_conv.is_owned = false;
31600         void* val_ptr = untag_ptr(val);
31601         CHECK_ACCESS(val_ptr);
31602         LDKMaxDustHTLCExposure val_conv = *(LDKMaxDustHTLCExposure*)(val_ptr);
31603         val_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(val));
31604         ChannelConfig_set_max_dust_htlc_exposure(&this_ptr_conv, val_conv);
31605 }
31606
31607 int64_t  CS_LDK_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(int64_t this_ptr) {
31608         LDKChannelConfig this_ptr_conv;
31609         this_ptr_conv.inner = untag_ptr(this_ptr);
31610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31612         this_ptr_conv.is_owned = false;
31613         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
31614         return ret_conv;
31615 }
31616
31617 void  CS_LDK_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(int64_t this_ptr, int64_t val) {
31618         LDKChannelConfig this_ptr_conv;
31619         this_ptr_conv.inner = untag_ptr(this_ptr);
31620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31622         this_ptr_conv.is_owned = false;
31623         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
31624 }
31625
31626 jboolean  CS_LDK_ChannelConfig_get_accept_underpaying_htlcs(int64_t this_ptr) {
31627         LDKChannelConfig this_ptr_conv;
31628         this_ptr_conv.inner = untag_ptr(this_ptr);
31629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31631         this_ptr_conv.is_owned = false;
31632         jboolean ret_conv = ChannelConfig_get_accept_underpaying_htlcs(&this_ptr_conv);
31633         return ret_conv;
31634 }
31635
31636 void  CS_LDK_ChannelConfig_set_accept_underpaying_htlcs(int64_t this_ptr, jboolean val) {
31637         LDKChannelConfig this_ptr_conv;
31638         this_ptr_conv.inner = untag_ptr(this_ptr);
31639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31641         this_ptr_conv.is_owned = false;
31642         ChannelConfig_set_accept_underpaying_htlcs(&this_ptr_conv, val);
31643 }
31644
31645 int64_t  CS_LDK_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_arg, int64_t force_close_avoidance_max_fee_satoshis_arg, jboolean accept_underpaying_htlcs_arg) {
31646         void* max_dust_htlc_exposure_arg_ptr = untag_ptr(max_dust_htlc_exposure_arg);
31647         CHECK_ACCESS(max_dust_htlc_exposure_arg_ptr);
31648         LDKMaxDustHTLCExposure max_dust_htlc_exposure_arg_conv = *(LDKMaxDustHTLCExposure*)(max_dust_htlc_exposure_arg_ptr);
31649         max_dust_htlc_exposure_arg_conv = MaxDustHTLCExposure_clone((LDKMaxDustHTLCExposure*)untag_ptr(max_dust_htlc_exposure_arg));
31650         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_arg_conv, force_close_avoidance_max_fee_satoshis_arg, accept_underpaying_htlcs_arg);
31651         int64_t ret_ref = 0;
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31654         return ret_ref;
31655 }
31656
31657 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
31658         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
31659         int64_t ret_ref = 0;
31660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31661         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31662         return ret_ref;
31663 }
31664 int64_t  CS_LDK_ChannelConfig_clone_ptr(int64_t arg) {
31665         LDKChannelConfig arg_conv;
31666         arg_conv.inner = untag_ptr(arg);
31667         arg_conv.is_owned = ptr_is_owned(arg);
31668         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31669         arg_conv.is_owned = false;
31670         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
31671         return ret_conv;
31672 }
31673
31674 int64_t  CS_LDK_ChannelConfig_clone(int64_t orig) {
31675         LDKChannelConfig orig_conv;
31676         orig_conv.inner = untag_ptr(orig);
31677         orig_conv.is_owned = ptr_is_owned(orig);
31678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31679         orig_conv.is_owned = false;
31680         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
31681         int64_t ret_ref = 0;
31682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31684         return ret_ref;
31685 }
31686
31687 jboolean  CS_LDK_ChannelConfig_eq(int64_t a, int64_t b) {
31688         LDKChannelConfig a_conv;
31689         a_conv.inner = untag_ptr(a);
31690         a_conv.is_owned = ptr_is_owned(a);
31691         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
31692         a_conv.is_owned = false;
31693         LDKChannelConfig b_conv;
31694         b_conv.inner = untag_ptr(b);
31695         b_conv.is_owned = ptr_is_owned(b);
31696         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
31697         b_conv.is_owned = false;
31698         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
31699         return ret_conv;
31700 }
31701
31702 void  CS_LDK_ChannelConfig_apply(int64_t this_arg, int64_t update) {
31703         LDKChannelConfig this_arg_conv;
31704         this_arg_conv.inner = untag_ptr(this_arg);
31705         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31707         this_arg_conv.is_owned = false;
31708         LDKChannelConfigUpdate update_conv;
31709         update_conv.inner = untag_ptr(update);
31710         update_conv.is_owned = ptr_is_owned(update);
31711         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
31712         update_conv.is_owned = false;
31713         ChannelConfig_apply(&this_arg_conv, &update_conv);
31714 }
31715
31716 int64_t  CS_LDK_ChannelConfig_default() {
31717         LDKChannelConfig ret_var = ChannelConfig_default();
31718         int64_t ret_ref = 0;
31719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31720         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31721         return ret_ref;
31722 }
31723
31724 int8_tArray  CS_LDK_ChannelConfig_write(int64_t obj) {
31725         LDKChannelConfig obj_conv;
31726         obj_conv.inner = untag_ptr(obj);
31727         obj_conv.is_owned = ptr_is_owned(obj);
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31729         obj_conv.is_owned = false;
31730         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
31731         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31732         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31733         CVec_u8Z_free(ret_var);
31734         return ret_arr;
31735 }
31736
31737 int64_t  CS_LDK_ChannelConfig_read(int8_tArray ser) {
31738         LDKu8slice ser_ref;
31739         ser_ref.datalen = ser->arr_len;
31740         ser_ref.data = ser->elems;
31741         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
31742         *ret_conv = ChannelConfig_read(ser_ref);
31743         FREE(ser);
31744         return tag_ptr(ret_conv, true);
31745 }
31746
31747 void  CS_LDK_ChannelConfigUpdate_free(int64_t this_obj) {
31748         LDKChannelConfigUpdate this_obj_conv;
31749         this_obj_conv.inner = untag_ptr(this_obj);
31750         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31752         ChannelConfigUpdate_free(this_obj_conv);
31753 }
31754
31755 int64_t  CS_LDK_ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(int64_t this_ptr) {
31756         LDKChannelConfigUpdate this_ptr_conv;
31757         this_ptr_conv.inner = untag_ptr(this_ptr);
31758         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31760         this_ptr_conv.is_owned = false;
31761         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
31762         *ret_copy = ChannelConfigUpdate_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
31763         int64_t ret_ref = tag_ptr(ret_copy, true);
31764         return ret_ref;
31765 }
31766
31767 void  CS_LDK_ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(int64_t this_ptr, int64_t val) {
31768         LDKChannelConfigUpdate this_ptr_conv;
31769         this_ptr_conv.inner = untag_ptr(this_ptr);
31770         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31772         this_ptr_conv.is_owned = false;
31773         void* val_ptr = untag_ptr(val);
31774         CHECK_ACCESS(val_ptr);
31775         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
31776         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
31777         ChannelConfigUpdate_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val_conv);
31778 }
31779
31780 int64_t  CS_LDK_ChannelConfigUpdate_get_forwarding_fee_base_msat(int64_t this_ptr) {
31781         LDKChannelConfigUpdate this_ptr_conv;
31782         this_ptr_conv.inner = untag_ptr(this_ptr);
31783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31785         this_ptr_conv.is_owned = false;
31786         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
31787         *ret_copy = ChannelConfigUpdate_get_forwarding_fee_base_msat(&this_ptr_conv);
31788         int64_t ret_ref = tag_ptr(ret_copy, true);
31789         return ret_ref;
31790 }
31791
31792 void  CS_LDK_ChannelConfigUpdate_set_forwarding_fee_base_msat(int64_t this_ptr, int64_t val) {
31793         LDKChannelConfigUpdate this_ptr_conv;
31794         this_ptr_conv.inner = untag_ptr(this_ptr);
31795         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31797         this_ptr_conv.is_owned = false;
31798         void* val_ptr = untag_ptr(val);
31799         CHECK_ACCESS(val_ptr);
31800         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
31801         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
31802         ChannelConfigUpdate_set_forwarding_fee_base_msat(&this_ptr_conv, val_conv);
31803 }
31804
31805 int64_t  CS_LDK_ChannelConfigUpdate_get_cltv_expiry_delta(int64_t this_ptr) {
31806         LDKChannelConfigUpdate this_ptr_conv;
31807         this_ptr_conv.inner = untag_ptr(this_ptr);
31808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31810         this_ptr_conv.is_owned = false;
31811         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
31812         *ret_copy = ChannelConfigUpdate_get_cltv_expiry_delta(&this_ptr_conv);
31813         int64_t ret_ref = tag_ptr(ret_copy, true);
31814         return ret_ref;
31815 }
31816
31817 void  CS_LDK_ChannelConfigUpdate_set_cltv_expiry_delta(int64_t this_ptr, int64_t val) {
31818         LDKChannelConfigUpdate this_ptr_conv;
31819         this_ptr_conv.inner = untag_ptr(this_ptr);
31820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31822         this_ptr_conv.is_owned = false;
31823         void* val_ptr = untag_ptr(val);
31824         CHECK_ACCESS(val_ptr);
31825         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
31826         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
31827         ChannelConfigUpdate_set_cltv_expiry_delta(&this_ptr_conv, val_conv);
31828 }
31829
31830 int64_t  CS_LDK_ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(int64_t this_ptr) {
31831         LDKChannelConfigUpdate this_ptr_conv;
31832         this_ptr_conv.inner = untag_ptr(this_ptr);
31833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31835         this_ptr_conv.is_owned = false;
31836         LDKCOption_MaxDustHTLCExposureZ *ret_copy = MALLOC(sizeof(LDKCOption_MaxDustHTLCExposureZ), "LDKCOption_MaxDustHTLCExposureZ");
31837         *ret_copy = ChannelConfigUpdate_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
31838         int64_t ret_ref = tag_ptr(ret_copy, true);
31839         return ret_ref;
31840 }
31841
31842 void  CS_LDK_ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(int64_t this_ptr, int64_t val) {
31843         LDKChannelConfigUpdate this_ptr_conv;
31844         this_ptr_conv.inner = untag_ptr(this_ptr);
31845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31847         this_ptr_conv.is_owned = false;
31848         void* val_ptr = untag_ptr(val);
31849         CHECK_ACCESS(val_ptr);
31850         LDKCOption_MaxDustHTLCExposureZ val_conv = *(LDKCOption_MaxDustHTLCExposureZ*)(val_ptr);
31851         val_conv = COption_MaxDustHTLCExposureZ_clone((LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(val));
31852         ChannelConfigUpdate_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val_conv);
31853 }
31854
31855 int64_t  CS_LDK_ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(int64_t this_ptr) {
31856         LDKChannelConfigUpdate this_ptr_conv;
31857         this_ptr_conv.inner = untag_ptr(this_ptr);
31858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31860         this_ptr_conv.is_owned = false;
31861         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31862         *ret_copy = ChannelConfigUpdate_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
31863         int64_t ret_ref = tag_ptr(ret_copy, true);
31864         return ret_ref;
31865 }
31866
31867 void  CS_LDK_ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(int64_t this_ptr, int64_t val) {
31868         LDKChannelConfigUpdate this_ptr_conv;
31869         this_ptr_conv.inner = untag_ptr(this_ptr);
31870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31872         this_ptr_conv.is_owned = false;
31873         void* val_ptr = untag_ptr(val);
31874         CHECK_ACCESS(val_ptr);
31875         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31876         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31877         ChannelConfigUpdate_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val_conv);
31878 }
31879
31880 int64_t  CS_LDK_ChannelConfigUpdate_new(int64_t forwarding_fee_proportional_millionths_arg, int64_t forwarding_fee_base_msat_arg, int64_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
31881         void* forwarding_fee_proportional_millionths_arg_ptr = untag_ptr(forwarding_fee_proportional_millionths_arg);
31882         CHECK_ACCESS(forwarding_fee_proportional_millionths_arg_ptr);
31883         LDKCOption_u32Z forwarding_fee_proportional_millionths_arg_conv = *(LDKCOption_u32Z*)(forwarding_fee_proportional_millionths_arg_ptr);
31884         forwarding_fee_proportional_millionths_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(forwarding_fee_proportional_millionths_arg));
31885         void* forwarding_fee_base_msat_arg_ptr = untag_ptr(forwarding_fee_base_msat_arg);
31886         CHECK_ACCESS(forwarding_fee_base_msat_arg_ptr);
31887         LDKCOption_u32Z forwarding_fee_base_msat_arg_conv = *(LDKCOption_u32Z*)(forwarding_fee_base_msat_arg_ptr);
31888         forwarding_fee_base_msat_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(forwarding_fee_base_msat_arg));
31889         void* cltv_expiry_delta_arg_ptr = untag_ptr(cltv_expiry_delta_arg);
31890         CHECK_ACCESS(cltv_expiry_delta_arg_ptr);
31891         LDKCOption_u16Z cltv_expiry_delta_arg_conv = *(LDKCOption_u16Z*)(cltv_expiry_delta_arg_ptr);
31892         cltv_expiry_delta_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(cltv_expiry_delta_arg));
31893         void* max_dust_htlc_exposure_msat_arg_ptr = untag_ptr(max_dust_htlc_exposure_msat_arg);
31894         CHECK_ACCESS(max_dust_htlc_exposure_msat_arg_ptr);
31895         LDKCOption_MaxDustHTLCExposureZ max_dust_htlc_exposure_msat_arg_conv = *(LDKCOption_MaxDustHTLCExposureZ*)(max_dust_htlc_exposure_msat_arg_ptr);
31896         max_dust_htlc_exposure_msat_arg_conv = COption_MaxDustHTLCExposureZ_clone((LDKCOption_MaxDustHTLCExposureZ*)untag_ptr(max_dust_htlc_exposure_msat_arg));
31897         void* force_close_avoidance_max_fee_satoshis_arg_ptr = untag_ptr(force_close_avoidance_max_fee_satoshis_arg);
31898         CHECK_ACCESS(force_close_avoidance_max_fee_satoshis_arg_ptr);
31899         LDKCOption_u64Z force_close_avoidance_max_fee_satoshis_arg_conv = *(LDKCOption_u64Z*)(force_close_avoidance_max_fee_satoshis_arg_ptr);
31900         force_close_avoidance_max_fee_satoshis_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(force_close_avoidance_max_fee_satoshis_arg));
31901         LDKChannelConfigUpdate ret_var = ChannelConfigUpdate_new(forwarding_fee_proportional_millionths_arg_conv, forwarding_fee_base_msat_arg_conv, cltv_expiry_delta_arg_conv, max_dust_htlc_exposure_msat_arg_conv, force_close_avoidance_max_fee_satoshis_arg_conv);
31902         int64_t ret_ref = 0;
31903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31905         return ret_ref;
31906 }
31907
31908 int64_t  CS_LDK_ChannelConfigUpdate_default() {
31909         LDKChannelConfigUpdate ret_var = ChannelConfigUpdate_default();
31910         int64_t ret_ref = 0;
31911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31913         return ret_ref;
31914 }
31915
31916 void  CS_LDK_UserConfig_free(int64_t this_obj) {
31917         LDKUserConfig this_obj_conv;
31918         this_obj_conv.inner = untag_ptr(this_obj);
31919         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31921         UserConfig_free(this_obj_conv);
31922 }
31923
31924 int64_t  CS_LDK_UserConfig_get_channel_handshake_config(int64_t this_ptr) {
31925         LDKUserConfig this_ptr_conv;
31926         this_ptr_conv.inner = untag_ptr(this_ptr);
31927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31929         this_ptr_conv.is_owned = false;
31930         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
31931         int64_t ret_ref = 0;
31932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31934         return ret_ref;
31935 }
31936
31937 void  CS_LDK_UserConfig_set_channel_handshake_config(int64_t this_ptr, int64_t val) {
31938         LDKUserConfig this_ptr_conv;
31939         this_ptr_conv.inner = untag_ptr(this_ptr);
31940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31942         this_ptr_conv.is_owned = false;
31943         LDKChannelHandshakeConfig val_conv;
31944         val_conv.inner = untag_ptr(val);
31945         val_conv.is_owned = ptr_is_owned(val);
31946         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31947         val_conv = ChannelHandshakeConfig_clone(&val_conv);
31948         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
31949 }
31950
31951 int64_t  CS_LDK_UserConfig_get_channel_handshake_limits(int64_t this_ptr) {
31952         LDKUserConfig this_ptr_conv;
31953         this_ptr_conv.inner = untag_ptr(this_ptr);
31954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31956         this_ptr_conv.is_owned = false;
31957         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
31958         int64_t ret_ref = 0;
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31961         return ret_ref;
31962 }
31963
31964 void  CS_LDK_UserConfig_set_channel_handshake_limits(int64_t this_ptr, int64_t val) {
31965         LDKUserConfig this_ptr_conv;
31966         this_ptr_conv.inner = untag_ptr(this_ptr);
31967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31969         this_ptr_conv.is_owned = false;
31970         LDKChannelHandshakeLimits val_conv;
31971         val_conv.inner = untag_ptr(val);
31972         val_conv.is_owned = ptr_is_owned(val);
31973         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31974         val_conv = ChannelHandshakeLimits_clone(&val_conv);
31975         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
31976 }
31977
31978 int64_t  CS_LDK_UserConfig_get_channel_config(int64_t this_ptr) {
31979         LDKUserConfig this_ptr_conv;
31980         this_ptr_conv.inner = untag_ptr(this_ptr);
31981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31983         this_ptr_conv.is_owned = false;
31984         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
31985         int64_t ret_ref = 0;
31986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31988         return ret_ref;
31989 }
31990
31991 void  CS_LDK_UserConfig_set_channel_config(int64_t this_ptr, int64_t val) {
31992         LDKUserConfig this_ptr_conv;
31993         this_ptr_conv.inner = untag_ptr(this_ptr);
31994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31996         this_ptr_conv.is_owned = false;
31997         LDKChannelConfig val_conv;
31998         val_conv.inner = untag_ptr(val);
31999         val_conv.is_owned = ptr_is_owned(val);
32000         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32001         val_conv = ChannelConfig_clone(&val_conv);
32002         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
32003 }
32004
32005 jboolean  CS_LDK_UserConfig_get_accept_forwards_to_priv_channels(int64_t this_ptr) {
32006         LDKUserConfig this_ptr_conv;
32007         this_ptr_conv.inner = untag_ptr(this_ptr);
32008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32010         this_ptr_conv.is_owned = false;
32011         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
32012         return ret_conv;
32013 }
32014
32015 void  CS_LDK_UserConfig_set_accept_forwards_to_priv_channels(int64_t this_ptr, jboolean val) {
32016         LDKUserConfig this_ptr_conv;
32017         this_ptr_conv.inner = untag_ptr(this_ptr);
32018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32020         this_ptr_conv.is_owned = false;
32021         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
32022 }
32023
32024 jboolean  CS_LDK_UserConfig_get_accept_inbound_channels(int64_t this_ptr) {
32025         LDKUserConfig this_ptr_conv;
32026         this_ptr_conv.inner = untag_ptr(this_ptr);
32027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32029         this_ptr_conv.is_owned = false;
32030         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
32031         return ret_conv;
32032 }
32033
32034 void  CS_LDK_UserConfig_set_accept_inbound_channels(int64_t this_ptr, jboolean val) {
32035         LDKUserConfig this_ptr_conv;
32036         this_ptr_conv.inner = untag_ptr(this_ptr);
32037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32039         this_ptr_conv.is_owned = false;
32040         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
32041 }
32042
32043 jboolean  CS_LDK_UserConfig_get_manually_accept_inbound_channels(int64_t this_ptr) {
32044         LDKUserConfig this_ptr_conv;
32045         this_ptr_conv.inner = untag_ptr(this_ptr);
32046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32048         this_ptr_conv.is_owned = false;
32049         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
32050         return ret_conv;
32051 }
32052
32053 void  CS_LDK_UserConfig_set_manually_accept_inbound_channels(int64_t this_ptr, jboolean val) {
32054         LDKUserConfig this_ptr_conv;
32055         this_ptr_conv.inner = untag_ptr(this_ptr);
32056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32058         this_ptr_conv.is_owned = false;
32059         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
32060 }
32061
32062 jboolean  CS_LDK_UserConfig_get_accept_intercept_htlcs(int64_t this_ptr) {
32063         LDKUserConfig this_ptr_conv;
32064         this_ptr_conv.inner = untag_ptr(this_ptr);
32065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32067         this_ptr_conv.is_owned = false;
32068         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
32069         return ret_conv;
32070 }
32071
32072 void  CS_LDK_UserConfig_set_accept_intercept_htlcs(int64_t this_ptr, jboolean val) {
32073         LDKUserConfig this_ptr_conv;
32074         this_ptr_conv.inner = untag_ptr(this_ptr);
32075         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32077         this_ptr_conv.is_owned = false;
32078         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
32079 }
32080
32081 jboolean  CS_LDK_UserConfig_get_accept_mpp_keysend(int64_t this_ptr) {
32082         LDKUserConfig this_ptr_conv;
32083         this_ptr_conv.inner = untag_ptr(this_ptr);
32084         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32086         this_ptr_conv.is_owned = false;
32087         jboolean ret_conv = UserConfig_get_accept_mpp_keysend(&this_ptr_conv);
32088         return ret_conv;
32089 }
32090
32091 void  CS_LDK_UserConfig_set_accept_mpp_keysend(int64_t this_ptr, jboolean val) {
32092         LDKUserConfig this_ptr_conv;
32093         this_ptr_conv.inner = untag_ptr(this_ptr);
32094         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32096         this_ptr_conv.is_owned = false;
32097         UserConfig_set_accept_mpp_keysend(&this_ptr_conv, val);
32098 }
32099
32100 int64_t  CS_LDK_UserConfig_new(int64_t channel_handshake_config_arg, int64_t channel_handshake_limits_arg, int64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg, jboolean accept_intercept_htlcs_arg, jboolean accept_mpp_keysend_arg) {
32101         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
32102         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
32103         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
32104         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
32105         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
32106         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
32107         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
32108         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
32109         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
32110         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
32111         LDKChannelConfig channel_config_arg_conv;
32112         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
32113         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
32115         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
32116         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg, accept_intercept_htlcs_arg, accept_mpp_keysend_arg);
32117         int64_t ret_ref = 0;
32118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32120         return ret_ref;
32121 }
32122
32123 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
32124         LDKUserConfig ret_var = UserConfig_clone(arg);
32125         int64_t ret_ref = 0;
32126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32128         return ret_ref;
32129 }
32130 int64_t  CS_LDK_UserConfig_clone_ptr(int64_t arg) {
32131         LDKUserConfig arg_conv;
32132         arg_conv.inner = untag_ptr(arg);
32133         arg_conv.is_owned = ptr_is_owned(arg);
32134         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32135         arg_conv.is_owned = false;
32136         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
32137         return ret_conv;
32138 }
32139
32140 int64_t  CS_LDK_UserConfig_clone(int64_t orig) {
32141         LDKUserConfig orig_conv;
32142         orig_conv.inner = untag_ptr(orig);
32143         orig_conv.is_owned = ptr_is_owned(orig);
32144         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32145         orig_conv.is_owned = false;
32146         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
32147         int64_t ret_ref = 0;
32148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32150         return ret_ref;
32151 }
32152
32153 int64_t  CS_LDK_UserConfig_default() {
32154         LDKUserConfig ret_var = UserConfig_default();
32155         int64_t ret_ref = 0;
32156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32158         return ret_ref;
32159 }
32160
32161 void  CS_LDK_BestBlock_free(int64_t this_obj) {
32162         LDKBestBlock this_obj_conv;
32163         this_obj_conv.inner = untag_ptr(this_obj);
32164         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32166         BestBlock_free(this_obj_conv);
32167 }
32168
32169 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
32170         LDKBestBlock ret_var = BestBlock_clone(arg);
32171         int64_t ret_ref = 0;
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32173         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32174         return ret_ref;
32175 }
32176 int64_t  CS_LDK_BestBlock_clone_ptr(int64_t arg) {
32177         LDKBestBlock arg_conv;
32178         arg_conv.inner = untag_ptr(arg);
32179         arg_conv.is_owned = ptr_is_owned(arg);
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32181         arg_conv.is_owned = false;
32182         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
32183         return ret_conv;
32184 }
32185
32186 int64_t  CS_LDK_BestBlock_clone(int64_t orig) {
32187         LDKBestBlock orig_conv;
32188         orig_conv.inner = untag_ptr(orig);
32189         orig_conv.is_owned = ptr_is_owned(orig);
32190         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32191         orig_conv.is_owned = false;
32192         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
32193         int64_t ret_ref = 0;
32194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32195         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32196         return ret_ref;
32197 }
32198
32199 jboolean  CS_LDK_BestBlock_eq(int64_t a, int64_t b) {
32200         LDKBestBlock a_conv;
32201         a_conv.inner = untag_ptr(a);
32202         a_conv.is_owned = ptr_is_owned(a);
32203         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32204         a_conv.is_owned = false;
32205         LDKBestBlock b_conv;
32206         b_conv.inner = untag_ptr(b);
32207         b_conv.is_owned = ptr_is_owned(b);
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32209         b_conv.is_owned = false;
32210         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
32211         return ret_conv;
32212 }
32213
32214 int64_t  CS_LDK_BestBlock_from_network(int32_t network) {
32215         LDKNetwork network_conv = LDKNetwork_from_cs(network);
32216         LDKBestBlock ret_var = BestBlock_from_network(network_conv);
32217         int64_t ret_ref = 0;
32218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32219         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32220         return ret_ref;
32221 }
32222
32223 int64_t  CS_LDK_BestBlock_new(int8_tArray block_hash, int32_t height) {
32224         LDKThirtyTwoBytes block_hash_ref;
32225         CHECK(block_hash->arr_len == 32);
32226         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
32227         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
32228         int64_t ret_ref = 0;
32229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32230         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32231         return ret_ref;
32232 }
32233
32234 int8_tArray  CS_LDK_BestBlock_block_hash(int64_t this_arg) {
32235         LDKBestBlock this_arg_conv;
32236         this_arg_conv.inner = untag_ptr(this_arg);
32237         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32239         this_arg_conv.is_owned = false;
32240         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32241         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
32242         return ret_arr;
32243 }
32244
32245 int32_t  CS_LDK_BestBlock_height(int64_t this_arg) {
32246         LDKBestBlock this_arg_conv;
32247         this_arg_conv.inner = untag_ptr(this_arg);
32248         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32250         this_arg_conv.is_owned = false;
32251         int32_t ret_conv = BestBlock_height(&this_arg_conv);
32252         return ret_conv;
32253 }
32254
32255 void  CS_LDK_Listen_free(int64_t this_ptr) {
32256         if (!ptr_is_owned(this_ptr)) return;
32257         void* this_ptr_ptr = untag_ptr(this_ptr);
32258         CHECK_ACCESS(this_ptr_ptr);
32259         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
32260         FREE(untag_ptr(this_ptr));
32261         Listen_free(this_ptr_conv);
32262 }
32263
32264 void  CS_LDK_Confirm_free(int64_t this_ptr) {
32265         if (!ptr_is_owned(this_ptr)) return;
32266         void* this_ptr_ptr = untag_ptr(this_ptr);
32267         CHECK_ACCESS(this_ptr_ptr);
32268         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
32269         FREE(untag_ptr(this_ptr));
32270         Confirm_free(this_ptr_conv);
32271 }
32272
32273 int32_t  CS_LDK_ChannelMonitorUpdateStatus_clone(int64_t orig) {
32274         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
32275         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_clone(orig_conv));
32276         return ret_conv;
32277 }
32278
32279 int32_t  CS_LDK_ChannelMonitorUpdateStatus_completed() {
32280         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_completed());
32281         return ret_conv;
32282 }
32283
32284 int32_t  CS_LDK_ChannelMonitorUpdateStatus_in_progress() {
32285         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_in_progress());
32286         return ret_conv;
32287 }
32288
32289 int32_t  CS_LDK_ChannelMonitorUpdateStatus_unrecoverable_error() {
32290         int32_t ret_conv = LDKChannelMonitorUpdateStatus_to_cs(ChannelMonitorUpdateStatus_unrecoverable_error());
32291         return ret_conv;
32292 }
32293
32294 jboolean  CS_LDK_ChannelMonitorUpdateStatus_eq(int64_t a, int64_t b) {
32295         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
32296         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
32297         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
32298         return ret_conv;
32299 }
32300
32301 void  CS_LDK_Watch_free(int64_t this_ptr) {
32302         if (!ptr_is_owned(this_ptr)) return;
32303         void* this_ptr_ptr = untag_ptr(this_ptr);
32304         CHECK_ACCESS(this_ptr_ptr);
32305         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
32306         FREE(untag_ptr(this_ptr));
32307         Watch_free(this_ptr_conv);
32308 }
32309
32310 void  CS_LDK_Filter_free(int64_t this_ptr) {
32311         if (!ptr_is_owned(this_ptr)) return;
32312         void* this_ptr_ptr = untag_ptr(this_ptr);
32313         CHECK_ACCESS(this_ptr_ptr);
32314         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
32315         FREE(untag_ptr(this_ptr));
32316         Filter_free(this_ptr_conv);
32317 }
32318
32319 void  CS_LDK_WatchedOutput_free(int64_t this_obj) {
32320         LDKWatchedOutput this_obj_conv;
32321         this_obj_conv.inner = untag_ptr(this_obj);
32322         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32324         WatchedOutput_free(this_obj_conv);
32325 }
32326
32327 int64_t  CS_LDK_WatchedOutput_get_block_hash(int64_t this_ptr) {
32328         LDKWatchedOutput this_ptr_conv;
32329         this_ptr_conv.inner = untag_ptr(this_ptr);
32330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32332         this_ptr_conv.is_owned = false;
32333         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
32334         *ret_copy = WatchedOutput_get_block_hash(&this_ptr_conv);
32335         int64_t ret_ref = tag_ptr(ret_copy, true);
32336         return ret_ref;
32337 }
32338
32339 void  CS_LDK_WatchedOutput_set_block_hash(int64_t this_ptr, int64_t val) {
32340         LDKWatchedOutput this_ptr_conv;
32341         this_ptr_conv.inner = untag_ptr(this_ptr);
32342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32344         this_ptr_conv.is_owned = false;
32345         void* val_ptr = untag_ptr(val);
32346         CHECK_ACCESS(val_ptr);
32347         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
32348         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
32349         WatchedOutput_set_block_hash(&this_ptr_conv, val_conv);
32350 }
32351
32352 int64_t  CS_LDK_WatchedOutput_get_outpoint(int64_t this_ptr) {
32353         LDKWatchedOutput this_ptr_conv;
32354         this_ptr_conv.inner = untag_ptr(this_ptr);
32355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32357         this_ptr_conv.is_owned = false;
32358         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
32359         int64_t ret_ref = 0;
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32362         return ret_ref;
32363 }
32364
32365 void  CS_LDK_WatchedOutput_set_outpoint(int64_t this_ptr, int64_t val) {
32366         LDKWatchedOutput this_ptr_conv;
32367         this_ptr_conv.inner = untag_ptr(this_ptr);
32368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32370         this_ptr_conv.is_owned = false;
32371         LDKOutPoint val_conv;
32372         val_conv.inner = untag_ptr(val);
32373         val_conv.is_owned = ptr_is_owned(val);
32374         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32375         val_conv = OutPoint_clone(&val_conv);
32376         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
32377 }
32378
32379 int8_tArray  CS_LDK_WatchedOutput_get_script_pubkey(int64_t this_ptr) {
32380         LDKWatchedOutput this_ptr_conv;
32381         this_ptr_conv.inner = untag_ptr(this_ptr);
32382         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32384         this_ptr_conv.is_owned = false;
32385         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
32386         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32387         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32388         return ret_arr;
32389 }
32390
32391 void  CS_LDK_WatchedOutput_set_script_pubkey(int64_t this_ptr, int8_tArray val) {
32392         LDKWatchedOutput this_ptr_conv;
32393         this_ptr_conv.inner = untag_ptr(this_ptr);
32394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32396         this_ptr_conv.is_owned = false;
32397         LDKCVec_u8Z val_ref;
32398         val_ref.datalen = val->arr_len;
32399         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
32400         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
32401         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
32402 }
32403
32404 int64_t  CS_LDK_WatchedOutput_new(int64_t block_hash_arg, int64_t outpoint_arg, int8_tArray script_pubkey_arg) {
32405         void* block_hash_arg_ptr = untag_ptr(block_hash_arg);
32406         CHECK_ACCESS(block_hash_arg_ptr);
32407         LDKCOption_ThirtyTwoBytesZ block_hash_arg_conv = *(LDKCOption_ThirtyTwoBytesZ*)(block_hash_arg_ptr);
32408         block_hash_arg_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(block_hash_arg));
32409         LDKOutPoint outpoint_arg_conv;
32410         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
32411         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
32412         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
32413         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
32414         LDKCVec_u8Z script_pubkey_arg_ref;
32415         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
32416         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
32417         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
32418         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_conv, outpoint_arg_conv, script_pubkey_arg_ref);
32419         int64_t ret_ref = 0;
32420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32422         return ret_ref;
32423 }
32424
32425 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
32426         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
32427         int64_t ret_ref = 0;
32428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32429         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32430         return ret_ref;
32431 }
32432 int64_t  CS_LDK_WatchedOutput_clone_ptr(int64_t arg) {
32433         LDKWatchedOutput arg_conv;
32434         arg_conv.inner = untag_ptr(arg);
32435         arg_conv.is_owned = ptr_is_owned(arg);
32436         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32437         arg_conv.is_owned = false;
32438         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
32439         return ret_conv;
32440 }
32441
32442 int64_t  CS_LDK_WatchedOutput_clone(int64_t orig) {
32443         LDKWatchedOutput orig_conv;
32444         orig_conv.inner = untag_ptr(orig);
32445         orig_conv.is_owned = ptr_is_owned(orig);
32446         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32447         orig_conv.is_owned = false;
32448         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
32449         int64_t ret_ref = 0;
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32451         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32452         return ret_ref;
32453 }
32454
32455 jboolean  CS_LDK_WatchedOutput_eq(int64_t a, int64_t b) {
32456         LDKWatchedOutput a_conv;
32457         a_conv.inner = untag_ptr(a);
32458         a_conv.is_owned = ptr_is_owned(a);
32459         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32460         a_conv.is_owned = false;
32461         LDKWatchedOutput b_conv;
32462         b_conv.inner = untag_ptr(b);
32463         b_conv.is_owned = ptr_is_owned(b);
32464         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32465         b_conv.is_owned = false;
32466         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
32467         return ret_conv;
32468 }
32469
32470 int64_t  CS_LDK_WatchedOutput_hash(int64_t o) {
32471         LDKWatchedOutput o_conv;
32472         o_conv.inner = untag_ptr(o);
32473         o_conv.is_owned = ptr_is_owned(o);
32474         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32475         o_conv.is_owned = false;
32476         int64_t ret_conv = WatchedOutput_hash(&o_conv);
32477         return ret_conv;
32478 }
32479
32480 void  CS_LDK_BroadcasterInterface_free(int64_t this_ptr) {
32481         if (!ptr_is_owned(this_ptr)) return;
32482         void* this_ptr_ptr = untag_ptr(this_ptr);
32483         CHECK_ACCESS(this_ptr_ptr);
32484         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
32485         FREE(untag_ptr(this_ptr));
32486         BroadcasterInterface_free(this_ptr_conv);
32487 }
32488
32489 int32_t  CS_LDK_ConfirmationTarget_clone(int64_t orig) {
32490         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
32491         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_clone(orig_conv));
32492         return ret_conv;
32493 }
32494
32495 int32_t  CS_LDK_ConfirmationTarget_on_chain_sweep() {
32496         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_on_chain_sweep());
32497         return ret_conv;
32498 }
32499
32500 int32_t  CS_LDK_ConfirmationTarget_max_allowed_non_anchor_channel_remote_fee() {
32501         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_max_allowed_non_anchor_channel_remote_fee());
32502         return ret_conv;
32503 }
32504
32505 int32_t  CS_LDK_ConfirmationTarget_min_allowed_anchor_channel_remote_fee() {
32506         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_min_allowed_anchor_channel_remote_fee());
32507         return ret_conv;
32508 }
32509
32510 int32_t  CS_LDK_ConfirmationTarget_min_allowed_non_anchor_channel_remote_fee() {
32511         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_min_allowed_non_anchor_channel_remote_fee());
32512         return ret_conv;
32513 }
32514
32515 int32_t  CS_LDK_ConfirmationTarget_anchor_channel_fee() {
32516         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_anchor_channel_fee());
32517         return ret_conv;
32518 }
32519
32520 int32_t  CS_LDK_ConfirmationTarget_non_anchor_channel_fee() {
32521         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_non_anchor_channel_fee());
32522         return ret_conv;
32523 }
32524
32525 int32_t  CS_LDK_ConfirmationTarget_channel_close_minimum() {
32526         int32_t ret_conv = LDKConfirmationTarget_to_cs(ConfirmationTarget_channel_close_minimum());
32527         return ret_conv;
32528 }
32529
32530 int64_t  CS_LDK_ConfirmationTarget_hash(int64_t o) {
32531         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
32532         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
32533         return ret_conv;
32534 }
32535
32536 jboolean  CS_LDK_ConfirmationTarget_eq(int64_t a, int64_t b) {
32537         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
32538         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
32539         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
32540         return ret_conv;
32541 }
32542
32543 void  CS_LDK_FeeEstimator_free(int64_t this_ptr) {
32544         if (!ptr_is_owned(this_ptr)) return;
32545         void* this_ptr_ptr = untag_ptr(this_ptr);
32546         CHECK_ACCESS(this_ptr_ptr);
32547         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
32548         FREE(untag_ptr(this_ptr));
32549         FeeEstimator_free(this_ptr_conv);
32550 }
32551
32552 void  CS_LDK_MonitorUpdateId_free(int64_t this_obj) {
32553         LDKMonitorUpdateId this_obj_conv;
32554         this_obj_conv.inner = untag_ptr(this_obj);
32555         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32557         MonitorUpdateId_free(this_obj_conv);
32558 }
32559
32560 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
32561         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
32562         int64_t ret_ref = 0;
32563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32564         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32565         return ret_ref;
32566 }
32567 int64_t  CS_LDK_MonitorUpdateId_clone_ptr(int64_t arg) {
32568         LDKMonitorUpdateId arg_conv;
32569         arg_conv.inner = untag_ptr(arg);
32570         arg_conv.is_owned = ptr_is_owned(arg);
32571         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32572         arg_conv.is_owned = false;
32573         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
32574         return ret_conv;
32575 }
32576
32577 int64_t  CS_LDK_MonitorUpdateId_clone(int64_t orig) {
32578         LDKMonitorUpdateId orig_conv;
32579         orig_conv.inner = untag_ptr(orig);
32580         orig_conv.is_owned = ptr_is_owned(orig);
32581         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32582         orig_conv.is_owned = false;
32583         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
32584         int64_t ret_ref = 0;
32585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32587         return ret_ref;
32588 }
32589
32590 int64_t  CS_LDK_MonitorUpdateId_hash(int64_t o) {
32591         LDKMonitorUpdateId o_conv;
32592         o_conv.inner = untag_ptr(o);
32593         o_conv.is_owned = ptr_is_owned(o);
32594         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32595         o_conv.is_owned = false;
32596         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
32597         return ret_conv;
32598 }
32599
32600 jboolean  CS_LDK_MonitorUpdateId_eq(int64_t a, int64_t b) {
32601         LDKMonitorUpdateId a_conv;
32602         a_conv.inner = untag_ptr(a);
32603         a_conv.is_owned = ptr_is_owned(a);
32604         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32605         a_conv.is_owned = false;
32606         LDKMonitorUpdateId b_conv;
32607         b_conv.inner = untag_ptr(b);
32608         b_conv.is_owned = ptr_is_owned(b);
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32610         b_conv.is_owned = false;
32611         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
32612         return ret_conv;
32613 }
32614
32615 void  CS_LDK_Persist_free(int64_t this_ptr) {
32616         if (!ptr_is_owned(this_ptr)) return;
32617         void* this_ptr_ptr = untag_ptr(this_ptr);
32618         CHECK_ACCESS(this_ptr_ptr);
32619         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
32620         FREE(untag_ptr(this_ptr));
32621         Persist_free(this_ptr_conv);
32622 }
32623
32624 void  CS_LDK_LockedChannelMonitor_free(int64_t this_obj) {
32625         LDKLockedChannelMonitor this_obj_conv;
32626         this_obj_conv.inner = untag_ptr(this_obj);
32627         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32629         LockedChannelMonitor_free(this_obj_conv);
32630 }
32631
32632 void  CS_LDK_ChainMonitor_free(int64_t this_obj) {
32633         LDKChainMonitor this_obj_conv;
32634         this_obj_conv.inner = untag_ptr(this_obj);
32635         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32637         ChainMonitor_free(this_obj_conv);
32638 }
32639
32640 int64_t  CS_LDK_ChainMonitor_new(int64_t chain_source, int64_t broadcaster, int64_t logger, int64_t feeest, int64_t persister) {
32641         void* chain_source_ptr = untag_ptr(chain_source);
32642         CHECK_ACCESS(chain_source_ptr);
32643         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
32644         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
32645         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
32646                 // Manually implement clone for Java trait instances
32647                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
32648                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32649                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
32650                 }
32651         }
32652         void* broadcaster_ptr = untag_ptr(broadcaster);
32653         CHECK_ACCESS(broadcaster_ptr);
32654         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
32655         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
32656                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32657                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
32658         }
32659         void* logger_ptr = untag_ptr(logger);
32660         CHECK_ACCESS(logger_ptr);
32661         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32662         if (logger_conv.free == LDKLogger_JCalls_free) {
32663                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32664                 LDKLogger_JCalls_cloned(&logger_conv);
32665         }
32666         void* feeest_ptr = untag_ptr(feeest);
32667         CHECK_ACCESS(feeest_ptr);
32668         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
32669         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
32670                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32671                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
32672         }
32673         void* persister_ptr = untag_ptr(persister);
32674         CHECK_ACCESS(persister_ptr);
32675         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
32676         if (persister_conv.free == LDKPersist_JCalls_free) {
32677                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32678                 LDKPersist_JCalls_cloned(&persister_conv);
32679         }
32680         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
32681         int64_t ret_ref = 0;
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32684         return ret_ref;
32685 }
32686
32687 int64_tArray  CS_LDK_ChainMonitor_get_claimable_balances(int64_t this_arg, int64_tArray ignored_channels) {
32688         LDKChainMonitor this_arg_conv;
32689         this_arg_conv.inner = untag_ptr(this_arg);
32690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32692         this_arg_conv.is_owned = false;
32693         LDKCVec_ChannelDetailsZ ignored_channels_constr;
32694         ignored_channels_constr.datalen = ignored_channels->arr_len;
32695         if (ignored_channels_constr.datalen > 0)
32696                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
32697         else
32698                 ignored_channels_constr.data = NULL;
32699         int64_t* ignored_channels_vals = ignored_channels->elems;
32700         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
32701                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
32702                 LDKChannelDetails ignored_channels_conv_16_conv;
32703                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
32704                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
32705                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
32706                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
32707                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
32708         }
32709         FREE(ignored_channels);
32710         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
32711         int64_tArray ret_arr = NULL;
32712         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32713         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32714         for (size_t j = 0; j < ret_var.datalen; j++) {
32715                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
32716                 *ret_conv_9_copy = ret_var.data[j];
32717                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
32718                 ret_arr_ptr[j] = ret_conv_9_ref;
32719         }
32720         
32721         FREE(ret_var.data);
32722         return ret_arr;
32723 }
32724
32725 int64_t  CS_LDK_ChainMonitor_get_monitor(int64_t this_arg, int64_t funding_txo) {
32726         LDKChainMonitor this_arg_conv;
32727         this_arg_conv.inner = untag_ptr(this_arg);
32728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32730         this_arg_conv.is_owned = false;
32731         LDKOutPoint funding_txo_conv;
32732         funding_txo_conv.inner = untag_ptr(funding_txo);
32733         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
32734         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
32735         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
32736         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
32737         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
32738         return tag_ptr(ret_conv, true);
32739 }
32740
32741 int64_tArray  CS_LDK_ChainMonitor_list_monitors(int64_t this_arg) {
32742         LDKChainMonitor this_arg_conv;
32743         this_arg_conv.inner = untag_ptr(this_arg);
32744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32746         this_arg_conv.is_owned = false;
32747         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
32748         int64_tArray ret_arr = NULL;
32749         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32750         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32751         for (size_t k = 0; k < ret_var.datalen; k++) {
32752                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
32753                 int64_t ret_conv_10_ref = 0;
32754                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
32755                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
32756                 ret_arr_ptr[k] = ret_conv_10_ref;
32757         }
32758         
32759         FREE(ret_var.data);
32760         return ret_arr;
32761 }
32762
32763 int64_tArray  CS_LDK_ChainMonitor_list_pending_monitor_updates(int64_t this_arg) {
32764         LDKChainMonitor this_arg_conv;
32765         this_arg_conv.inner = untag_ptr(this_arg);
32766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32768         this_arg_conv.is_owned = false;
32769         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
32770         int64_tArray ret_arr = NULL;
32771         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
32772         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
32773         for (size_t p = 0; p < ret_var.datalen; p++) {
32774                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
32775                 *ret_conv_41_conv = ret_var.data[p];
32776                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
32777         }
32778         
32779         FREE(ret_var.data);
32780         return ret_arr;
32781 }
32782
32783 int64_t  CS_LDK_ChainMonitor_channel_monitor_updated(int64_t this_arg, int64_t funding_txo, int64_t completed_update_id) {
32784         LDKChainMonitor this_arg_conv;
32785         this_arg_conv.inner = untag_ptr(this_arg);
32786         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32788         this_arg_conv.is_owned = false;
32789         LDKOutPoint funding_txo_conv;
32790         funding_txo_conv.inner = untag_ptr(funding_txo);
32791         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
32792         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
32793         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
32794         LDKMonitorUpdateId completed_update_id_conv;
32795         completed_update_id_conv.inner = untag_ptr(completed_update_id);
32796         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
32797         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
32798         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
32799         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32800         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
32801         return tag_ptr(ret_conv, true);
32802 }
32803
32804 int64_t  CS_LDK_ChainMonitor_get_update_future(int64_t this_arg) {
32805         LDKChainMonitor this_arg_conv;
32806         this_arg_conv.inner = untag_ptr(this_arg);
32807         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32809         this_arg_conv.is_owned = false;
32810         LDKFuture ret_var = ChainMonitor_get_update_future(&this_arg_conv);
32811         int64_t ret_ref = 0;
32812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32813         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32814         return ret_ref;
32815 }
32816
32817 void  CS_LDK_ChainMonitor_rebroadcast_pending_claims(int64_t this_arg) {
32818         LDKChainMonitor this_arg_conv;
32819         this_arg_conv.inner = untag_ptr(this_arg);
32820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32822         this_arg_conv.is_owned = false;
32823         ChainMonitor_rebroadcast_pending_claims(&this_arg_conv);
32824 }
32825
32826 int64_t  CS_LDK_ChainMonitor_as_Listen(int64_t this_arg) {
32827         LDKChainMonitor this_arg_conv;
32828         this_arg_conv.inner = untag_ptr(this_arg);
32829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32831         this_arg_conv.is_owned = false;
32832         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
32833         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
32834         return tag_ptr(ret_ret, true);
32835 }
32836
32837 int64_t  CS_LDK_ChainMonitor_as_Confirm(int64_t this_arg) {
32838         LDKChainMonitor this_arg_conv;
32839         this_arg_conv.inner = untag_ptr(this_arg);
32840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32842         this_arg_conv.is_owned = false;
32843         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
32844         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
32845         return tag_ptr(ret_ret, true);
32846 }
32847
32848 int64_t  CS_LDK_ChainMonitor_as_Watch(int64_t this_arg) {
32849         LDKChainMonitor this_arg_conv;
32850         this_arg_conv.inner = untag_ptr(this_arg);
32851         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32853         this_arg_conv.is_owned = false;
32854         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
32855         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
32856         return tag_ptr(ret_ret, true);
32857 }
32858
32859 int64_t  CS_LDK_ChainMonitor_as_EventsProvider(int64_t this_arg) {
32860         LDKChainMonitor this_arg_conv;
32861         this_arg_conv.inner = untag_ptr(this_arg);
32862         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32864         this_arg_conv.is_owned = false;
32865         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
32866         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
32867         return tag_ptr(ret_ret, true);
32868 }
32869
32870 void  CS_LDK_ChannelMonitorUpdate_free(int64_t this_obj) {
32871         LDKChannelMonitorUpdate this_obj_conv;
32872         this_obj_conv.inner = untag_ptr(this_obj);
32873         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32875         ChannelMonitorUpdate_free(this_obj_conv);
32876 }
32877
32878 int64_t  CS_LDK_ChannelMonitorUpdate_get_update_id(int64_t this_ptr) {
32879         LDKChannelMonitorUpdate this_ptr_conv;
32880         this_ptr_conv.inner = untag_ptr(this_ptr);
32881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32883         this_ptr_conv.is_owned = false;
32884         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
32885         return ret_conv;
32886 }
32887
32888 void  CS_LDK_ChannelMonitorUpdate_set_update_id(int64_t this_ptr, int64_t val) {
32889         LDKChannelMonitorUpdate this_ptr_conv;
32890         this_ptr_conv.inner = untag_ptr(this_ptr);
32891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32893         this_ptr_conv.is_owned = false;
32894         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
32895 }
32896
32897 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
32898         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
32899         int64_t ret_ref = 0;
32900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32902         return ret_ref;
32903 }
32904 int64_t  CS_LDK_ChannelMonitorUpdate_clone_ptr(int64_t arg) {
32905         LDKChannelMonitorUpdate arg_conv;
32906         arg_conv.inner = untag_ptr(arg);
32907         arg_conv.is_owned = ptr_is_owned(arg);
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32909         arg_conv.is_owned = false;
32910         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
32911         return ret_conv;
32912 }
32913
32914 int64_t  CS_LDK_ChannelMonitorUpdate_clone(int64_t orig) {
32915         LDKChannelMonitorUpdate orig_conv;
32916         orig_conv.inner = untag_ptr(orig);
32917         orig_conv.is_owned = ptr_is_owned(orig);
32918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32919         orig_conv.is_owned = false;
32920         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
32921         int64_t ret_ref = 0;
32922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32923         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32924         return ret_ref;
32925 }
32926
32927 jboolean  CS_LDK_ChannelMonitorUpdate_eq(int64_t a, int64_t b) {
32928         LDKChannelMonitorUpdate a_conv;
32929         a_conv.inner = untag_ptr(a);
32930         a_conv.is_owned = ptr_is_owned(a);
32931         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32932         a_conv.is_owned = false;
32933         LDKChannelMonitorUpdate b_conv;
32934         b_conv.inner = untag_ptr(b);
32935         b_conv.is_owned = ptr_is_owned(b);
32936         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32937         b_conv.is_owned = false;
32938         jboolean ret_conv = ChannelMonitorUpdate_eq(&a_conv, &b_conv);
32939         return ret_conv;
32940 }
32941
32942 int8_tArray  CS_LDK_ChannelMonitorUpdate_write(int64_t obj) {
32943         LDKChannelMonitorUpdate obj_conv;
32944         obj_conv.inner = untag_ptr(obj);
32945         obj_conv.is_owned = ptr_is_owned(obj);
32946         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32947         obj_conv.is_owned = false;
32948         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
32949         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32950         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32951         CVec_u8Z_free(ret_var);
32952         return ret_arr;
32953 }
32954
32955 int64_t  CS_LDK_ChannelMonitorUpdate_read(int8_tArray ser) {
32956         LDKu8slice ser_ref;
32957         ser_ref.datalen = ser->arr_len;
32958         ser_ref.data = ser->elems;
32959         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
32960         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
32961         FREE(ser);
32962         return tag_ptr(ret_conv, true);
32963 }
32964
32965 void  CS_LDK_MonitorEvent_free(int64_t this_ptr) {
32966         if (!ptr_is_owned(this_ptr)) return;
32967         void* this_ptr_ptr = untag_ptr(this_ptr);
32968         CHECK_ACCESS(this_ptr_ptr);
32969         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
32970         FREE(untag_ptr(this_ptr));
32971         MonitorEvent_free(this_ptr_conv);
32972 }
32973
32974 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
32975         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
32976         *ret_copy = MonitorEvent_clone(arg);
32977         int64_t ret_ref = tag_ptr(ret_copy, true);
32978         return ret_ref;
32979 }
32980 int64_t  CS_LDK_MonitorEvent_clone_ptr(int64_t arg) {
32981         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
32982         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
32983         return ret_conv;
32984 }
32985
32986 int64_t  CS_LDK_MonitorEvent_clone(int64_t orig) {
32987         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
32988         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
32989         *ret_copy = MonitorEvent_clone(orig_conv);
32990         int64_t ret_ref = tag_ptr(ret_copy, true);
32991         return ret_ref;
32992 }
32993
32994 int64_t  CS_LDK_MonitorEvent_htlcevent(int64_t a) {
32995         LDKHTLCUpdate a_conv;
32996         a_conv.inner = untag_ptr(a);
32997         a_conv.is_owned = ptr_is_owned(a);
32998         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32999         a_conv = HTLCUpdate_clone(&a_conv);
33000         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33001         *ret_copy = MonitorEvent_htlcevent(a_conv);
33002         int64_t ret_ref = tag_ptr(ret_copy, true);
33003         return ret_ref;
33004 }
33005
33006 int64_t  CS_LDK_MonitorEvent_holder_force_closed(int64_t a) {
33007         LDKOutPoint a_conv;
33008         a_conv.inner = untag_ptr(a);
33009         a_conv.is_owned = ptr_is_owned(a);
33010         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33011         a_conv = OutPoint_clone(&a_conv);
33012         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33013         *ret_copy = MonitorEvent_holder_force_closed(a_conv);
33014         int64_t ret_ref = tag_ptr(ret_copy, true);
33015         return ret_ref;
33016 }
33017
33018 int64_t  CS_LDK_MonitorEvent_completed(int64_t funding_txo, int64_t monitor_update_id) {
33019         LDKOutPoint funding_txo_conv;
33020         funding_txo_conv.inner = untag_ptr(funding_txo);
33021         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
33022         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
33023         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
33024         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33025         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
33026         int64_t ret_ref = tag_ptr(ret_copy, true);
33027         return ret_ref;
33028 }
33029
33030 jboolean  CS_LDK_MonitorEvent_eq(int64_t a, int64_t b) {
33031         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
33032         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
33033         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
33034         return ret_conv;
33035 }
33036
33037 int8_tArray  CS_LDK_MonitorEvent_write(int64_t obj) {
33038         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
33039         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
33040         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33041         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33042         CVec_u8Z_free(ret_var);
33043         return ret_arr;
33044 }
33045
33046 int64_t  CS_LDK_MonitorEvent_read(int8_tArray ser) {
33047         LDKu8slice ser_ref;
33048         ser_ref.datalen = ser->arr_len;
33049         ser_ref.data = ser->elems;
33050         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
33051         *ret_conv = MonitorEvent_read(ser_ref);
33052         FREE(ser);
33053         return tag_ptr(ret_conv, true);
33054 }
33055
33056 void  CS_LDK_HTLCUpdate_free(int64_t this_obj) {
33057         LDKHTLCUpdate this_obj_conv;
33058         this_obj_conv.inner = untag_ptr(this_obj);
33059         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33061         HTLCUpdate_free(this_obj_conv);
33062 }
33063
33064 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
33065         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
33066         int64_t ret_ref = 0;
33067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33069         return ret_ref;
33070 }
33071 int64_t  CS_LDK_HTLCUpdate_clone_ptr(int64_t arg) {
33072         LDKHTLCUpdate arg_conv;
33073         arg_conv.inner = untag_ptr(arg);
33074         arg_conv.is_owned = ptr_is_owned(arg);
33075         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33076         arg_conv.is_owned = false;
33077         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
33078         return ret_conv;
33079 }
33080
33081 int64_t  CS_LDK_HTLCUpdate_clone(int64_t orig) {
33082         LDKHTLCUpdate orig_conv;
33083         orig_conv.inner = untag_ptr(orig);
33084         orig_conv.is_owned = ptr_is_owned(orig);
33085         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33086         orig_conv.is_owned = false;
33087         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
33088         int64_t ret_ref = 0;
33089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33091         return ret_ref;
33092 }
33093
33094 jboolean  CS_LDK_HTLCUpdate_eq(int64_t a, int64_t b) {
33095         LDKHTLCUpdate a_conv;
33096         a_conv.inner = untag_ptr(a);
33097         a_conv.is_owned = ptr_is_owned(a);
33098         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33099         a_conv.is_owned = false;
33100         LDKHTLCUpdate b_conv;
33101         b_conv.inner = untag_ptr(b);
33102         b_conv.is_owned = ptr_is_owned(b);
33103         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33104         b_conv.is_owned = false;
33105         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
33106         return ret_conv;
33107 }
33108
33109 int8_tArray  CS_LDK_HTLCUpdate_write(int64_t obj) {
33110         LDKHTLCUpdate obj_conv;
33111         obj_conv.inner = untag_ptr(obj);
33112         obj_conv.is_owned = ptr_is_owned(obj);
33113         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33114         obj_conv.is_owned = false;
33115         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
33116         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33117         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33118         CVec_u8Z_free(ret_var);
33119         return ret_arr;
33120 }
33121
33122 int64_t  CS_LDK_HTLCUpdate_read(int8_tArray ser) {
33123         LDKu8slice ser_ref;
33124         ser_ref.datalen = ser->arr_len;
33125         ser_ref.data = ser->elems;
33126         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
33127         *ret_conv = HTLCUpdate_read(ser_ref);
33128         FREE(ser);
33129         return tag_ptr(ret_conv, true);
33130 }
33131
33132 void  CS_LDK_Balance_free(int64_t this_ptr) {
33133         if (!ptr_is_owned(this_ptr)) return;
33134         void* this_ptr_ptr = untag_ptr(this_ptr);
33135         CHECK_ACCESS(this_ptr_ptr);
33136         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
33137         FREE(untag_ptr(this_ptr));
33138         Balance_free(this_ptr_conv);
33139 }
33140
33141 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
33142         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33143         *ret_copy = Balance_clone(arg);
33144         int64_t ret_ref = tag_ptr(ret_copy, true);
33145         return ret_ref;
33146 }
33147 int64_t  CS_LDK_Balance_clone_ptr(int64_t arg) {
33148         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
33149         int64_t ret_conv = Balance_clone_ptr(arg_conv);
33150         return ret_conv;
33151 }
33152
33153 int64_t  CS_LDK_Balance_clone(int64_t orig) {
33154         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
33155         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33156         *ret_copy = Balance_clone(orig_conv);
33157         int64_t ret_ref = tag_ptr(ret_copy, true);
33158         return ret_ref;
33159 }
33160
33161 int64_t  CS_LDK_Balance_claimable_on_channel_close(int64_t amount_satoshis) {
33162         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33163         *ret_copy = Balance_claimable_on_channel_close(amount_satoshis);
33164         int64_t ret_ref = tag_ptr(ret_copy, true);
33165         return ret_ref;
33166 }
33167
33168 int64_t  CS_LDK_Balance_claimable_awaiting_confirmations(int64_t amount_satoshis, int32_t confirmation_height) {
33169         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33170         *ret_copy = Balance_claimable_awaiting_confirmations(amount_satoshis, confirmation_height);
33171         int64_t ret_ref = tag_ptr(ret_copy, true);
33172         return ret_ref;
33173 }
33174
33175 int64_t  CS_LDK_Balance_contentious_claimable(int64_t amount_satoshis, int32_t timeout_height, int8_tArray payment_hash, int8_tArray payment_preimage) {
33176         LDKThirtyTwoBytes payment_hash_ref;
33177         CHECK(payment_hash->arr_len == 32);
33178         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
33179         LDKThirtyTwoBytes payment_preimage_ref;
33180         CHECK(payment_preimage->arr_len == 32);
33181         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
33182         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33183         *ret_copy = Balance_contentious_claimable(amount_satoshis, timeout_height, payment_hash_ref, payment_preimage_ref);
33184         int64_t ret_ref = tag_ptr(ret_copy, true);
33185         return ret_ref;
33186 }
33187
33188 int64_t  CS_LDK_Balance_maybe_timeout_claimable_htlc(int64_t amount_satoshis, int32_t claimable_height, int8_tArray payment_hash) {
33189         LDKThirtyTwoBytes payment_hash_ref;
33190         CHECK(payment_hash->arr_len == 32);
33191         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
33192         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33193         *ret_copy = Balance_maybe_timeout_claimable_htlc(amount_satoshis, claimable_height, payment_hash_ref);
33194         int64_t ret_ref = tag_ptr(ret_copy, true);
33195         return ret_ref;
33196 }
33197
33198 int64_t  CS_LDK_Balance_maybe_preimage_claimable_htlc(int64_t amount_satoshis, int32_t expiry_height, int8_tArray payment_hash) {
33199         LDKThirtyTwoBytes payment_hash_ref;
33200         CHECK(payment_hash->arr_len == 32);
33201         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
33202         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33203         *ret_copy = Balance_maybe_preimage_claimable_htlc(amount_satoshis, expiry_height, payment_hash_ref);
33204         int64_t ret_ref = tag_ptr(ret_copy, true);
33205         return ret_ref;
33206 }
33207
33208 int64_t  CS_LDK_Balance_counterparty_revoked_output_claimable(int64_t amount_satoshis) {
33209         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33210         *ret_copy = Balance_counterparty_revoked_output_claimable(amount_satoshis);
33211         int64_t ret_ref = tag_ptr(ret_copy, true);
33212         return ret_ref;
33213 }
33214
33215 jboolean  CS_LDK_Balance_eq(int64_t a, int64_t b) {
33216         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
33217         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
33218         jboolean ret_conv = Balance_eq(a_conv, b_conv);
33219         return ret_conv;
33220 }
33221
33222 int64_t  CS_LDK_Balance_claimable_amount_satoshis(int64_t this_arg) {
33223         LDKBalance* this_arg_conv = (LDKBalance*)untag_ptr(this_arg);
33224         int64_t ret_conv = Balance_claimable_amount_satoshis(this_arg_conv);
33225         return ret_conv;
33226 }
33227
33228 void  CS_LDK_ChannelMonitor_free(int64_t this_obj) {
33229         LDKChannelMonitor this_obj_conv;
33230         this_obj_conv.inner = untag_ptr(this_obj);
33231         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33233         ChannelMonitor_free(this_obj_conv);
33234 }
33235
33236 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
33237         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
33238         int64_t ret_ref = 0;
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33241         return ret_ref;
33242 }
33243 int64_t  CS_LDK_ChannelMonitor_clone_ptr(int64_t arg) {
33244         LDKChannelMonitor arg_conv;
33245         arg_conv.inner = untag_ptr(arg);
33246         arg_conv.is_owned = ptr_is_owned(arg);
33247         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33248         arg_conv.is_owned = false;
33249         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
33250         return ret_conv;
33251 }
33252
33253 int64_t  CS_LDK_ChannelMonitor_clone(int64_t orig) {
33254         LDKChannelMonitor orig_conv;
33255         orig_conv.inner = untag_ptr(orig);
33256         orig_conv.is_owned = ptr_is_owned(orig);
33257         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33258         orig_conv.is_owned = false;
33259         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
33260         int64_t ret_ref = 0;
33261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33262         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33263         return ret_ref;
33264 }
33265
33266 int8_tArray  CS_LDK_ChannelMonitor_write(int64_t obj) {
33267         LDKChannelMonitor obj_conv;
33268         obj_conv.inner = untag_ptr(obj);
33269         obj_conv.is_owned = ptr_is_owned(obj);
33270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33271         obj_conv.is_owned = false;
33272         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
33273         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33274         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33275         CVec_u8Z_free(ret_var);
33276         return ret_arr;
33277 }
33278
33279 int64_t  CS_LDK_ChannelMonitor_update_monitor(int64_t this_arg, int64_t updates, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33280         LDKChannelMonitor this_arg_conv;
33281         this_arg_conv.inner = untag_ptr(this_arg);
33282         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33284         this_arg_conv.is_owned = false;
33285         LDKChannelMonitorUpdate updates_conv;
33286         updates_conv.inner = untag_ptr(updates);
33287         updates_conv.is_owned = ptr_is_owned(updates);
33288         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
33289         updates_conv.is_owned = false;
33290         void* broadcaster_ptr = untag_ptr(broadcaster);
33291         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
33292         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
33293         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33294         if (ptr_is_owned(fee_estimator)) { CHECK_ACCESS(fee_estimator_ptr); }
33295         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
33296         void* logger_ptr = untag_ptr(logger);
33297         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
33298         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
33299         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
33300         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
33301         return tag_ptr(ret_conv, true);
33302 }
33303
33304 int64_t  CS_LDK_ChannelMonitor_get_latest_update_id(int64_t this_arg) {
33305         LDKChannelMonitor this_arg_conv;
33306         this_arg_conv.inner = untag_ptr(this_arg);
33307         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33309         this_arg_conv.is_owned = false;
33310         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
33311         return ret_conv;
33312 }
33313
33314 int64_t  CS_LDK_ChannelMonitor_get_funding_txo(int64_t this_arg) {
33315         LDKChannelMonitor this_arg_conv;
33316         this_arg_conv.inner = untag_ptr(this_arg);
33317         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33319         this_arg_conv.is_owned = false;
33320         LDKC2Tuple_OutPointCVec_u8ZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_u8ZZ), "LDKC2Tuple_OutPointCVec_u8ZZ");
33321         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
33322         return tag_ptr(ret_conv, true);
33323 }
33324
33325 int64_tArray  CS_LDK_ChannelMonitor_get_outputs_to_watch(int64_t this_arg) {
33326         LDKChannelMonitor this_arg_conv;
33327         this_arg_conv.inner = untag_ptr(this_arg);
33328         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33330         this_arg_conv.is_owned = false;
33331         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
33332         int64_tArray ret_arr = NULL;
33333         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33334         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33335         for (size_t a = 0; a < ret_var.datalen; a++) {
33336                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ* ret_conv_52_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ");
33337                 *ret_conv_52_conv = ret_var.data[a];
33338                 ret_arr_ptr[a] = tag_ptr(ret_conv_52_conv, true);
33339         }
33340         
33341         FREE(ret_var.data);
33342         return ret_arr;
33343 }
33344
33345 void  CS_LDK_ChannelMonitor_load_outputs_to_watch(int64_t this_arg, int64_t filter) {
33346         LDKChannelMonitor this_arg_conv;
33347         this_arg_conv.inner = untag_ptr(this_arg);
33348         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33350         this_arg_conv.is_owned = false;
33351         void* filter_ptr = untag_ptr(filter);
33352         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
33353         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
33354         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
33355 }
33356
33357 int64_tArray  CS_LDK_ChannelMonitor_get_and_clear_pending_monitor_events(int64_t this_arg) {
33358         LDKChannelMonitor this_arg_conv;
33359         this_arg_conv.inner = untag_ptr(this_arg);
33360         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33362         this_arg_conv.is_owned = false;
33363         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
33364         int64_tArray ret_arr = NULL;
33365         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33366         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33367         for (size_t o = 0; o < ret_var.datalen; o++) {
33368                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
33369                 *ret_conv_14_copy = ret_var.data[o];
33370                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
33371                 ret_arr_ptr[o] = ret_conv_14_ref;
33372         }
33373         
33374         FREE(ret_var.data);
33375         return ret_arr;
33376 }
33377
33378 void  CS_LDK_ChannelMonitor_process_pending_events(int64_t this_arg, int64_t handler) {
33379         LDKChannelMonitor this_arg_conv;
33380         this_arg_conv.inner = untag_ptr(this_arg);
33381         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33383         this_arg_conv.is_owned = false;
33384         void* handler_ptr = untag_ptr(handler);
33385         if (ptr_is_owned(handler)) { CHECK_ACCESS(handler_ptr); }
33386         LDKEventHandler* handler_conv = (LDKEventHandler*)handler_ptr;
33387         ChannelMonitor_process_pending_events(&this_arg_conv, handler_conv);
33388 }
33389
33390 int64_t  CS_LDK_ChannelMonitor_initial_counterparty_commitment_tx(int64_t this_arg) {
33391         LDKChannelMonitor this_arg_conv;
33392         this_arg_conv.inner = untag_ptr(this_arg);
33393         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33395         this_arg_conv.is_owned = false;
33396         LDKCommitmentTransaction ret_var = ChannelMonitor_initial_counterparty_commitment_tx(&this_arg_conv);
33397         int64_t ret_ref = 0;
33398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33399         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33400         return ret_ref;
33401 }
33402
33403 int64_tArray  CS_LDK_ChannelMonitor_counterparty_commitment_txs_from_update(int64_t this_arg, int64_t update) {
33404         LDKChannelMonitor this_arg_conv;
33405         this_arg_conv.inner = untag_ptr(this_arg);
33406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33408         this_arg_conv.is_owned = false;
33409         LDKChannelMonitorUpdate update_conv;
33410         update_conv.inner = untag_ptr(update);
33411         update_conv.is_owned = ptr_is_owned(update);
33412         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
33413         update_conv.is_owned = false;
33414         LDKCVec_CommitmentTransactionZ ret_var = ChannelMonitor_counterparty_commitment_txs_from_update(&this_arg_conv, &update_conv);
33415         int64_tArray ret_arr = NULL;
33416         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33417         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33418         for (size_t x = 0; x < ret_var.datalen; x++) {
33419                 LDKCommitmentTransaction ret_conv_23_var = ret_var.data[x];
33420                 int64_t ret_conv_23_ref = 0;
33421                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_23_var);
33422                 ret_conv_23_ref = tag_ptr(ret_conv_23_var.inner, ret_conv_23_var.is_owned);
33423                 ret_arr_ptr[x] = ret_conv_23_ref;
33424         }
33425         
33426         FREE(ret_var.data);
33427         return ret_arr;
33428 }
33429
33430 int64_t  CS_LDK_ChannelMonitor_sign_to_local_justice_tx(int64_t this_arg, int8_tArray justice_tx, int64_t input_idx, int64_t value, int64_t commitment_number) {
33431         LDKChannelMonitor this_arg_conv;
33432         this_arg_conv.inner = untag_ptr(this_arg);
33433         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33435         this_arg_conv.is_owned = false;
33436         LDKTransaction justice_tx_ref;
33437         justice_tx_ref.datalen = justice_tx->arr_len;
33438         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
33439         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
33440         justice_tx_ref.data_is_owned = true;
33441         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
33442         *ret_conv = ChannelMonitor_sign_to_local_justice_tx(&this_arg_conv, justice_tx_ref, input_idx, value, commitment_number);
33443         return tag_ptr(ret_conv, true);
33444 }
33445
33446 int8_tArray  CS_LDK_ChannelMonitor_get_counterparty_node_id(int64_t this_arg) {
33447         LDKChannelMonitor this_arg_conv;
33448         this_arg_conv.inner = untag_ptr(this_arg);
33449         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33451         this_arg_conv.is_owned = false;
33452         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33453         memcpy(ret_arr->elems, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form, 33);
33454         return ret_arr;
33455 }
33456
33457 ptrArray  CS_LDK_ChannelMonitor_get_latest_holder_commitment_txn(int64_t this_arg, int64_t logger) {
33458         LDKChannelMonitor this_arg_conv;
33459         this_arg_conv.inner = untag_ptr(this_arg);
33460         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33462         this_arg_conv.is_owned = false;
33463         void* logger_ptr = untag_ptr(logger);
33464         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
33465         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
33466         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
33467         ptrArray ret_arr = NULL;
33468         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
33469         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
33470         for (size_t i = 0; i < ret_var.datalen; i++) {
33471                 LDKTransaction ret_conv_8_var = ret_var.data[i];
33472                 int8_tArray ret_conv_8_arr = init_int8_tArray(ret_conv_8_var.datalen, __LINE__);
33473                 memcpy(ret_conv_8_arr->elems, ret_conv_8_var.data, ret_conv_8_var.datalen);
33474                 Transaction_free(ret_conv_8_var);
33475                 ret_arr_ptr[i] = ret_conv_8_arr;
33476         }
33477         
33478         FREE(ret_var.data);
33479         return ret_arr;
33480 }
33481
33482 int64_tArray  CS_LDK_ChannelMonitor_block_connected(int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33483         LDKChannelMonitor this_arg_conv;
33484         this_arg_conv.inner = untag_ptr(this_arg);
33485         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33487         this_arg_conv.is_owned = false;
33488         uint8_t header_arr[80];
33489         CHECK(header->arr_len == 80);
33490         memcpy(header_arr, header->elems, 80); FREE(header);
33491         uint8_t (*header_ref)[80] = &header_arr;
33492         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
33493         txdata_constr.datalen = txdata->arr_len;
33494         if (txdata_constr.datalen > 0)
33495                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
33496         else
33497                 txdata_constr.data = NULL;
33498         int64_t* txdata_vals = txdata->elems;
33499         for (size_t c = 0; c < txdata_constr.datalen; c++) {
33500                 int64_t txdata_conv_28 = txdata_vals[c];
33501                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
33502                 CHECK_ACCESS(txdata_conv_28_ptr);
33503                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
33504                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
33505                 txdata_constr.data[c] = txdata_conv_28_conv;
33506         }
33507         FREE(txdata);
33508         void* broadcaster_ptr = untag_ptr(broadcaster);
33509         CHECK_ACCESS(broadcaster_ptr);
33510         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33511         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33512                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33513                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33514         }
33515         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33516         CHECK_ACCESS(fee_estimator_ptr);
33517         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33518         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33519                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33520                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33521         }
33522         void* logger_ptr = untag_ptr(logger);
33523         CHECK_ACCESS(logger_ptr);
33524         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33525         if (logger_conv.free == LDKLogger_JCalls_free) {
33526                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33527                 LDKLogger_JCalls_cloned(&logger_conv);
33528         }
33529         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
33530         int64_tArray ret_arr = NULL;
33531         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33532         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33533         for (size_t x = 0; x < ret_var.datalen; x++) {
33534                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
33535                 *ret_conv_49_conv = ret_var.data[x];
33536                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33537         }
33538         
33539         FREE(ret_var.data);
33540         return ret_arr;
33541 }
33542
33543 void  CS_LDK_ChannelMonitor_block_disconnected(int64_t this_arg, int8_tArray header, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33544         LDKChannelMonitor this_arg_conv;
33545         this_arg_conv.inner = untag_ptr(this_arg);
33546         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33548         this_arg_conv.is_owned = false;
33549         uint8_t header_arr[80];
33550         CHECK(header->arr_len == 80);
33551         memcpy(header_arr, header->elems, 80); FREE(header);
33552         uint8_t (*header_ref)[80] = &header_arr;
33553         void* broadcaster_ptr = untag_ptr(broadcaster);
33554         CHECK_ACCESS(broadcaster_ptr);
33555         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33556         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33558                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33559         }
33560         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33561         CHECK_ACCESS(fee_estimator_ptr);
33562         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33563         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33564                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33565                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33566         }
33567         void* logger_ptr = untag_ptr(logger);
33568         CHECK_ACCESS(logger_ptr);
33569         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33570         if (logger_conv.free == LDKLogger_JCalls_free) {
33571                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33572                 LDKLogger_JCalls_cloned(&logger_conv);
33573         }
33574         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
33575 }
33576
33577 int64_tArray  CS_LDK_ChannelMonitor_transactions_confirmed(int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33578         LDKChannelMonitor this_arg_conv;
33579         this_arg_conv.inner = untag_ptr(this_arg);
33580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33582         this_arg_conv.is_owned = false;
33583         uint8_t header_arr[80];
33584         CHECK(header->arr_len == 80);
33585         memcpy(header_arr, header->elems, 80); FREE(header);
33586         uint8_t (*header_ref)[80] = &header_arr;
33587         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
33588         txdata_constr.datalen = txdata->arr_len;
33589         if (txdata_constr.datalen > 0)
33590                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
33591         else
33592                 txdata_constr.data = NULL;
33593         int64_t* txdata_vals = txdata->elems;
33594         for (size_t c = 0; c < txdata_constr.datalen; c++) {
33595                 int64_t txdata_conv_28 = txdata_vals[c];
33596                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
33597                 CHECK_ACCESS(txdata_conv_28_ptr);
33598                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
33599                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
33600                 txdata_constr.data[c] = txdata_conv_28_conv;
33601         }
33602         FREE(txdata);
33603         void* broadcaster_ptr = untag_ptr(broadcaster);
33604         CHECK_ACCESS(broadcaster_ptr);
33605         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33606         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33607                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33608                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33609         }
33610         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33611         CHECK_ACCESS(fee_estimator_ptr);
33612         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33613         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33614                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33615                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33616         }
33617         void* logger_ptr = untag_ptr(logger);
33618         CHECK_ACCESS(logger_ptr);
33619         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33620         if (logger_conv.free == LDKLogger_JCalls_free) {
33621                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33622                 LDKLogger_JCalls_cloned(&logger_conv);
33623         }
33624         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
33625         int64_tArray ret_arr = NULL;
33626         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33627         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33628         for (size_t x = 0; x < ret_var.datalen; x++) {
33629                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
33630                 *ret_conv_49_conv = ret_var.data[x];
33631                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33632         }
33633         
33634         FREE(ret_var.data);
33635         return ret_arr;
33636 }
33637
33638 void  CS_LDK_ChannelMonitor_transaction_unconfirmed(int64_t this_arg, int8_tArray txid, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33639         LDKChannelMonitor this_arg_conv;
33640         this_arg_conv.inner = untag_ptr(this_arg);
33641         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33643         this_arg_conv.is_owned = false;
33644         uint8_t txid_arr[32];
33645         CHECK(txid->arr_len == 32);
33646         memcpy(txid_arr, txid->elems, 32); FREE(txid);
33647         uint8_t (*txid_ref)[32] = &txid_arr;
33648         void* broadcaster_ptr = untag_ptr(broadcaster);
33649         CHECK_ACCESS(broadcaster_ptr);
33650         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33651         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33652                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33653                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33654         }
33655         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33656         CHECK_ACCESS(fee_estimator_ptr);
33657         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33658         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33659                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33660                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33661         }
33662         void* logger_ptr = untag_ptr(logger);
33663         CHECK_ACCESS(logger_ptr);
33664         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33665         if (logger_conv.free == LDKLogger_JCalls_free) {
33666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33667                 LDKLogger_JCalls_cloned(&logger_conv);
33668         }
33669         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
33670 }
33671
33672 int64_tArray  CS_LDK_ChannelMonitor_best_block_updated(int64_t this_arg, int8_tArray header, int32_t height, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33673         LDKChannelMonitor this_arg_conv;
33674         this_arg_conv.inner = untag_ptr(this_arg);
33675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33677         this_arg_conv.is_owned = false;
33678         uint8_t header_arr[80];
33679         CHECK(header->arr_len == 80);
33680         memcpy(header_arr, header->elems, 80); FREE(header);
33681         uint8_t (*header_ref)[80] = &header_arr;
33682         void* broadcaster_ptr = untag_ptr(broadcaster);
33683         CHECK_ACCESS(broadcaster_ptr);
33684         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33685         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33686                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33687                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33688         }
33689         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33690         CHECK_ACCESS(fee_estimator_ptr);
33691         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33692         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33693                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33694                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33695         }
33696         void* logger_ptr = untag_ptr(logger);
33697         CHECK_ACCESS(logger_ptr);
33698         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33699         if (logger_conv.free == LDKLogger_JCalls_free) {
33700                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33701                 LDKLogger_JCalls_cloned(&logger_conv);
33702         }
33703         LDKCVec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
33704         int64_tArray ret_arr = NULL;
33705         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33706         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33707         for (size_t x = 0; x < ret_var.datalen; x++) {
33708                 LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ");
33709                 *ret_conv_49_conv = ret_var.data[x];
33710                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33711         }
33712         
33713         FREE(ret_var.data);
33714         return ret_arr;
33715 }
33716
33717 int64_tArray  CS_LDK_ChannelMonitor_get_relevant_txids(int64_t this_arg) {
33718         LDKChannelMonitor this_arg_conv;
33719         this_arg_conv.inner = untag_ptr(this_arg);
33720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33722         this_arg_conv.is_owned = false;
33723         LDKCVec_C2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
33724         int64_tArray ret_arr = NULL;
33725         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33726         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33727         for (size_t x = 0; x < ret_var.datalen; x++) {
33728                 LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ* ret_conv_49_conv = MALLOC(sizeof(LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ), "LDKC2Tuple_ThirtyTwoBytesCOption_ThirtyTwoBytesZZ");
33729                 *ret_conv_49_conv = ret_var.data[x];
33730                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
33731         }
33732         
33733         FREE(ret_var.data);
33734         return ret_arr;
33735 }
33736
33737 int64_t  CS_LDK_ChannelMonitor_current_best_block(int64_t this_arg) {
33738         LDKChannelMonitor this_arg_conv;
33739         this_arg_conv.inner = untag_ptr(this_arg);
33740         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33742         this_arg_conv.is_owned = false;
33743         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
33744         int64_t ret_ref = 0;
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33747         return ret_ref;
33748 }
33749
33750 void  CS_LDK_ChannelMonitor_rebroadcast_pending_claims(int64_t this_arg, int64_t broadcaster, int64_t fee_estimator, int64_t logger) {
33751         LDKChannelMonitor this_arg_conv;
33752         this_arg_conv.inner = untag_ptr(this_arg);
33753         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33755         this_arg_conv.is_owned = false;
33756         void* broadcaster_ptr = untag_ptr(broadcaster);
33757         CHECK_ACCESS(broadcaster_ptr);
33758         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
33759         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33760                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33761                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
33762         }
33763         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33764         CHECK_ACCESS(fee_estimator_ptr);
33765         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33766         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33767                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33768                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33769         }
33770         void* logger_ptr = untag_ptr(logger);
33771         CHECK_ACCESS(logger_ptr);
33772         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33773         if (logger_conv.free == LDKLogger_JCalls_free) {
33774                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33775                 LDKLogger_JCalls_cloned(&logger_conv);
33776         }
33777         ChannelMonitor_rebroadcast_pending_claims(&this_arg_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
33778 }
33779
33780 int64_tArray  CS_LDK_ChannelMonitor_get_spendable_outputs(int64_t this_arg, int8_tArray tx, int32_t confirmation_height) {
33781         LDKChannelMonitor this_arg_conv;
33782         this_arg_conv.inner = untag_ptr(this_arg);
33783         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33785         this_arg_conv.is_owned = false;
33786         LDKTransaction tx_ref;
33787         tx_ref.datalen = tx->arr_len;
33788         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
33789         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
33790         tx_ref.data_is_owned = true;
33791         LDKCVec_SpendableOutputDescriptorZ ret_var = ChannelMonitor_get_spendable_outputs(&this_arg_conv, tx_ref, confirmation_height);
33792         int64_tArray ret_arr = NULL;
33793         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33794         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33795         for (size_t b = 0; b < ret_var.datalen; b++) {
33796                 LDKSpendableOutputDescriptor *ret_conv_27_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
33797                 *ret_conv_27_copy = ret_var.data[b];
33798                 int64_t ret_conv_27_ref = tag_ptr(ret_conv_27_copy, true);
33799                 ret_arr_ptr[b] = ret_conv_27_ref;
33800         }
33801         
33802         FREE(ret_var.data);
33803         return ret_arr;
33804 }
33805
33806 int64_tArray  CS_LDK_ChannelMonitor_get_claimable_balances(int64_t this_arg) {
33807         LDKChannelMonitor this_arg_conv;
33808         this_arg_conv.inner = untag_ptr(this_arg);
33809         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33811         this_arg_conv.is_owned = false;
33812         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
33813         int64_tArray ret_arr = NULL;
33814         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
33815         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
33816         for (size_t j = 0; j < ret_var.datalen; j++) {
33817                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
33818                 *ret_conv_9_copy = ret_var.data[j];
33819                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
33820                 ret_arr_ptr[j] = ret_conv_9_ref;
33821         }
33822         
33823         FREE(ret_var.data);
33824         return ret_arr;
33825 }
33826
33827 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(int8_tArray ser, int64_t arg_a, int64_t arg_b) {
33828         LDKu8slice ser_ref;
33829         ser_ref.datalen = ser->arr_len;
33830         ser_ref.data = ser->elems;
33831         void* arg_a_ptr = untag_ptr(arg_a);
33832         if (ptr_is_owned(arg_a)) { CHECK_ACCESS(arg_a_ptr); }
33833         LDKEntropySource* arg_a_conv = (LDKEntropySource*)arg_a_ptr;
33834         void* arg_b_ptr = untag_ptr(arg_b);
33835         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
33836         LDKSignerProvider* arg_b_conv = (LDKSignerProvider*)arg_b_ptr;
33837         LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ");
33838         *ret_conv = C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(ser_ref, arg_a_conv, arg_b_conv);
33839         FREE(ser);
33840         return tag_ptr(ret_conv, true);
33841 }
33842
33843 void  CS_LDK_OutPoint_free(int64_t this_obj) {
33844         LDKOutPoint this_obj_conv;
33845         this_obj_conv.inner = untag_ptr(this_obj);
33846         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33848         OutPoint_free(this_obj_conv);
33849 }
33850
33851 int8_tArray  CS_LDK_OutPoint_get_txid(int64_t this_ptr) {
33852         LDKOutPoint this_ptr_conv;
33853         this_ptr_conv.inner = untag_ptr(this_ptr);
33854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33856         this_ptr_conv.is_owned = false;
33857         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33858         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
33859         return ret_arr;
33860 }
33861
33862 void  CS_LDK_OutPoint_set_txid(int64_t this_ptr, int8_tArray val) {
33863         LDKOutPoint this_ptr_conv;
33864         this_ptr_conv.inner = untag_ptr(this_ptr);
33865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33867         this_ptr_conv.is_owned = false;
33868         LDKThirtyTwoBytes val_ref;
33869         CHECK(val->arr_len == 32);
33870         memcpy(val_ref.data, val->elems, 32); FREE(val);
33871         OutPoint_set_txid(&this_ptr_conv, val_ref);
33872 }
33873
33874 int16_t  CS_LDK_OutPoint_get_index(int64_t this_ptr) {
33875         LDKOutPoint this_ptr_conv;
33876         this_ptr_conv.inner = untag_ptr(this_ptr);
33877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33879         this_ptr_conv.is_owned = false;
33880         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
33881         return ret_conv;
33882 }
33883
33884 void  CS_LDK_OutPoint_set_index(int64_t this_ptr, int16_t val) {
33885         LDKOutPoint this_ptr_conv;
33886         this_ptr_conv.inner = untag_ptr(this_ptr);
33887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33889         this_ptr_conv.is_owned = false;
33890         OutPoint_set_index(&this_ptr_conv, val);
33891 }
33892
33893 int64_t  CS_LDK_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
33894         LDKThirtyTwoBytes txid_arg_ref;
33895         CHECK(txid_arg->arr_len == 32);
33896         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
33897         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
33898         int64_t ret_ref = 0;
33899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33901         return ret_ref;
33902 }
33903
33904 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
33905         LDKOutPoint ret_var = OutPoint_clone(arg);
33906         int64_t ret_ref = 0;
33907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33908         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33909         return ret_ref;
33910 }
33911 int64_t  CS_LDK_OutPoint_clone_ptr(int64_t arg) {
33912         LDKOutPoint arg_conv;
33913         arg_conv.inner = untag_ptr(arg);
33914         arg_conv.is_owned = ptr_is_owned(arg);
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33916         arg_conv.is_owned = false;
33917         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
33918         return ret_conv;
33919 }
33920
33921 int64_t  CS_LDK_OutPoint_clone(int64_t orig) {
33922         LDKOutPoint orig_conv;
33923         orig_conv.inner = untag_ptr(orig);
33924         orig_conv.is_owned = ptr_is_owned(orig);
33925         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33926         orig_conv.is_owned = false;
33927         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
33928         int64_t ret_ref = 0;
33929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33931         return ret_ref;
33932 }
33933
33934 jboolean  CS_LDK_OutPoint_eq(int64_t a, int64_t b) {
33935         LDKOutPoint a_conv;
33936         a_conv.inner = untag_ptr(a);
33937         a_conv.is_owned = ptr_is_owned(a);
33938         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33939         a_conv.is_owned = false;
33940         LDKOutPoint b_conv;
33941         b_conv.inner = untag_ptr(b);
33942         b_conv.is_owned = ptr_is_owned(b);
33943         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33944         b_conv.is_owned = false;
33945         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
33946         return ret_conv;
33947 }
33948
33949 int64_t  CS_LDK_OutPoint_hash(int64_t o) {
33950         LDKOutPoint o_conv;
33951         o_conv.inner = untag_ptr(o);
33952         o_conv.is_owned = ptr_is_owned(o);
33953         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33954         o_conv.is_owned = false;
33955         int64_t ret_conv = OutPoint_hash(&o_conv);
33956         return ret_conv;
33957 }
33958
33959 int8_tArray  CS_LDK_OutPoint_to_channel_id(int64_t this_arg) {
33960         LDKOutPoint this_arg_conv;
33961         this_arg_conv.inner = untag_ptr(this_arg);
33962         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33964         this_arg_conv.is_owned = false;
33965         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33966         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
33967         return ret_arr;
33968 }
33969
33970 int8_tArray  CS_LDK_OutPoint_write(int64_t obj) {
33971         LDKOutPoint obj_conv;
33972         obj_conv.inner = untag_ptr(obj);
33973         obj_conv.is_owned = ptr_is_owned(obj);
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33975         obj_conv.is_owned = false;
33976         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
33977         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33978         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33979         CVec_u8Z_free(ret_var);
33980         return ret_arr;
33981 }
33982
33983 int64_t  CS_LDK_OutPoint_read(int8_tArray ser) {
33984         LDKu8slice ser_ref;
33985         ser_ref.datalen = ser->arr_len;
33986         ser_ref.data = ser->elems;
33987         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
33988         *ret_conv = OutPoint_read(ser_ref);
33989         FREE(ser);
33990         return tag_ptr(ret_conv, true);
33991 }
33992
33993 void  CS_LDK_FailureCode_free(int64_t this_ptr) {
33994         if (!ptr_is_owned(this_ptr)) return;
33995         void* this_ptr_ptr = untag_ptr(this_ptr);
33996         CHECK_ACCESS(this_ptr_ptr);
33997         LDKFailureCode this_ptr_conv = *(LDKFailureCode*)(this_ptr_ptr);
33998         FREE(untag_ptr(this_ptr));
33999         FailureCode_free(this_ptr_conv);
34000 }
34001
34002 static inline uint64_t FailureCode_clone_ptr(LDKFailureCode *NONNULL_PTR arg) {
34003         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34004         *ret_copy = FailureCode_clone(arg);
34005         int64_t ret_ref = tag_ptr(ret_copy, true);
34006         return ret_ref;
34007 }
34008 int64_t  CS_LDK_FailureCode_clone_ptr(int64_t arg) {
34009         LDKFailureCode* arg_conv = (LDKFailureCode*)untag_ptr(arg);
34010         int64_t ret_conv = FailureCode_clone_ptr(arg_conv);
34011         return ret_conv;
34012 }
34013
34014 int64_t  CS_LDK_FailureCode_clone(int64_t orig) {
34015         LDKFailureCode* orig_conv = (LDKFailureCode*)untag_ptr(orig);
34016         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34017         *ret_copy = FailureCode_clone(orig_conv);
34018         int64_t ret_ref = tag_ptr(ret_copy, true);
34019         return ret_ref;
34020 }
34021
34022 int64_t  CS_LDK_FailureCode_temporary_node_failure() {
34023         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34024         *ret_copy = FailureCode_temporary_node_failure();
34025         int64_t ret_ref = tag_ptr(ret_copy, true);
34026         return ret_ref;
34027 }
34028
34029 int64_t  CS_LDK_FailureCode_required_node_feature_missing() {
34030         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34031         *ret_copy = FailureCode_required_node_feature_missing();
34032         int64_t ret_ref = tag_ptr(ret_copy, true);
34033         return ret_ref;
34034 }
34035
34036 int64_t  CS_LDK_FailureCode_incorrect_or_unknown_payment_details() {
34037         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34038         *ret_copy = FailureCode_incorrect_or_unknown_payment_details();
34039         int64_t ret_ref = tag_ptr(ret_copy, true);
34040         return ret_ref;
34041 }
34042
34043 int64_t  CS_LDK_FailureCode_invalid_onion_payload(int64_t a) {
34044         void* a_ptr = untag_ptr(a);
34045         CHECK_ACCESS(a_ptr);
34046         LDKCOption_C2Tuple_u64u16ZZ a_conv = *(LDKCOption_C2Tuple_u64u16ZZ*)(a_ptr);
34047         a_conv = COption_C2Tuple_u64u16ZZ_clone((LDKCOption_C2Tuple_u64u16ZZ*)untag_ptr(a));
34048         LDKFailureCode *ret_copy = MALLOC(sizeof(LDKFailureCode), "LDKFailureCode");
34049         *ret_copy = FailureCode_invalid_onion_payload(a_conv);
34050         int64_t ret_ref = tag_ptr(ret_copy, true);
34051         return ret_ref;
34052 }
34053
34054 void  CS_LDK_ChannelManager_free(int64_t this_obj) {
34055         LDKChannelManager this_obj_conv;
34056         this_obj_conv.inner = untag_ptr(this_obj);
34057         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34059         ChannelManager_free(this_obj_conv);
34060 }
34061
34062 void  CS_LDK_ChainParameters_free(int64_t this_obj) {
34063         LDKChainParameters this_obj_conv;
34064         this_obj_conv.inner = untag_ptr(this_obj);
34065         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34067         ChainParameters_free(this_obj_conv);
34068 }
34069
34070 int32_t  CS_LDK_ChainParameters_get_network(int64_t this_ptr) {
34071         LDKChainParameters this_ptr_conv;
34072         this_ptr_conv.inner = untag_ptr(this_ptr);
34073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34075         this_ptr_conv.is_owned = false;
34076         int32_t ret_conv = LDKNetwork_to_cs(ChainParameters_get_network(&this_ptr_conv));
34077         return ret_conv;
34078 }
34079
34080 void  CS_LDK_ChainParameters_set_network(int64_t this_ptr, int32_t val) {
34081         LDKChainParameters this_ptr_conv;
34082         this_ptr_conv.inner = untag_ptr(this_ptr);
34083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34085         this_ptr_conv.is_owned = false;
34086         LDKNetwork val_conv = LDKNetwork_from_cs(val);
34087         ChainParameters_set_network(&this_ptr_conv, val_conv);
34088 }
34089
34090 int64_t  CS_LDK_ChainParameters_get_best_block(int64_t this_ptr) {
34091         LDKChainParameters this_ptr_conv;
34092         this_ptr_conv.inner = untag_ptr(this_ptr);
34093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34095         this_ptr_conv.is_owned = false;
34096         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
34097         int64_t ret_ref = 0;
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34100         return ret_ref;
34101 }
34102
34103 void  CS_LDK_ChainParameters_set_best_block(int64_t this_ptr, int64_t val) {
34104         LDKChainParameters this_ptr_conv;
34105         this_ptr_conv.inner = untag_ptr(this_ptr);
34106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34108         this_ptr_conv.is_owned = false;
34109         LDKBestBlock val_conv;
34110         val_conv.inner = untag_ptr(val);
34111         val_conv.is_owned = ptr_is_owned(val);
34112         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34113         val_conv = BestBlock_clone(&val_conv);
34114         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
34115 }
34116
34117 int64_t  CS_LDK_ChainParameters_new(int32_t network_arg, int64_t best_block_arg) {
34118         LDKNetwork network_arg_conv = LDKNetwork_from_cs(network_arg);
34119         LDKBestBlock best_block_arg_conv;
34120         best_block_arg_conv.inner = untag_ptr(best_block_arg);
34121         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
34122         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
34123         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
34124         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
34125         int64_t ret_ref = 0;
34126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34128         return ret_ref;
34129 }
34130
34131 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
34132         LDKChainParameters ret_var = ChainParameters_clone(arg);
34133         int64_t ret_ref = 0;
34134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34135         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34136         return ret_ref;
34137 }
34138 int64_t  CS_LDK_ChainParameters_clone_ptr(int64_t arg) {
34139         LDKChainParameters arg_conv;
34140         arg_conv.inner = untag_ptr(arg);
34141         arg_conv.is_owned = ptr_is_owned(arg);
34142         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34143         arg_conv.is_owned = false;
34144         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
34145         return ret_conv;
34146 }
34147
34148 int64_t  CS_LDK_ChainParameters_clone(int64_t orig) {
34149         LDKChainParameters orig_conv;
34150         orig_conv.inner = untag_ptr(orig);
34151         orig_conv.is_owned = ptr_is_owned(orig);
34152         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34153         orig_conv.is_owned = false;
34154         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
34155         int64_t ret_ref = 0;
34156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34157         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34158         return ret_ref;
34159 }
34160
34161 void  CS_LDK_CounterpartyForwardingInfo_free(int64_t this_obj) {
34162         LDKCounterpartyForwardingInfo this_obj_conv;
34163         this_obj_conv.inner = untag_ptr(this_obj);
34164         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34166         CounterpartyForwardingInfo_free(this_obj_conv);
34167 }
34168
34169 int32_t  CS_LDK_CounterpartyForwardingInfo_get_fee_base_msat(int64_t this_ptr) {
34170         LDKCounterpartyForwardingInfo this_ptr_conv;
34171         this_ptr_conv.inner = untag_ptr(this_ptr);
34172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34174         this_ptr_conv.is_owned = false;
34175         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
34176         return ret_conv;
34177 }
34178
34179 void  CS_LDK_CounterpartyForwardingInfo_set_fee_base_msat(int64_t this_ptr, int32_t val) {
34180         LDKCounterpartyForwardingInfo this_ptr_conv;
34181         this_ptr_conv.inner = untag_ptr(this_ptr);
34182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34184         this_ptr_conv.is_owned = false;
34185         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
34186 }
34187
34188 int32_t  CS_LDK_CounterpartyForwardingInfo_get_fee_proportional_millionths(int64_t this_ptr) {
34189         LDKCounterpartyForwardingInfo this_ptr_conv;
34190         this_ptr_conv.inner = untag_ptr(this_ptr);
34191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34193         this_ptr_conv.is_owned = false;
34194         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
34195         return ret_conv;
34196 }
34197
34198 void  CS_LDK_CounterpartyForwardingInfo_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
34199         LDKCounterpartyForwardingInfo this_ptr_conv;
34200         this_ptr_conv.inner = untag_ptr(this_ptr);
34201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34203         this_ptr_conv.is_owned = false;
34204         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
34205 }
34206
34207 int16_t  CS_LDK_CounterpartyForwardingInfo_get_cltv_expiry_delta(int64_t this_ptr) {
34208         LDKCounterpartyForwardingInfo this_ptr_conv;
34209         this_ptr_conv.inner = untag_ptr(this_ptr);
34210         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34212         this_ptr_conv.is_owned = false;
34213         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
34214         return ret_conv;
34215 }
34216
34217 void  CS_LDK_CounterpartyForwardingInfo_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
34218         LDKCounterpartyForwardingInfo this_ptr_conv;
34219         this_ptr_conv.inner = untag_ptr(this_ptr);
34220         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34222         this_ptr_conv.is_owned = false;
34223         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
34224 }
34225
34226 int64_t  CS_LDK_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
34227         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
34228         int64_t ret_ref = 0;
34229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34230         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34231         return ret_ref;
34232 }
34233
34234 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
34235         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
34236         int64_t ret_ref = 0;
34237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34238         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34239         return ret_ref;
34240 }
34241 int64_t  CS_LDK_CounterpartyForwardingInfo_clone_ptr(int64_t arg) {
34242         LDKCounterpartyForwardingInfo arg_conv;
34243         arg_conv.inner = untag_ptr(arg);
34244         arg_conv.is_owned = ptr_is_owned(arg);
34245         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34246         arg_conv.is_owned = false;
34247         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
34248         return ret_conv;
34249 }
34250
34251 int64_t  CS_LDK_CounterpartyForwardingInfo_clone(int64_t orig) {
34252         LDKCounterpartyForwardingInfo orig_conv;
34253         orig_conv.inner = untag_ptr(orig);
34254         orig_conv.is_owned = ptr_is_owned(orig);
34255         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34256         orig_conv.is_owned = false;
34257         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
34258         int64_t ret_ref = 0;
34259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34260         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34261         return ret_ref;
34262 }
34263
34264 void  CS_LDK_ChannelCounterparty_free(int64_t this_obj) {
34265         LDKChannelCounterparty this_obj_conv;
34266         this_obj_conv.inner = untag_ptr(this_obj);
34267         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34269         ChannelCounterparty_free(this_obj_conv);
34270 }
34271
34272 int8_tArray  CS_LDK_ChannelCounterparty_get_node_id(int64_t this_ptr) {
34273         LDKChannelCounterparty this_ptr_conv;
34274         this_ptr_conv.inner = untag_ptr(this_ptr);
34275         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34277         this_ptr_conv.is_owned = false;
34278         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34279         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
34280         return ret_arr;
34281 }
34282
34283 void  CS_LDK_ChannelCounterparty_set_node_id(int64_t this_ptr, int8_tArray val) {
34284         LDKChannelCounterparty this_ptr_conv;
34285         this_ptr_conv.inner = untag_ptr(this_ptr);
34286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34288         this_ptr_conv.is_owned = false;
34289         LDKPublicKey val_ref;
34290         CHECK(val->arr_len == 33);
34291         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34292         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
34293 }
34294
34295 int64_t  CS_LDK_ChannelCounterparty_get_features(int64_t this_ptr) {
34296         LDKChannelCounterparty this_ptr_conv;
34297         this_ptr_conv.inner = untag_ptr(this_ptr);
34298         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34300         this_ptr_conv.is_owned = false;
34301         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
34302         int64_t ret_ref = 0;
34303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34304         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34305         return ret_ref;
34306 }
34307
34308 void  CS_LDK_ChannelCounterparty_set_features(int64_t this_ptr, int64_t val) {
34309         LDKChannelCounterparty this_ptr_conv;
34310         this_ptr_conv.inner = untag_ptr(this_ptr);
34311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34313         this_ptr_conv.is_owned = false;
34314         LDKInitFeatures val_conv;
34315         val_conv.inner = untag_ptr(val);
34316         val_conv.is_owned = ptr_is_owned(val);
34317         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34318         val_conv = InitFeatures_clone(&val_conv);
34319         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
34320 }
34321
34322 int64_t  CS_LDK_ChannelCounterparty_get_unspendable_punishment_reserve(int64_t this_ptr) {
34323         LDKChannelCounterparty this_ptr_conv;
34324         this_ptr_conv.inner = untag_ptr(this_ptr);
34325         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34327         this_ptr_conv.is_owned = false;
34328         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
34329         return ret_conv;
34330 }
34331
34332 void  CS_LDK_ChannelCounterparty_set_unspendable_punishment_reserve(int64_t this_ptr, int64_t val) {
34333         LDKChannelCounterparty this_ptr_conv;
34334         this_ptr_conv.inner = untag_ptr(this_ptr);
34335         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34337         this_ptr_conv.is_owned = false;
34338         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
34339 }
34340
34341 int64_t  CS_LDK_ChannelCounterparty_get_forwarding_info(int64_t this_ptr) {
34342         LDKChannelCounterparty this_ptr_conv;
34343         this_ptr_conv.inner = untag_ptr(this_ptr);
34344         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34346         this_ptr_conv.is_owned = false;
34347         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
34348         int64_t ret_ref = 0;
34349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34350         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34351         return ret_ref;
34352 }
34353
34354 void  CS_LDK_ChannelCounterparty_set_forwarding_info(int64_t this_ptr, int64_t val) {
34355         LDKChannelCounterparty this_ptr_conv;
34356         this_ptr_conv.inner = untag_ptr(this_ptr);
34357         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34359         this_ptr_conv.is_owned = false;
34360         LDKCounterpartyForwardingInfo val_conv;
34361         val_conv.inner = untag_ptr(val);
34362         val_conv.is_owned = ptr_is_owned(val);
34363         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34364         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
34365         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
34366 }
34367
34368 int64_t  CS_LDK_ChannelCounterparty_get_outbound_htlc_minimum_msat(int64_t this_ptr) {
34369         LDKChannelCounterparty this_ptr_conv;
34370         this_ptr_conv.inner = untag_ptr(this_ptr);
34371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34373         this_ptr_conv.is_owned = false;
34374         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34375         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
34376         int64_t ret_ref = tag_ptr(ret_copy, true);
34377         return ret_ref;
34378 }
34379
34380 void  CS_LDK_ChannelCounterparty_set_outbound_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
34381         LDKChannelCounterparty this_ptr_conv;
34382         this_ptr_conv.inner = untag_ptr(this_ptr);
34383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34385         this_ptr_conv.is_owned = false;
34386         void* val_ptr = untag_ptr(val);
34387         CHECK_ACCESS(val_ptr);
34388         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34389         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34390         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
34391 }
34392
34393 int64_t  CS_LDK_ChannelCounterparty_get_outbound_htlc_maximum_msat(int64_t this_ptr) {
34394         LDKChannelCounterparty this_ptr_conv;
34395         this_ptr_conv.inner = untag_ptr(this_ptr);
34396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34398         this_ptr_conv.is_owned = false;
34399         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34400         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
34401         int64_t ret_ref = tag_ptr(ret_copy, true);
34402         return ret_ref;
34403 }
34404
34405 void  CS_LDK_ChannelCounterparty_set_outbound_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
34406         LDKChannelCounterparty this_ptr_conv;
34407         this_ptr_conv.inner = untag_ptr(this_ptr);
34408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34410         this_ptr_conv.is_owned = false;
34411         void* val_ptr = untag_ptr(val);
34412         CHECK_ACCESS(val_ptr);
34413         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34414         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34415         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
34416 }
34417
34418 int64_t  CS_LDK_ChannelCounterparty_new(int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg, int64_t outbound_htlc_minimum_msat_arg, int64_t outbound_htlc_maximum_msat_arg) {
34419         LDKPublicKey node_id_arg_ref;
34420         CHECK(node_id_arg->arr_len == 33);
34421         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
34422         LDKInitFeatures features_arg_conv;
34423         features_arg_conv.inner = untag_ptr(features_arg);
34424         features_arg_conv.is_owned = ptr_is_owned(features_arg);
34425         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34426         features_arg_conv = InitFeatures_clone(&features_arg_conv);
34427         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
34428         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
34429         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
34430         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
34431         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
34432         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
34433         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
34434         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
34435         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
34436         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
34437         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
34438         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
34439         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
34440         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
34441         int64_t ret_ref = 0;
34442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34443         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34444         return ret_ref;
34445 }
34446
34447 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
34448         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
34449         int64_t ret_ref = 0;
34450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34451         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34452         return ret_ref;
34453 }
34454 int64_t  CS_LDK_ChannelCounterparty_clone_ptr(int64_t arg) {
34455         LDKChannelCounterparty arg_conv;
34456         arg_conv.inner = untag_ptr(arg);
34457         arg_conv.is_owned = ptr_is_owned(arg);
34458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34459         arg_conv.is_owned = false;
34460         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
34461         return ret_conv;
34462 }
34463
34464 int64_t  CS_LDK_ChannelCounterparty_clone(int64_t orig) {
34465         LDKChannelCounterparty orig_conv;
34466         orig_conv.inner = untag_ptr(orig);
34467         orig_conv.is_owned = ptr_is_owned(orig);
34468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34469         orig_conv.is_owned = false;
34470         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
34471         int64_t ret_ref = 0;
34472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34474         return ret_ref;
34475 }
34476
34477 void  CS_LDK_ChannelDetails_free(int64_t this_obj) {
34478         LDKChannelDetails this_obj_conv;
34479         this_obj_conv.inner = untag_ptr(this_obj);
34480         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34482         ChannelDetails_free(this_obj_conv);
34483 }
34484
34485 int8_tArray  CS_LDK_ChannelDetails_get_channel_id(int64_t this_ptr) {
34486         LDKChannelDetails this_ptr_conv;
34487         this_ptr_conv.inner = untag_ptr(this_ptr);
34488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34490         this_ptr_conv.is_owned = false;
34491         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34492         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
34493         return ret_arr;
34494 }
34495
34496 void  CS_LDK_ChannelDetails_set_channel_id(int64_t this_ptr, int8_tArray val) {
34497         LDKChannelDetails this_ptr_conv;
34498         this_ptr_conv.inner = untag_ptr(this_ptr);
34499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34501         this_ptr_conv.is_owned = false;
34502         LDKThirtyTwoBytes val_ref;
34503         CHECK(val->arr_len == 32);
34504         memcpy(val_ref.data, val->elems, 32); FREE(val);
34505         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
34506 }
34507
34508 int64_t  CS_LDK_ChannelDetails_get_counterparty(int64_t this_ptr) {
34509         LDKChannelDetails this_ptr_conv;
34510         this_ptr_conv.inner = untag_ptr(this_ptr);
34511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34513         this_ptr_conv.is_owned = false;
34514         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
34515         int64_t ret_ref = 0;
34516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34517         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34518         return ret_ref;
34519 }
34520
34521 void  CS_LDK_ChannelDetails_set_counterparty(int64_t this_ptr, int64_t val) {
34522         LDKChannelDetails this_ptr_conv;
34523         this_ptr_conv.inner = untag_ptr(this_ptr);
34524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34526         this_ptr_conv.is_owned = false;
34527         LDKChannelCounterparty val_conv;
34528         val_conv.inner = untag_ptr(val);
34529         val_conv.is_owned = ptr_is_owned(val);
34530         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34531         val_conv = ChannelCounterparty_clone(&val_conv);
34532         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
34533 }
34534
34535 int64_t  CS_LDK_ChannelDetails_get_funding_txo(int64_t this_ptr) {
34536         LDKChannelDetails this_ptr_conv;
34537         this_ptr_conv.inner = untag_ptr(this_ptr);
34538         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34540         this_ptr_conv.is_owned = false;
34541         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
34542         int64_t ret_ref = 0;
34543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34544         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34545         return ret_ref;
34546 }
34547
34548 void  CS_LDK_ChannelDetails_set_funding_txo(int64_t this_ptr, int64_t val) {
34549         LDKChannelDetails this_ptr_conv;
34550         this_ptr_conv.inner = untag_ptr(this_ptr);
34551         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34553         this_ptr_conv.is_owned = false;
34554         LDKOutPoint val_conv;
34555         val_conv.inner = untag_ptr(val);
34556         val_conv.is_owned = ptr_is_owned(val);
34557         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34558         val_conv = OutPoint_clone(&val_conv);
34559         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
34560 }
34561
34562 int64_t  CS_LDK_ChannelDetails_get_channel_type(int64_t this_ptr) {
34563         LDKChannelDetails this_ptr_conv;
34564         this_ptr_conv.inner = untag_ptr(this_ptr);
34565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34567         this_ptr_conv.is_owned = false;
34568         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
34569         int64_t ret_ref = 0;
34570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34571         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34572         return ret_ref;
34573 }
34574
34575 void  CS_LDK_ChannelDetails_set_channel_type(int64_t this_ptr, int64_t val) {
34576         LDKChannelDetails this_ptr_conv;
34577         this_ptr_conv.inner = untag_ptr(this_ptr);
34578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34580         this_ptr_conv.is_owned = false;
34581         LDKChannelTypeFeatures val_conv;
34582         val_conv.inner = untag_ptr(val);
34583         val_conv.is_owned = ptr_is_owned(val);
34584         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34585         val_conv = ChannelTypeFeatures_clone(&val_conv);
34586         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
34587 }
34588
34589 int64_t  CS_LDK_ChannelDetails_get_short_channel_id(int64_t this_ptr) {
34590         LDKChannelDetails this_ptr_conv;
34591         this_ptr_conv.inner = untag_ptr(this_ptr);
34592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34594         this_ptr_conv.is_owned = false;
34595         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34596         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
34597         int64_t ret_ref = tag_ptr(ret_copy, true);
34598         return ret_ref;
34599 }
34600
34601 void  CS_LDK_ChannelDetails_set_short_channel_id(int64_t this_ptr, int64_t val) {
34602         LDKChannelDetails this_ptr_conv;
34603         this_ptr_conv.inner = untag_ptr(this_ptr);
34604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34606         this_ptr_conv.is_owned = false;
34607         void* val_ptr = untag_ptr(val);
34608         CHECK_ACCESS(val_ptr);
34609         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34610         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34611         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
34612 }
34613
34614 int64_t  CS_LDK_ChannelDetails_get_outbound_scid_alias(int64_t this_ptr) {
34615         LDKChannelDetails this_ptr_conv;
34616         this_ptr_conv.inner = untag_ptr(this_ptr);
34617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34619         this_ptr_conv.is_owned = false;
34620         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34621         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
34622         int64_t ret_ref = tag_ptr(ret_copy, true);
34623         return ret_ref;
34624 }
34625
34626 void  CS_LDK_ChannelDetails_set_outbound_scid_alias(int64_t this_ptr, int64_t val) {
34627         LDKChannelDetails this_ptr_conv;
34628         this_ptr_conv.inner = untag_ptr(this_ptr);
34629         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34631         this_ptr_conv.is_owned = false;
34632         void* val_ptr = untag_ptr(val);
34633         CHECK_ACCESS(val_ptr);
34634         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34635         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34636         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
34637 }
34638
34639 int64_t  CS_LDK_ChannelDetails_get_inbound_scid_alias(int64_t this_ptr) {
34640         LDKChannelDetails this_ptr_conv;
34641         this_ptr_conv.inner = untag_ptr(this_ptr);
34642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34644         this_ptr_conv.is_owned = false;
34645         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34646         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
34647         int64_t ret_ref = tag_ptr(ret_copy, true);
34648         return ret_ref;
34649 }
34650
34651 void  CS_LDK_ChannelDetails_set_inbound_scid_alias(int64_t this_ptr, int64_t val) {
34652         LDKChannelDetails this_ptr_conv;
34653         this_ptr_conv.inner = untag_ptr(this_ptr);
34654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34656         this_ptr_conv.is_owned = false;
34657         void* val_ptr = untag_ptr(val);
34658         CHECK_ACCESS(val_ptr);
34659         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34660         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34661         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
34662 }
34663
34664 int64_t  CS_LDK_ChannelDetails_get_channel_value_satoshis(int64_t this_ptr) {
34665         LDKChannelDetails this_ptr_conv;
34666         this_ptr_conv.inner = untag_ptr(this_ptr);
34667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34669         this_ptr_conv.is_owned = false;
34670         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
34671         return ret_conv;
34672 }
34673
34674 void  CS_LDK_ChannelDetails_set_channel_value_satoshis(int64_t this_ptr, int64_t val) {
34675         LDKChannelDetails this_ptr_conv;
34676         this_ptr_conv.inner = untag_ptr(this_ptr);
34677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34679         this_ptr_conv.is_owned = false;
34680         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
34681 }
34682
34683 int64_t  CS_LDK_ChannelDetails_get_unspendable_punishment_reserve(int64_t this_ptr) {
34684         LDKChannelDetails this_ptr_conv;
34685         this_ptr_conv.inner = untag_ptr(this_ptr);
34686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34688         this_ptr_conv.is_owned = false;
34689         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34690         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
34691         int64_t ret_ref = tag_ptr(ret_copy, true);
34692         return ret_ref;
34693 }
34694
34695 void  CS_LDK_ChannelDetails_set_unspendable_punishment_reserve(int64_t this_ptr, int64_t val) {
34696         LDKChannelDetails this_ptr_conv;
34697         this_ptr_conv.inner = untag_ptr(this_ptr);
34698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34700         this_ptr_conv.is_owned = false;
34701         void* val_ptr = untag_ptr(val);
34702         CHECK_ACCESS(val_ptr);
34703         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34704         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
34705         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
34706 }
34707
34708 int8_tArray  CS_LDK_ChannelDetails_get_user_channel_id(int64_t this_ptr) {
34709         LDKChannelDetails this_ptr_conv;
34710         this_ptr_conv.inner = untag_ptr(this_ptr);
34711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34713         this_ptr_conv.is_owned = false;
34714         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
34715         memcpy(ret_arr->elems, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes, 16);
34716         return ret_arr;
34717 }
34718
34719 void  CS_LDK_ChannelDetails_set_user_channel_id(int64_t this_ptr, int8_tArray val) {
34720         LDKChannelDetails this_ptr_conv;
34721         this_ptr_conv.inner = untag_ptr(this_ptr);
34722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34724         this_ptr_conv.is_owned = false;
34725         LDKU128 val_ref;
34726         CHECK(val->arr_len == 16);
34727         memcpy(val_ref.le_bytes, val->elems, 16); FREE(val);
34728         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
34729 }
34730
34731 int64_t  CS_LDK_ChannelDetails_get_feerate_sat_per_1000_weight(int64_t this_ptr) {
34732         LDKChannelDetails this_ptr_conv;
34733         this_ptr_conv.inner = untag_ptr(this_ptr);
34734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34736         this_ptr_conv.is_owned = false;
34737         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34738         *ret_copy = ChannelDetails_get_feerate_sat_per_1000_weight(&this_ptr_conv);
34739         int64_t ret_ref = tag_ptr(ret_copy, true);
34740         return ret_ref;
34741 }
34742
34743 void  CS_LDK_ChannelDetails_set_feerate_sat_per_1000_weight(int64_t this_ptr, int64_t val) {
34744         LDKChannelDetails this_ptr_conv;
34745         this_ptr_conv.inner = untag_ptr(this_ptr);
34746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34748         this_ptr_conv.is_owned = false;
34749         void* val_ptr = untag_ptr(val);
34750         CHECK_ACCESS(val_ptr);
34751         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34752         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
34753         ChannelDetails_set_feerate_sat_per_1000_weight(&this_ptr_conv, val_conv);
34754 }
34755
34756 int64_t  CS_LDK_ChannelDetails_get_balance_msat(int64_t this_ptr) {
34757         LDKChannelDetails this_ptr_conv;
34758         this_ptr_conv.inner = untag_ptr(this_ptr);
34759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34761         this_ptr_conv.is_owned = false;
34762         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
34763         return ret_conv;
34764 }
34765
34766 void  CS_LDK_ChannelDetails_set_balance_msat(int64_t this_ptr, int64_t val) {
34767         LDKChannelDetails this_ptr_conv;
34768         this_ptr_conv.inner = untag_ptr(this_ptr);
34769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34771         this_ptr_conv.is_owned = false;
34772         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
34773 }
34774
34775 int64_t  CS_LDK_ChannelDetails_get_outbound_capacity_msat(int64_t this_ptr) {
34776         LDKChannelDetails this_ptr_conv;
34777         this_ptr_conv.inner = untag_ptr(this_ptr);
34778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34780         this_ptr_conv.is_owned = false;
34781         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
34782         return ret_conv;
34783 }
34784
34785 void  CS_LDK_ChannelDetails_set_outbound_capacity_msat(int64_t this_ptr, int64_t val) {
34786         LDKChannelDetails this_ptr_conv;
34787         this_ptr_conv.inner = untag_ptr(this_ptr);
34788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34790         this_ptr_conv.is_owned = false;
34791         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
34792 }
34793
34794 int64_t  CS_LDK_ChannelDetails_get_next_outbound_htlc_limit_msat(int64_t this_ptr) {
34795         LDKChannelDetails this_ptr_conv;
34796         this_ptr_conv.inner = untag_ptr(this_ptr);
34797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34799         this_ptr_conv.is_owned = false;
34800         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
34801         return ret_conv;
34802 }
34803
34804 void  CS_LDK_ChannelDetails_set_next_outbound_htlc_limit_msat(int64_t this_ptr, int64_t val) {
34805         LDKChannelDetails this_ptr_conv;
34806         this_ptr_conv.inner = untag_ptr(this_ptr);
34807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34809         this_ptr_conv.is_owned = false;
34810         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
34811 }
34812
34813 int64_t  CS_LDK_ChannelDetails_get_next_outbound_htlc_minimum_msat(int64_t this_ptr) {
34814         LDKChannelDetails this_ptr_conv;
34815         this_ptr_conv.inner = untag_ptr(this_ptr);
34816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34818         this_ptr_conv.is_owned = false;
34819         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_minimum_msat(&this_ptr_conv);
34820         return ret_conv;
34821 }
34822
34823 void  CS_LDK_ChannelDetails_set_next_outbound_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
34824         LDKChannelDetails this_ptr_conv;
34825         this_ptr_conv.inner = untag_ptr(this_ptr);
34826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34828         this_ptr_conv.is_owned = false;
34829         ChannelDetails_set_next_outbound_htlc_minimum_msat(&this_ptr_conv, val);
34830 }
34831
34832 int64_t  CS_LDK_ChannelDetails_get_inbound_capacity_msat(int64_t this_ptr) {
34833         LDKChannelDetails this_ptr_conv;
34834         this_ptr_conv.inner = untag_ptr(this_ptr);
34835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34837         this_ptr_conv.is_owned = false;
34838         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
34839         return ret_conv;
34840 }
34841
34842 void  CS_LDK_ChannelDetails_set_inbound_capacity_msat(int64_t this_ptr, int64_t val) {
34843         LDKChannelDetails this_ptr_conv;
34844         this_ptr_conv.inner = untag_ptr(this_ptr);
34845         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34847         this_ptr_conv.is_owned = false;
34848         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
34849 }
34850
34851 int64_t  CS_LDK_ChannelDetails_get_confirmations_required(int64_t this_ptr) {
34852         LDKChannelDetails this_ptr_conv;
34853         this_ptr_conv.inner = untag_ptr(this_ptr);
34854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34856         this_ptr_conv.is_owned = false;
34857         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34858         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
34859         int64_t ret_ref = tag_ptr(ret_copy, true);
34860         return ret_ref;
34861 }
34862
34863 void  CS_LDK_ChannelDetails_set_confirmations_required(int64_t this_ptr, int64_t val) {
34864         LDKChannelDetails this_ptr_conv;
34865         this_ptr_conv.inner = untag_ptr(this_ptr);
34866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34868         this_ptr_conv.is_owned = false;
34869         void* val_ptr = untag_ptr(val);
34870         CHECK_ACCESS(val_ptr);
34871         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34872         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
34873         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
34874 }
34875
34876 int64_t  CS_LDK_ChannelDetails_get_confirmations(int64_t this_ptr) {
34877         LDKChannelDetails this_ptr_conv;
34878         this_ptr_conv.inner = untag_ptr(this_ptr);
34879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34881         this_ptr_conv.is_owned = false;
34882         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34883         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
34884         int64_t ret_ref = tag_ptr(ret_copy, true);
34885         return ret_ref;
34886 }
34887
34888 void  CS_LDK_ChannelDetails_set_confirmations(int64_t this_ptr, int64_t val) {
34889         LDKChannelDetails this_ptr_conv;
34890         this_ptr_conv.inner = untag_ptr(this_ptr);
34891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34893         this_ptr_conv.is_owned = false;
34894         void* val_ptr = untag_ptr(val);
34895         CHECK_ACCESS(val_ptr);
34896         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34897         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
34898         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
34899 }
34900
34901 int64_t  CS_LDK_ChannelDetails_get_force_close_spend_delay(int64_t this_ptr) {
34902         LDKChannelDetails this_ptr_conv;
34903         this_ptr_conv.inner = untag_ptr(this_ptr);
34904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34906         this_ptr_conv.is_owned = false;
34907         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
34908         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
34909         int64_t ret_ref = tag_ptr(ret_copy, true);
34910         return ret_ref;
34911 }
34912
34913 void  CS_LDK_ChannelDetails_set_force_close_spend_delay(int64_t this_ptr, int64_t val) {
34914         LDKChannelDetails this_ptr_conv;
34915         this_ptr_conv.inner = untag_ptr(this_ptr);
34916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34918         this_ptr_conv.is_owned = false;
34919         void* val_ptr = untag_ptr(val);
34920         CHECK_ACCESS(val_ptr);
34921         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
34922         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
34923         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
34924 }
34925
34926 jboolean  CS_LDK_ChannelDetails_get_is_outbound(int64_t this_ptr) {
34927         LDKChannelDetails this_ptr_conv;
34928         this_ptr_conv.inner = untag_ptr(this_ptr);
34929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34931         this_ptr_conv.is_owned = false;
34932         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
34933         return ret_conv;
34934 }
34935
34936 void  CS_LDK_ChannelDetails_set_is_outbound(int64_t this_ptr, jboolean val) {
34937         LDKChannelDetails this_ptr_conv;
34938         this_ptr_conv.inner = untag_ptr(this_ptr);
34939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34941         this_ptr_conv.is_owned = false;
34942         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
34943 }
34944
34945 jboolean  CS_LDK_ChannelDetails_get_is_channel_ready(int64_t this_ptr) {
34946         LDKChannelDetails this_ptr_conv;
34947         this_ptr_conv.inner = untag_ptr(this_ptr);
34948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34950         this_ptr_conv.is_owned = false;
34951         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
34952         return ret_conv;
34953 }
34954
34955 void  CS_LDK_ChannelDetails_set_is_channel_ready(int64_t this_ptr, jboolean val) {
34956         LDKChannelDetails this_ptr_conv;
34957         this_ptr_conv.inner = untag_ptr(this_ptr);
34958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34960         this_ptr_conv.is_owned = false;
34961         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
34962 }
34963
34964 int64_t  CS_LDK_ChannelDetails_get_channel_shutdown_state(int64_t this_ptr) {
34965         LDKChannelDetails this_ptr_conv;
34966         this_ptr_conv.inner = untag_ptr(this_ptr);
34967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34969         this_ptr_conv.is_owned = false;
34970         LDKCOption_ChannelShutdownStateZ *ret_copy = MALLOC(sizeof(LDKCOption_ChannelShutdownStateZ), "LDKCOption_ChannelShutdownStateZ");
34971         *ret_copy = ChannelDetails_get_channel_shutdown_state(&this_ptr_conv);
34972         int64_t ret_ref = tag_ptr(ret_copy, true);
34973         return ret_ref;
34974 }
34975
34976 void  CS_LDK_ChannelDetails_set_channel_shutdown_state(int64_t this_ptr, int64_t val) {
34977         LDKChannelDetails this_ptr_conv;
34978         this_ptr_conv.inner = untag_ptr(this_ptr);
34979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34981         this_ptr_conv.is_owned = false;
34982         void* val_ptr = untag_ptr(val);
34983         CHECK_ACCESS(val_ptr);
34984         LDKCOption_ChannelShutdownStateZ val_conv = *(LDKCOption_ChannelShutdownStateZ*)(val_ptr);
34985         val_conv = COption_ChannelShutdownStateZ_clone((LDKCOption_ChannelShutdownStateZ*)untag_ptr(val));
34986         ChannelDetails_set_channel_shutdown_state(&this_ptr_conv, val_conv);
34987 }
34988
34989 jboolean  CS_LDK_ChannelDetails_get_is_usable(int64_t this_ptr) {
34990         LDKChannelDetails this_ptr_conv;
34991         this_ptr_conv.inner = untag_ptr(this_ptr);
34992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34994         this_ptr_conv.is_owned = false;
34995         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
34996         return ret_conv;
34997 }
34998
34999 void  CS_LDK_ChannelDetails_set_is_usable(int64_t this_ptr, jboolean val) {
35000         LDKChannelDetails this_ptr_conv;
35001         this_ptr_conv.inner = untag_ptr(this_ptr);
35002         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35004         this_ptr_conv.is_owned = false;
35005         ChannelDetails_set_is_usable(&this_ptr_conv, val);
35006 }
35007
35008 jboolean  CS_LDK_ChannelDetails_get_is_public(int64_t this_ptr) {
35009         LDKChannelDetails this_ptr_conv;
35010         this_ptr_conv.inner = untag_ptr(this_ptr);
35011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35013         this_ptr_conv.is_owned = false;
35014         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
35015         return ret_conv;
35016 }
35017
35018 void  CS_LDK_ChannelDetails_set_is_public(int64_t this_ptr, jboolean val) {
35019         LDKChannelDetails this_ptr_conv;
35020         this_ptr_conv.inner = untag_ptr(this_ptr);
35021         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35023         this_ptr_conv.is_owned = false;
35024         ChannelDetails_set_is_public(&this_ptr_conv, val);
35025 }
35026
35027 int64_t  CS_LDK_ChannelDetails_get_inbound_htlc_minimum_msat(int64_t this_ptr) {
35028         LDKChannelDetails this_ptr_conv;
35029         this_ptr_conv.inner = untag_ptr(this_ptr);
35030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35032         this_ptr_conv.is_owned = false;
35033         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35034         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
35035         int64_t ret_ref = tag_ptr(ret_copy, true);
35036         return ret_ref;
35037 }
35038
35039 void  CS_LDK_ChannelDetails_set_inbound_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
35040         LDKChannelDetails this_ptr_conv;
35041         this_ptr_conv.inner = untag_ptr(this_ptr);
35042         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35044         this_ptr_conv.is_owned = false;
35045         void* val_ptr = untag_ptr(val);
35046         CHECK_ACCESS(val_ptr);
35047         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35048         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
35049         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
35050 }
35051
35052 int64_t  CS_LDK_ChannelDetails_get_inbound_htlc_maximum_msat(int64_t this_ptr) {
35053         LDKChannelDetails this_ptr_conv;
35054         this_ptr_conv.inner = untag_ptr(this_ptr);
35055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35057         this_ptr_conv.is_owned = false;
35058         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35059         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
35060         int64_t ret_ref = tag_ptr(ret_copy, true);
35061         return ret_ref;
35062 }
35063
35064 void  CS_LDK_ChannelDetails_set_inbound_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
35065         LDKChannelDetails this_ptr_conv;
35066         this_ptr_conv.inner = untag_ptr(this_ptr);
35067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35069         this_ptr_conv.is_owned = false;
35070         void* val_ptr = untag_ptr(val);
35071         CHECK_ACCESS(val_ptr);
35072         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35073         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
35074         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
35075 }
35076
35077 int64_t  CS_LDK_ChannelDetails_get_config(int64_t this_ptr) {
35078         LDKChannelDetails this_ptr_conv;
35079         this_ptr_conv.inner = untag_ptr(this_ptr);
35080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35082         this_ptr_conv.is_owned = false;
35083         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
35084         int64_t ret_ref = 0;
35085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35087         return ret_ref;
35088 }
35089
35090 void  CS_LDK_ChannelDetails_set_config(int64_t this_ptr, int64_t val) {
35091         LDKChannelDetails this_ptr_conv;
35092         this_ptr_conv.inner = untag_ptr(this_ptr);
35093         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35095         this_ptr_conv.is_owned = false;
35096         LDKChannelConfig val_conv;
35097         val_conv.inner = untag_ptr(val);
35098         val_conv.is_owned = ptr_is_owned(val);
35099         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35100         val_conv = ChannelConfig_clone(&val_conv);
35101         ChannelDetails_set_config(&this_ptr_conv, val_conv);
35102 }
35103
35104 int64_t  CS_LDK_ChannelDetails_new(int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int8_tArray user_channel_id_arg, int64_t feerate_sat_per_1000_weight_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t next_outbound_htlc_minimum_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t confirmations_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, int64_t channel_shutdown_state_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
35105         LDKThirtyTwoBytes channel_id_arg_ref;
35106         CHECK(channel_id_arg->arr_len == 32);
35107         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
35108         LDKChannelCounterparty counterparty_arg_conv;
35109         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
35110         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
35112         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
35113         LDKOutPoint funding_txo_arg_conv;
35114         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
35115         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
35116         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
35117         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
35118         LDKChannelTypeFeatures channel_type_arg_conv;
35119         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
35120         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
35121         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
35122         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
35123         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
35124         CHECK_ACCESS(short_channel_id_arg_ptr);
35125         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
35126         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
35127         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
35128         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
35129         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
35130         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
35131         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
35132         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
35133         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
35134         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
35135         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
35136         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
35137         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
35138         LDKU128 user_channel_id_arg_ref;
35139         CHECK(user_channel_id_arg->arr_len == 16);
35140         memcpy(user_channel_id_arg_ref.le_bytes, user_channel_id_arg->elems, 16); FREE(user_channel_id_arg);
35141         void* feerate_sat_per_1000_weight_arg_ptr = untag_ptr(feerate_sat_per_1000_weight_arg);
35142         CHECK_ACCESS(feerate_sat_per_1000_weight_arg_ptr);
35143         LDKCOption_u32Z feerate_sat_per_1000_weight_arg_conv = *(LDKCOption_u32Z*)(feerate_sat_per_1000_weight_arg_ptr);
35144         feerate_sat_per_1000_weight_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(feerate_sat_per_1000_weight_arg));
35145         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
35146         CHECK_ACCESS(confirmations_required_arg_ptr);
35147         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
35148         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
35149         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
35150         CHECK_ACCESS(confirmations_arg_ptr);
35151         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
35152         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
35153         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
35154         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
35155         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
35156         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
35157         void* channel_shutdown_state_arg_ptr = untag_ptr(channel_shutdown_state_arg);
35158         CHECK_ACCESS(channel_shutdown_state_arg_ptr);
35159         LDKCOption_ChannelShutdownStateZ channel_shutdown_state_arg_conv = *(LDKCOption_ChannelShutdownStateZ*)(channel_shutdown_state_arg_ptr);
35160         channel_shutdown_state_arg_conv = COption_ChannelShutdownStateZ_clone((LDKCOption_ChannelShutdownStateZ*)untag_ptr(channel_shutdown_state_arg));
35161         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
35162         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
35163         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
35164         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
35165         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
35166         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
35167         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
35168         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
35169         LDKChannelConfig config_arg_conv;
35170         config_arg_conv.inner = untag_ptr(config_arg);
35171         config_arg_conv.is_owned = ptr_is_owned(config_arg);
35172         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
35173         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
35174         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg_ref, feerate_sat_per_1000_weight_arg_conv, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, next_outbound_htlc_minimum_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, confirmations_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, channel_shutdown_state_arg_conv, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
35175         int64_t ret_ref = 0;
35176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35178         return ret_ref;
35179 }
35180
35181 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
35182         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
35183         int64_t ret_ref = 0;
35184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35186         return ret_ref;
35187 }
35188 int64_t  CS_LDK_ChannelDetails_clone_ptr(int64_t arg) {
35189         LDKChannelDetails arg_conv;
35190         arg_conv.inner = untag_ptr(arg);
35191         arg_conv.is_owned = ptr_is_owned(arg);
35192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35193         arg_conv.is_owned = false;
35194         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
35195         return ret_conv;
35196 }
35197
35198 int64_t  CS_LDK_ChannelDetails_clone(int64_t orig) {
35199         LDKChannelDetails orig_conv;
35200         orig_conv.inner = untag_ptr(orig);
35201         orig_conv.is_owned = ptr_is_owned(orig);
35202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35203         orig_conv.is_owned = false;
35204         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
35205         int64_t ret_ref = 0;
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35207         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35208         return ret_ref;
35209 }
35210
35211 int64_t  CS_LDK_ChannelDetails_get_inbound_payment_scid(int64_t this_arg) {
35212         LDKChannelDetails this_arg_conv;
35213         this_arg_conv.inner = untag_ptr(this_arg);
35214         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35216         this_arg_conv.is_owned = false;
35217         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35218         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
35219         int64_t ret_ref = tag_ptr(ret_copy, true);
35220         return ret_ref;
35221 }
35222
35223 int64_t  CS_LDK_ChannelDetails_get_outbound_payment_scid(int64_t this_arg) {
35224         LDKChannelDetails this_arg_conv;
35225         this_arg_conv.inner = untag_ptr(this_arg);
35226         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35228         this_arg_conv.is_owned = false;
35229         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35230         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
35231         int64_t ret_ref = tag_ptr(ret_copy, true);
35232         return ret_ref;
35233 }
35234
35235 int32_t  CS_LDK_ChannelShutdownState_clone(int64_t orig) {
35236         LDKChannelShutdownState* orig_conv = (LDKChannelShutdownState*)untag_ptr(orig);
35237         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_clone(orig_conv));
35238         return ret_conv;
35239 }
35240
35241 int32_t  CS_LDK_ChannelShutdownState_not_shutting_down() {
35242         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_not_shutting_down());
35243         return ret_conv;
35244 }
35245
35246 int32_t  CS_LDK_ChannelShutdownState_shutdown_initiated() {
35247         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_shutdown_initiated());
35248         return ret_conv;
35249 }
35250
35251 int32_t  CS_LDK_ChannelShutdownState_resolving_htlcs() {
35252         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_resolving_htlcs());
35253         return ret_conv;
35254 }
35255
35256 int32_t  CS_LDK_ChannelShutdownState_negotiating_closing_fee() {
35257         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_negotiating_closing_fee());
35258         return ret_conv;
35259 }
35260
35261 int32_t  CS_LDK_ChannelShutdownState_shutdown_complete() {
35262         int32_t ret_conv = LDKChannelShutdownState_to_cs(ChannelShutdownState_shutdown_complete());
35263         return ret_conv;
35264 }
35265
35266 jboolean  CS_LDK_ChannelShutdownState_eq(int64_t a, int64_t b) {
35267         LDKChannelShutdownState* a_conv = (LDKChannelShutdownState*)untag_ptr(a);
35268         LDKChannelShutdownState* b_conv = (LDKChannelShutdownState*)untag_ptr(b);
35269         jboolean ret_conv = ChannelShutdownState_eq(a_conv, b_conv);
35270         return ret_conv;
35271 }
35272
35273 void  CS_LDK_RecentPaymentDetails_free(int64_t this_ptr) {
35274         if (!ptr_is_owned(this_ptr)) return;
35275         void* this_ptr_ptr = untag_ptr(this_ptr);
35276         CHECK_ACCESS(this_ptr_ptr);
35277         LDKRecentPaymentDetails this_ptr_conv = *(LDKRecentPaymentDetails*)(this_ptr_ptr);
35278         FREE(untag_ptr(this_ptr));
35279         RecentPaymentDetails_free(this_ptr_conv);
35280 }
35281
35282 static inline uint64_t RecentPaymentDetails_clone_ptr(LDKRecentPaymentDetails *NONNULL_PTR arg) {
35283         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35284         *ret_copy = RecentPaymentDetails_clone(arg);
35285         int64_t ret_ref = tag_ptr(ret_copy, true);
35286         return ret_ref;
35287 }
35288 int64_t  CS_LDK_RecentPaymentDetails_clone_ptr(int64_t arg) {
35289         LDKRecentPaymentDetails* arg_conv = (LDKRecentPaymentDetails*)untag_ptr(arg);
35290         int64_t ret_conv = RecentPaymentDetails_clone_ptr(arg_conv);
35291         return ret_conv;
35292 }
35293
35294 int64_t  CS_LDK_RecentPaymentDetails_clone(int64_t orig) {
35295         LDKRecentPaymentDetails* orig_conv = (LDKRecentPaymentDetails*)untag_ptr(orig);
35296         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35297         *ret_copy = RecentPaymentDetails_clone(orig_conv);
35298         int64_t ret_ref = tag_ptr(ret_copy, true);
35299         return ret_ref;
35300 }
35301
35302 int64_t  CS_LDK_RecentPaymentDetails_awaiting_invoice(int8_tArray payment_id) {
35303         LDKThirtyTwoBytes payment_id_ref;
35304         CHECK(payment_id->arr_len == 32);
35305         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35306         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35307         *ret_copy = RecentPaymentDetails_awaiting_invoice(payment_id_ref);
35308         int64_t ret_ref = tag_ptr(ret_copy, true);
35309         return ret_ref;
35310 }
35311
35312 int64_t  CS_LDK_RecentPaymentDetails_pending(int8_tArray payment_id, int8_tArray payment_hash, int64_t total_msat) {
35313         LDKThirtyTwoBytes payment_id_ref;
35314         CHECK(payment_id->arr_len == 32);
35315         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35316         LDKThirtyTwoBytes payment_hash_ref;
35317         CHECK(payment_hash->arr_len == 32);
35318         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35319         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35320         *ret_copy = RecentPaymentDetails_pending(payment_id_ref, payment_hash_ref, total_msat);
35321         int64_t ret_ref = tag_ptr(ret_copy, true);
35322         return ret_ref;
35323 }
35324
35325 int64_t  CS_LDK_RecentPaymentDetails_fulfilled(int8_tArray payment_id, int64_t payment_hash) {
35326         LDKThirtyTwoBytes payment_id_ref;
35327         CHECK(payment_id->arr_len == 32);
35328         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35329         void* payment_hash_ptr = untag_ptr(payment_hash);
35330         CHECK_ACCESS(payment_hash_ptr);
35331         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
35332         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
35333         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35334         *ret_copy = RecentPaymentDetails_fulfilled(payment_id_ref, payment_hash_conv);
35335         int64_t ret_ref = tag_ptr(ret_copy, true);
35336         return ret_ref;
35337 }
35338
35339 int64_t  CS_LDK_RecentPaymentDetails_abandoned(int8_tArray payment_id, int8_tArray payment_hash) {
35340         LDKThirtyTwoBytes payment_id_ref;
35341         CHECK(payment_id->arr_len == 32);
35342         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35343         LDKThirtyTwoBytes payment_hash_ref;
35344         CHECK(payment_hash->arr_len == 32);
35345         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35346         LDKRecentPaymentDetails *ret_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35347         *ret_copy = RecentPaymentDetails_abandoned(payment_id_ref, payment_hash_ref);
35348         int64_t ret_ref = tag_ptr(ret_copy, true);
35349         return ret_ref;
35350 }
35351
35352 void  CS_LDK_PhantomRouteHints_free(int64_t this_obj) {
35353         LDKPhantomRouteHints this_obj_conv;
35354         this_obj_conv.inner = untag_ptr(this_obj);
35355         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35357         PhantomRouteHints_free(this_obj_conv);
35358 }
35359
35360 int64_tArray  CS_LDK_PhantomRouteHints_get_channels(int64_t this_ptr) {
35361         LDKPhantomRouteHints this_ptr_conv;
35362         this_ptr_conv.inner = untag_ptr(this_ptr);
35363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35365         this_ptr_conv.is_owned = false;
35366         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
35367         int64_tArray ret_arr = NULL;
35368         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35369         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35370         for (size_t q = 0; q < ret_var.datalen; q++) {
35371                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35372                 int64_t ret_conv_16_ref = 0;
35373                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35374                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35375                 ret_arr_ptr[q] = ret_conv_16_ref;
35376         }
35377         
35378         FREE(ret_var.data);
35379         return ret_arr;
35380 }
35381
35382 void  CS_LDK_PhantomRouteHints_set_channels(int64_t this_ptr, int64_tArray val) {
35383         LDKPhantomRouteHints this_ptr_conv;
35384         this_ptr_conv.inner = untag_ptr(this_ptr);
35385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35387         this_ptr_conv.is_owned = false;
35388         LDKCVec_ChannelDetailsZ val_constr;
35389         val_constr.datalen = val->arr_len;
35390         if (val_constr.datalen > 0)
35391                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
35392         else
35393                 val_constr.data = NULL;
35394         int64_t* val_vals = val->elems;
35395         for (size_t q = 0; q < val_constr.datalen; q++) {
35396                 int64_t val_conv_16 = val_vals[q];
35397                 LDKChannelDetails val_conv_16_conv;
35398                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
35399                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
35400                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
35401                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
35402                 val_constr.data[q] = val_conv_16_conv;
35403         }
35404         FREE(val);
35405         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
35406 }
35407
35408 int64_t  CS_LDK_PhantomRouteHints_get_phantom_scid(int64_t this_ptr) {
35409         LDKPhantomRouteHints this_ptr_conv;
35410         this_ptr_conv.inner = untag_ptr(this_ptr);
35411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35413         this_ptr_conv.is_owned = false;
35414         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
35415         return ret_conv;
35416 }
35417
35418 void  CS_LDK_PhantomRouteHints_set_phantom_scid(int64_t this_ptr, int64_t val) {
35419         LDKPhantomRouteHints this_ptr_conv;
35420         this_ptr_conv.inner = untag_ptr(this_ptr);
35421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35423         this_ptr_conv.is_owned = false;
35424         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
35425 }
35426
35427 int8_tArray  CS_LDK_PhantomRouteHints_get_real_node_pubkey(int64_t this_ptr) {
35428         LDKPhantomRouteHints this_ptr_conv;
35429         this_ptr_conv.inner = untag_ptr(this_ptr);
35430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35432         this_ptr_conv.is_owned = false;
35433         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35434         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
35435         return ret_arr;
35436 }
35437
35438 void  CS_LDK_PhantomRouteHints_set_real_node_pubkey(int64_t this_ptr, int8_tArray val) {
35439         LDKPhantomRouteHints this_ptr_conv;
35440         this_ptr_conv.inner = untag_ptr(this_ptr);
35441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35443         this_ptr_conv.is_owned = false;
35444         LDKPublicKey val_ref;
35445         CHECK(val->arr_len == 33);
35446         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
35447         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
35448 }
35449
35450 int64_t  CS_LDK_PhantomRouteHints_new(int64_tArray channels_arg, int64_t phantom_scid_arg, int8_tArray real_node_pubkey_arg) {
35451         LDKCVec_ChannelDetailsZ channels_arg_constr;
35452         channels_arg_constr.datalen = channels_arg->arr_len;
35453         if (channels_arg_constr.datalen > 0)
35454                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
35455         else
35456                 channels_arg_constr.data = NULL;
35457         int64_t* channels_arg_vals = channels_arg->elems;
35458         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
35459                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
35460                 LDKChannelDetails channels_arg_conv_16_conv;
35461                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
35462                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
35463                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
35464                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
35465                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
35466         }
35467         FREE(channels_arg);
35468         LDKPublicKey real_node_pubkey_arg_ref;
35469         CHECK(real_node_pubkey_arg->arr_len == 33);
35470         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
35471         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
35472         int64_t ret_ref = 0;
35473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35474         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35475         return ret_ref;
35476 }
35477
35478 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
35479         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
35480         int64_t ret_ref = 0;
35481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35483         return ret_ref;
35484 }
35485 int64_t  CS_LDK_PhantomRouteHints_clone_ptr(int64_t arg) {
35486         LDKPhantomRouteHints arg_conv;
35487         arg_conv.inner = untag_ptr(arg);
35488         arg_conv.is_owned = ptr_is_owned(arg);
35489         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35490         arg_conv.is_owned = false;
35491         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
35492         return ret_conv;
35493 }
35494
35495 int64_t  CS_LDK_PhantomRouteHints_clone(int64_t orig) {
35496         LDKPhantomRouteHints orig_conv;
35497         orig_conv.inner = untag_ptr(orig);
35498         orig_conv.is_owned = ptr_is_owned(orig);
35499         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35500         orig_conv.is_owned = false;
35501         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
35502         int64_t ret_ref = 0;
35503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35505         return ret_ref;
35506 }
35507
35508 int64_t  CS_LDK_ChannelManager_new(int64_t fee_est, int64_t chain_monitor, int64_t tx_broadcaster, int64_t router, int64_t logger, int64_t entropy_source, int64_t node_signer, int64_t signer_provider, int64_t config, int64_t params, int32_t current_timestamp) {
35509         void* fee_est_ptr = untag_ptr(fee_est);
35510         CHECK_ACCESS(fee_est_ptr);
35511         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
35512         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
35513                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35514                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
35515         }
35516         void* chain_monitor_ptr = untag_ptr(chain_monitor);
35517         CHECK_ACCESS(chain_monitor_ptr);
35518         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
35519         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
35520                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35521                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
35522         }
35523         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
35524         CHECK_ACCESS(tx_broadcaster_ptr);
35525         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
35526         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
35527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35528                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
35529         }
35530         void* router_ptr = untag_ptr(router);
35531         CHECK_ACCESS(router_ptr);
35532         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
35533         if (router_conv.free == LDKRouter_JCalls_free) {
35534                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35535                 LDKRouter_JCalls_cloned(&router_conv);
35536         }
35537         void* logger_ptr = untag_ptr(logger);
35538         CHECK_ACCESS(logger_ptr);
35539         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35540         if (logger_conv.free == LDKLogger_JCalls_free) {
35541                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35542                 LDKLogger_JCalls_cloned(&logger_conv);
35543         }
35544         void* entropy_source_ptr = untag_ptr(entropy_source);
35545         CHECK_ACCESS(entropy_source_ptr);
35546         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
35547         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
35548                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35549                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
35550         }
35551         void* node_signer_ptr = untag_ptr(node_signer);
35552         CHECK_ACCESS(node_signer_ptr);
35553         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
35554         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
35555                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35556                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
35557         }
35558         void* signer_provider_ptr = untag_ptr(signer_provider);
35559         CHECK_ACCESS(signer_provider_ptr);
35560         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
35561         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
35562                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
35563                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
35564         }
35565         LDKUserConfig config_conv;
35566         config_conv.inner = untag_ptr(config);
35567         config_conv.is_owned = ptr_is_owned(config);
35568         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
35569         config_conv = UserConfig_clone(&config_conv);
35570         LDKChainParameters params_conv;
35571         params_conv.inner = untag_ptr(params);
35572         params_conv.is_owned = ptr_is_owned(params);
35573         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
35574         params_conv = ChainParameters_clone(&params_conv);
35575         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, router_conv, logger_conv, entropy_source_conv, node_signer_conv, signer_provider_conv, config_conv, params_conv, current_timestamp);
35576         int64_t ret_ref = 0;
35577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35579         return ret_ref;
35580 }
35581
35582 int64_t  CS_LDK_ChannelManager_get_current_default_configuration(int64_t this_arg) {
35583         LDKChannelManager this_arg_conv;
35584         this_arg_conv.inner = untag_ptr(this_arg);
35585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35587         this_arg_conv.is_owned = false;
35588         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
35589         int64_t ret_ref = 0;
35590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35592         return ret_ref;
35593 }
35594
35595 int64_t  CS_LDK_ChannelManager_create_channel(int64_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int8_tArray user_channel_id, int64_t override_config) {
35596         LDKChannelManager this_arg_conv;
35597         this_arg_conv.inner = untag_ptr(this_arg);
35598         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35600         this_arg_conv.is_owned = false;
35601         LDKPublicKey their_network_key_ref;
35602         CHECK(their_network_key->arr_len == 33);
35603         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
35604         LDKU128 user_channel_id_ref;
35605         CHECK(user_channel_id->arr_len == 16);
35606         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
35607         LDKUserConfig override_config_conv;
35608         override_config_conv.inner = untag_ptr(override_config);
35609         override_config_conv.is_owned = ptr_is_owned(override_config);
35610         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
35611         override_config_conv = UserConfig_clone(&override_config_conv);
35612         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
35613         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
35614         return tag_ptr(ret_conv, true);
35615 }
35616
35617 int64_tArray  CS_LDK_ChannelManager_list_channels(int64_t this_arg) {
35618         LDKChannelManager this_arg_conv;
35619         this_arg_conv.inner = untag_ptr(this_arg);
35620         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35622         this_arg_conv.is_owned = false;
35623         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
35624         int64_tArray ret_arr = NULL;
35625         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35626         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35627         for (size_t q = 0; q < ret_var.datalen; q++) {
35628                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35629                 int64_t ret_conv_16_ref = 0;
35630                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35631                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35632                 ret_arr_ptr[q] = ret_conv_16_ref;
35633         }
35634         
35635         FREE(ret_var.data);
35636         return ret_arr;
35637 }
35638
35639 int64_tArray  CS_LDK_ChannelManager_list_usable_channels(int64_t this_arg) {
35640         LDKChannelManager this_arg_conv;
35641         this_arg_conv.inner = untag_ptr(this_arg);
35642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35644         this_arg_conv.is_owned = false;
35645         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
35646         int64_tArray ret_arr = NULL;
35647         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35648         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35649         for (size_t q = 0; q < ret_var.datalen; q++) {
35650                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35651                 int64_t ret_conv_16_ref = 0;
35652                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35653                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35654                 ret_arr_ptr[q] = ret_conv_16_ref;
35655         }
35656         
35657         FREE(ret_var.data);
35658         return ret_arr;
35659 }
35660
35661 int64_tArray  CS_LDK_ChannelManager_list_channels_with_counterparty(int64_t this_arg, int8_tArray counterparty_node_id) {
35662         LDKChannelManager this_arg_conv;
35663         this_arg_conv.inner = untag_ptr(this_arg);
35664         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35666         this_arg_conv.is_owned = false;
35667         LDKPublicKey counterparty_node_id_ref;
35668         CHECK(counterparty_node_id->arr_len == 33);
35669         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35670         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels_with_counterparty(&this_arg_conv, counterparty_node_id_ref);
35671         int64_tArray ret_arr = NULL;
35672         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35673         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35674         for (size_t q = 0; q < ret_var.datalen; q++) {
35675                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
35676                 int64_t ret_conv_16_ref = 0;
35677                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
35678                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
35679                 ret_arr_ptr[q] = ret_conv_16_ref;
35680         }
35681         
35682         FREE(ret_var.data);
35683         return ret_arr;
35684 }
35685
35686 int64_tArray  CS_LDK_ChannelManager_list_recent_payments(int64_t this_arg) {
35687         LDKChannelManager this_arg_conv;
35688         this_arg_conv.inner = untag_ptr(this_arg);
35689         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35691         this_arg_conv.is_owned = false;
35692         LDKCVec_RecentPaymentDetailsZ ret_var = ChannelManager_list_recent_payments(&this_arg_conv);
35693         int64_tArray ret_arr = NULL;
35694         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
35695         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
35696         for (size_t w = 0; w < ret_var.datalen; w++) {
35697                 LDKRecentPaymentDetails *ret_conv_22_copy = MALLOC(sizeof(LDKRecentPaymentDetails), "LDKRecentPaymentDetails");
35698                 *ret_conv_22_copy = ret_var.data[w];
35699                 int64_t ret_conv_22_ref = tag_ptr(ret_conv_22_copy, true);
35700                 ret_arr_ptr[w] = ret_conv_22_ref;
35701         }
35702         
35703         FREE(ret_var.data);
35704         return ret_arr;
35705 }
35706
35707 int64_t  CS_LDK_ChannelManager_close_channel(int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
35708         LDKChannelManager this_arg_conv;
35709         this_arg_conv.inner = untag_ptr(this_arg);
35710         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35712         this_arg_conv.is_owned = false;
35713         uint8_t channel_id_arr[32];
35714         CHECK(channel_id->arr_len == 32);
35715         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35716         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35717         LDKPublicKey counterparty_node_id_ref;
35718         CHECK(counterparty_node_id->arr_len == 33);
35719         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35720         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35721         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
35722         return tag_ptr(ret_conv, true);
35723 }
35724
35725 int64_t  CS_LDK_ChannelManager_close_channel_with_feerate_and_script(int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int64_t target_feerate_sats_per_1000_weight, int64_t shutdown_script) {
35726         LDKChannelManager this_arg_conv;
35727         this_arg_conv.inner = untag_ptr(this_arg);
35728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35730         this_arg_conv.is_owned = false;
35731         uint8_t channel_id_arr[32];
35732         CHECK(channel_id->arr_len == 32);
35733         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35734         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35735         LDKPublicKey counterparty_node_id_ref;
35736         CHECK(counterparty_node_id->arr_len == 33);
35737         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35738         void* target_feerate_sats_per_1000_weight_ptr = untag_ptr(target_feerate_sats_per_1000_weight);
35739         CHECK_ACCESS(target_feerate_sats_per_1000_weight_ptr);
35740         LDKCOption_u32Z target_feerate_sats_per_1000_weight_conv = *(LDKCOption_u32Z*)(target_feerate_sats_per_1000_weight_ptr);
35741         target_feerate_sats_per_1000_weight_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(target_feerate_sats_per_1000_weight));
35742         LDKShutdownScript shutdown_script_conv;
35743         shutdown_script_conv.inner = untag_ptr(shutdown_script);
35744         shutdown_script_conv.is_owned = ptr_is_owned(shutdown_script);
35745         CHECK_INNER_FIELD_ACCESS_OR_NULL(shutdown_script_conv);
35746         shutdown_script_conv = ShutdownScript_clone(&shutdown_script_conv);
35747         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35748         *ret_conv = ChannelManager_close_channel_with_feerate_and_script(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight_conv, shutdown_script_conv);
35749         return tag_ptr(ret_conv, true);
35750 }
35751
35752 int64_t  CS_LDK_ChannelManager_force_close_broadcasting_latest_txn(int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
35753         LDKChannelManager this_arg_conv;
35754         this_arg_conv.inner = untag_ptr(this_arg);
35755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35757         this_arg_conv.is_owned = false;
35758         uint8_t channel_id_arr[32];
35759         CHECK(channel_id->arr_len == 32);
35760         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35761         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35762         LDKPublicKey counterparty_node_id_ref;
35763         CHECK(counterparty_node_id->arr_len == 33);
35764         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35765         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35766         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
35767         return tag_ptr(ret_conv, true);
35768 }
35769
35770 int64_t  CS_LDK_ChannelManager_force_close_without_broadcasting_txn(int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
35771         LDKChannelManager this_arg_conv;
35772         this_arg_conv.inner = untag_ptr(this_arg);
35773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35775         this_arg_conv.is_owned = false;
35776         uint8_t channel_id_arr[32];
35777         CHECK(channel_id->arr_len == 32);
35778         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
35779         uint8_t (*channel_id_ref)[32] = &channel_id_arr;
35780         LDKPublicKey counterparty_node_id_ref;
35781         CHECK(counterparty_node_id->arr_len == 33);
35782         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
35783         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
35784         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
35785         return tag_ptr(ret_conv, true);
35786 }
35787
35788 void  CS_LDK_ChannelManager_force_close_all_channels_broadcasting_latest_txn(int64_t this_arg) {
35789         LDKChannelManager this_arg_conv;
35790         this_arg_conv.inner = untag_ptr(this_arg);
35791         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35793         this_arg_conv.is_owned = false;
35794         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
35795 }
35796
35797 void  CS_LDK_ChannelManager_force_close_all_channels_without_broadcasting_txn(int64_t this_arg) {
35798         LDKChannelManager this_arg_conv;
35799         this_arg_conv.inner = untag_ptr(this_arg);
35800         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35802         this_arg_conv.is_owned = false;
35803         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
35804 }
35805
35806 int64_t  CS_LDK_ChannelManager_send_payment_with_route(int64_t this_arg, int64_t route, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id) {
35807         LDKChannelManager this_arg_conv;
35808         this_arg_conv.inner = untag_ptr(this_arg);
35809         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35811         this_arg_conv.is_owned = false;
35812         LDKRoute route_conv;
35813         route_conv.inner = untag_ptr(route);
35814         route_conv.is_owned = ptr_is_owned(route);
35815         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
35816         route_conv.is_owned = false;
35817         LDKThirtyTwoBytes payment_hash_ref;
35818         CHECK(payment_hash->arr_len == 32);
35819         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35820         LDKRecipientOnionFields recipient_onion_conv;
35821         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35822         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35823         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35824         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35825         LDKThirtyTwoBytes payment_id_ref;
35826         CHECK(payment_id->arr_len == 32);
35827         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35828         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
35829         *ret_conv = ChannelManager_send_payment_with_route(&this_arg_conv, &route_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref);
35830         return tag_ptr(ret_conv, true);
35831 }
35832
35833 int64_t  CS_LDK_ChannelManager_send_payment(int64_t this_arg, int8_tArray payment_hash, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
35834         LDKChannelManager this_arg_conv;
35835         this_arg_conv.inner = untag_ptr(this_arg);
35836         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35838         this_arg_conv.is_owned = false;
35839         LDKThirtyTwoBytes payment_hash_ref;
35840         CHECK(payment_hash->arr_len == 32);
35841         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
35842         LDKRecipientOnionFields recipient_onion_conv;
35843         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35844         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35845         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35846         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35847         LDKThirtyTwoBytes payment_id_ref;
35848         CHECK(payment_id->arr_len == 32);
35849         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35850         LDKRouteParameters route_params_conv;
35851         route_params_conv.inner = untag_ptr(route_params);
35852         route_params_conv.is_owned = ptr_is_owned(route_params);
35853         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
35854         route_params_conv = RouteParameters_clone(&route_params_conv);
35855         void* retry_strategy_ptr = untag_ptr(retry_strategy);
35856         CHECK_ACCESS(retry_strategy_ptr);
35857         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
35858         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
35859         LDKCResult_NoneRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneRetryableSendFailureZ), "LDKCResult_NoneRetryableSendFailureZ");
35860         *ret_conv = ChannelManager_send_payment(&this_arg_conv, payment_hash_ref, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
35861         return tag_ptr(ret_conv, true);
35862 }
35863
35864 void  CS_LDK_ChannelManager_abandon_payment(int64_t this_arg, int8_tArray payment_id) {
35865         LDKChannelManager this_arg_conv;
35866         this_arg_conv.inner = untag_ptr(this_arg);
35867         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35869         this_arg_conv.is_owned = false;
35870         LDKThirtyTwoBytes payment_id_ref;
35871         CHECK(payment_id->arr_len == 32);
35872         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35873         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
35874 }
35875
35876 int64_t  CS_LDK_ChannelManager_send_spontaneous_payment(int64_t this_arg, int64_t route, int64_t payment_preimage, int64_t recipient_onion, int8_tArray payment_id) {
35877         LDKChannelManager this_arg_conv;
35878         this_arg_conv.inner = untag_ptr(this_arg);
35879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35881         this_arg_conv.is_owned = false;
35882         LDKRoute route_conv;
35883         route_conv.inner = untag_ptr(route);
35884         route_conv.is_owned = ptr_is_owned(route);
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
35886         route_conv.is_owned = false;
35887         void* payment_preimage_ptr = untag_ptr(payment_preimage);
35888         CHECK_ACCESS(payment_preimage_ptr);
35889         LDKCOption_ThirtyTwoBytesZ payment_preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_preimage_ptr);
35890         payment_preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_preimage));
35891         LDKRecipientOnionFields recipient_onion_conv;
35892         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35893         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35895         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35896         LDKThirtyTwoBytes payment_id_ref;
35897         CHECK(payment_id->arr_len == 32);
35898         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35899         LDKCResult_ThirtyTwoBytesPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentSendFailureZ), "LDKCResult_ThirtyTwoBytesPaymentSendFailureZ");
35900         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_conv, recipient_onion_conv, payment_id_ref);
35901         return tag_ptr(ret_conv, true);
35902 }
35903
35904 int64_t  CS_LDK_ChannelManager_send_spontaneous_payment_with_retry(int64_t this_arg, int64_t payment_preimage, int64_t recipient_onion, int8_tArray payment_id, int64_t route_params, int64_t retry_strategy) {
35905         LDKChannelManager this_arg_conv;
35906         this_arg_conv.inner = untag_ptr(this_arg);
35907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35909         this_arg_conv.is_owned = false;
35910         void* payment_preimage_ptr = untag_ptr(payment_preimage);
35911         CHECK_ACCESS(payment_preimage_ptr);
35912         LDKCOption_ThirtyTwoBytesZ payment_preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_preimage_ptr);
35913         payment_preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_preimage));
35914         LDKRecipientOnionFields recipient_onion_conv;
35915         recipient_onion_conv.inner = untag_ptr(recipient_onion);
35916         recipient_onion_conv.is_owned = ptr_is_owned(recipient_onion);
35917         CHECK_INNER_FIELD_ACCESS_OR_NULL(recipient_onion_conv);
35918         recipient_onion_conv = RecipientOnionFields_clone(&recipient_onion_conv);
35919         LDKThirtyTwoBytes payment_id_ref;
35920         CHECK(payment_id->arr_len == 32);
35921         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
35922         LDKRouteParameters route_params_conv;
35923         route_params_conv.inner = untag_ptr(route_params);
35924         route_params_conv.is_owned = ptr_is_owned(route_params);
35925         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
35926         route_params_conv = RouteParameters_clone(&route_params_conv);
35927         void* retry_strategy_ptr = untag_ptr(retry_strategy);
35928         CHECK_ACCESS(retry_strategy_ptr);
35929         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
35930         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
35931         LDKCResult_ThirtyTwoBytesRetryableSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesRetryableSendFailureZ), "LDKCResult_ThirtyTwoBytesRetryableSendFailureZ");
35932         *ret_conv = ChannelManager_send_spontaneous_payment_with_retry(&this_arg_conv, payment_preimage_conv, recipient_onion_conv, payment_id_ref, route_params_conv, retry_strategy_conv);
35933         return tag_ptr(ret_conv, true);
35934 }
35935
35936 int64_t  CS_LDK_ChannelManager_send_probe(int64_t this_arg, int64_t path) {
35937         LDKChannelManager this_arg_conv;
35938         this_arg_conv.inner = untag_ptr(this_arg);
35939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35941         this_arg_conv.is_owned = false;
35942         LDKPath path_conv;
35943         path_conv.inner = untag_ptr(path);
35944         path_conv.is_owned = ptr_is_owned(path);
35945         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
35946         path_conv = Path_clone(&path_conv);
35947         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ");
35948         *ret_conv = ChannelManager_send_probe(&this_arg_conv, path_conv);
35949         return tag_ptr(ret_conv, true);
35950 }
35951
35952 int64_t  CS_LDK_ChannelManager_send_spontaneous_preflight_probes(int64_t this_arg, int8_tArray node_id, int64_t amount_msat, int32_t final_cltv_expiry_delta, int64_t liquidity_limit_multiplier) {
35953         LDKChannelManager this_arg_conv;
35954         this_arg_conv.inner = untag_ptr(this_arg);
35955         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35957         this_arg_conv.is_owned = false;
35958         LDKPublicKey node_id_ref;
35959         CHECK(node_id->arr_len == 33);
35960         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
35961         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
35962         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
35963         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
35964         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
35965         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
35966         *ret_conv = ChannelManager_send_spontaneous_preflight_probes(&this_arg_conv, node_id_ref, amount_msat, final_cltv_expiry_delta, liquidity_limit_multiplier_conv);
35967         return tag_ptr(ret_conv, true);
35968 }
35969
35970 int64_t  CS_LDK_ChannelManager_send_preflight_probes(int64_t this_arg, int64_t route_params, int64_t liquidity_limit_multiplier) {
35971         LDKChannelManager this_arg_conv;
35972         this_arg_conv.inner = untag_ptr(this_arg);
35973         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35975         this_arg_conv.is_owned = false;
35976         LDKRouteParameters route_params_conv;
35977         route_params_conv.inner = untag_ptr(route_params);
35978         route_params_conv.is_owned = ptr_is_owned(route_params);
35979         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
35980         route_params_conv = RouteParameters_clone(&route_params_conv);
35981         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
35982         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
35983         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
35984         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
35985         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ");
35986         *ret_conv = ChannelManager_send_preflight_probes(&this_arg_conv, route_params_conv, liquidity_limit_multiplier_conv);
35987         return tag_ptr(ret_conv, true);
35988 }
35989
35990 int64_t  CS_LDK_ChannelManager_funding_transaction_generated(int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
35991         LDKChannelManager this_arg_conv;
35992         this_arg_conv.inner = untag_ptr(this_arg);
35993         this_arg_conv.is_owned = ptr_is_owned(this_arg);
35994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35995         this_arg_conv.is_owned = false;
35996         uint8_t temporary_channel_id_arr[32];
35997         CHECK(temporary_channel_id->arr_len == 32);
35998         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
35999         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
36000         LDKPublicKey counterparty_node_id_ref;
36001         CHECK(counterparty_node_id->arr_len == 33);
36002         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36003         LDKTransaction funding_transaction_ref;
36004         funding_transaction_ref.datalen = funding_transaction->arr_len;
36005         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
36006         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
36007         funding_transaction_ref.data_is_owned = true;
36008         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36009         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
36010         return tag_ptr(ret_conv, true);
36011 }
36012
36013 int64_t  CS_LDK_ChannelManager_batch_funding_transaction_generated(int64_t this_arg, int64_tArray temporary_channels, int8_tArray funding_transaction) {
36014         LDKChannelManager this_arg_conv;
36015         this_arg_conv.inner = untag_ptr(this_arg);
36016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36018         this_arg_conv.is_owned = false;
36019         LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ temporary_channels_constr;
36020         temporary_channels_constr.datalen = temporary_channels->arr_len;
36021         if (temporary_channels_constr.datalen > 0)
36022                 temporary_channels_constr.data = MALLOC(temporary_channels_constr.datalen * sizeof(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ), "LDKCVec_C2Tuple_ThirtyTwoBytesPublicKeyZZ Elements");
36023         else
36024                 temporary_channels_constr.data = NULL;
36025         int64_t* temporary_channels_vals = temporary_channels->elems;
36026         for (size_t j = 0; j < temporary_channels_constr.datalen; j++) {
36027                 int64_t temporary_channels_conv_35 = temporary_channels_vals[j];
36028                 void* temporary_channels_conv_35_ptr = untag_ptr(temporary_channels_conv_35);
36029                 CHECK_ACCESS(temporary_channels_conv_35_ptr);
36030                 LDKC2Tuple_ThirtyTwoBytesPublicKeyZ temporary_channels_conv_35_conv = *(LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)(temporary_channels_conv_35_ptr);
36031                 temporary_channels_conv_35_conv = C2Tuple_ThirtyTwoBytesPublicKeyZ_clone((LDKC2Tuple_ThirtyTwoBytesPublicKeyZ*)untag_ptr(temporary_channels_conv_35));
36032                 temporary_channels_constr.data[j] = temporary_channels_conv_35_conv;
36033         }
36034         FREE(temporary_channels);
36035         LDKTransaction funding_transaction_ref;
36036         funding_transaction_ref.datalen = funding_transaction->arr_len;
36037         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
36038         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
36039         funding_transaction_ref.data_is_owned = true;
36040         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36041         *ret_conv = ChannelManager_batch_funding_transaction_generated(&this_arg_conv, temporary_channels_constr, funding_transaction_ref);
36042         return tag_ptr(ret_conv, true);
36043 }
36044
36045 int64_t  CS_LDK_ChannelManager_update_partial_channel_config(int64_t this_arg, int8_tArray counterparty_node_id, ptrArray channel_ids, int64_t config_update) {
36046         LDKChannelManager this_arg_conv;
36047         this_arg_conv.inner = untag_ptr(this_arg);
36048         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36050         this_arg_conv.is_owned = false;
36051         LDKPublicKey counterparty_node_id_ref;
36052         CHECK(counterparty_node_id->arr_len == 33);
36053         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36054         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
36055         channel_ids_constr.datalen = channel_ids->arr_len;
36056         if (channel_ids_constr.datalen > 0)
36057                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
36058         else
36059                 channel_ids_constr.data = NULL;
36060         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
36061         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
36062                 int8_tArray channel_ids_conv_8 = channel_ids_vals[i];
36063                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
36064                 CHECK(channel_ids_conv_8->arr_len == 32);
36065                 memcpy(channel_ids_conv_8_ref.data, channel_ids_conv_8->elems, 32); FREE(channel_ids_conv_8);
36066                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
36067         }
36068         FREE(channel_ids);
36069         LDKChannelConfigUpdate config_update_conv;
36070         config_update_conv.inner = untag_ptr(config_update);
36071         config_update_conv.is_owned = ptr_is_owned(config_update);
36072         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_update_conv);
36073         config_update_conv.is_owned = false;
36074         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36075         *ret_conv = ChannelManager_update_partial_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_update_conv);
36076         return tag_ptr(ret_conv, true);
36077 }
36078
36079 int64_t  CS_LDK_ChannelManager_update_channel_config(int64_t this_arg, int8_tArray counterparty_node_id, ptrArray channel_ids, int64_t config) {
36080         LDKChannelManager this_arg_conv;
36081         this_arg_conv.inner = untag_ptr(this_arg);
36082         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36084         this_arg_conv.is_owned = false;
36085         LDKPublicKey counterparty_node_id_ref;
36086         CHECK(counterparty_node_id->arr_len == 33);
36087         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36088         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
36089         channel_ids_constr.datalen = channel_ids->arr_len;
36090         if (channel_ids_constr.datalen > 0)
36091                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
36092         else
36093                 channel_ids_constr.data = NULL;
36094         int8_tArray* channel_ids_vals = (void*) channel_ids->elems;
36095         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
36096                 int8_tArray channel_ids_conv_8 = channel_ids_vals[i];
36097                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
36098                 CHECK(channel_ids_conv_8->arr_len == 32);
36099                 memcpy(channel_ids_conv_8_ref.data, channel_ids_conv_8->elems, 32); FREE(channel_ids_conv_8);
36100                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
36101         }
36102         FREE(channel_ids);
36103         LDKChannelConfig config_conv;
36104         config_conv.inner = untag_ptr(config);
36105         config_conv.is_owned = ptr_is_owned(config);
36106         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
36107         config_conv.is_owned = false;
36108         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36109         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
36110         return tag_ptr(ret_conv, true);
36111 }
36112
36113 int64_t  CS_LDK_ChannelManager_forward_intercepted_htlc(int64_t this_arg, int8_tArray intercept_id, int8_tArray next_hop_channel_id, int8_tArray next_node_id, int64_t amt_to_forward_msat) {
36114         LDKChannelManager this_arg_conv;
36115         this_arg_conv.inner = untag_ptr(this_arg);
36116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36118         this_arg_conv.is_owned = false;
36119         LDKThirtyTwoBytes intercept_id_ref;
36120         CHECK(intercept_id->arr_len == 32);
36121         memcpy(intercept_id_ref.data, intercept_id->elems, 32); FREE(intercept_id);
36122         uint8_t next_hop_channel_id_arr[32];
36123         CHECK(next_hop_channel_id->arr_len == 32);
36124         memcpy(next_hop_channel_id_arr, next_hop_channel_id->elems, 32); FREE(next_hop_channel_id);
36125         uint8_t (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
36126         LDKPublicKey next_node_id_ref;
36127         CHECK(next_node_id->arr_len == 33);
36128         memcpy(next_node_id_ref.compressed_form, next_node_id->elems, 33); FREE(next_node_id);
36129         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36130         *ret_conv = ChannelManager_forward_intercepted_htlc(&this_arg_conv, intercept_id_ref, next_hop_channel_id_ref, next_node_id_ref, amt_to_forward_msat);
36131         return tag_ptr(ret_conv, true);
36132 }
36133
36134 int64_t  CS_LDK_ChannelManager_fail_intercepted_htlc(int64_t this_arg, int8_tArray intercept_id) {
36135         LDKChannelManager this_arg_conv;
36136         this_arg_conv.inner = untag_ptr(this_arg);
36137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36139         this_arg_conv.is_owned = false;
36140         LDKThirtyTwoBytes intercept_id_ref;
36141         CHECK(intercept_id->arr_len == 32);
36142         memcpy(intercept_id_ref.data, intercept_id->elems, 32); FREE(intercept_id);
36143         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36144         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
36145         return tag_ptr(ret_conv, true);
36146 }
36147
36148 void  CS_LDK_ChannelManager_process_pending_htlc_forwards(int64_t this_arg) {
36149         LDKChannelManager this_arg_conv;
36150         this_arg_conv.inner = untag_ptr(this_arg);
36151         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36153         this_arg_conv.is_owned = false;
36154         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
36155 }
36156
36157 void  CS_LDK_ChannelManager_timer_tick_occurred(int64_t this_arg) {
36158         LDKChannelManager this_arg_conv;
36159         this_arg_conv.inner = untag_ptr(this_arg);
36160         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36162         this_arg_conv.is_owned = false;
36163         ChannelManager_timer_tick_occurred(&this_arg_conv);
36164 }
36165
36166 void  CS_LDK_ChannelManager_fail_htlc_backwards(int64_t this_arg, int8_tArray payment_hash) {
36167         LDKChannelManager this_arg_conv;
36168         this_arg_conv.inner = untag_ptr(this_arg);
36169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36171         this_arg_conv.is_owned = false;
36172         uint8_t payment_hash_arr[32];
36173         CHECK(payment_hash->arr_len == 32);
36174         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
36175         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
36176         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
36177 }
36178
36179 void  CS_LDK_ChannelManager_fail_htlc_backwards_with_reason(int64_t this_arg, int8_tArray payment_hash, int64_t failure_code) {
36180         LDKChannelManager this_arg_conv;
36181         this_arg_conv.inner = untag_ptr(this_arg);
36182         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36184         this_arg_conv.is_owned = false;
36185         uint8_t payment_hash_arr[32];
36186         CHECK(payment_hash->arr_len == 32);
36187         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
36188         uint8_t (*payment_hash_ref)[32] = &payment_hash_arr;
36189         void* failure_code_ptr = untag_ptr(failure_code);
36190         CHECK_ACCESS(failure_code_ptr);
36191         LDKFailureCode failure_code_conv = *(LDKFailureCode*)(failure_code_ptr);
36192         failure_code_conv = FailureCode_clone((LDKFailureCode*)untag_ptr(failure_code));
36193         ChannelManager_fail_htlc_backwards_with_reason(&this_arg_conv, payment_hash_ref, failure_code_conv);
36194 }
36195
36196 void  CS_LDK_ChannelManager_claim_funds(int64_t this_arg, int8_tArray payment_preimage) {
36197         LDKChannelManager this_arg_conv;
36198         this_arg_conv.inner = untag_ptr(this_arg);
36199         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36201         this_arg_conv.is_owned = false;
36202         LDKThirtyTwoBytes payment_preimage_ref;
36203         CHECK(payment_preimage->arr_len == 32);
36204         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
36205         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
36206 }
36207
36208 void  CS_LDK_ChannelManager_claim_funds_with_known_custom_tlvs(int64_t this_arg, int8_tArray payment_preimage) {
36209         LDKChannelManager this_arg_conv;
36210         this_arg_conv.inner = untag_ptr(this_arg);
36211         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36213         this_arg_conv.is_owned = false;
36214         LDKThirtyTwoBytes payment_preimage_ref;
36215         CHECK(payment_preimage->arr_len == 32);
36216         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
36217         ChannelManager_claim_funds_with_known_custom_tlvs(&this_arg_conv, payment_preimage_ref);
36218 }
36219
36220 int8_tArray  CS_LDK_ChannelManager_get_our_node_id(int64_t this_arg) {
36221         LDKChannelManager this_arg_conv;
36222         this_arg_conv.inner = untag_ptr(this_arg);
36223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36225         this_arg_conv.is_owned = false;
36226         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
36227         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
36228         return ret_arr;
36229 }
36230
36231 int64_t  CS_LDK_ChannelManager_accept_inbound_channel(int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray user_channel_id) {
36232         LDKChannelManager this_arg_conv;
36233         this_arg_conv.inner = untag_ptr(this_arg);
36234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36236         this_arg_conv.is_owned = false;
36237         uint8_t temporary_channel_id_arr[32];
36238         CHECK(temporary_channel_id->arr_len == 32);
36239         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
36240         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
36241         LDKPublicKey counterparty_node_id_ref;
36242         CHECK(counterparty_node_id->arr_len == 33);
36243         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36244         LDKU128 user_channel_id_ref;
36245         CHECK(user_channel_id->arr_len == 16);
36246         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
36247         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36248         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
36249         return tag_ptr(ret_conv, true);
36250 }
36251
36252 int64_t  CS_LDK_ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray user_channel_id) {
36253         LDKChannelManager this_arg_conv;
36254         this_arg_conv.inner = untag_ptr(this_arg);
36255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36257         this_arg_conv.is_owned = false;
36258         uint8_t temporary_channel_id_arr[32];
36259         CHECK(temporary_channel_id->arr_len == 32);
36260         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
36261         uint8_t (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
36262         LDKPublicKey counterparty_node_id_ref;
36263         CHECK(counterparty_node_id->arr_len == 33);
36264         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
36265         LDKU128 user_channel_id_ref;
36266         CHECK(user_channel_id->arr_len == 16);
36267         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
36268         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
36269         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
36270         return tag_ptr(ret_conv, true);
36271 }
36272
36273 int64_t  CS_LDK_ChannelManager_pay_for_offer(int64_t this_arg, int64_t offer, int64_t quantity, int64_t amount_msats, int64_t payer_note, int8_tArray payment_id, int64_t retry_strategy, int64_t max_total_routing_fee_msat) {
36274         LDKChannelManager this_arg_conv;
36275         this_arg_conv.inner = untag_ptr(this_arg);
36276         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36278         this_arg_conv.is_owned = false;
36279         LDKOffer offer_conv;
36280         offer_conv.inner = untag_ptr(offer);
36281         offer_conv.is_owned = ptr_is_owned(offer);
36282         CHECK_INNER_FIELD_ACCESS_OR_NULL(offer_conv);
36283         offer_conv.is_owned = false;
36284         void* quantity_ptr = untag_ptr(quantity);
36285         CHECK_ACCESS(quantity_ptr);
36286         LDKCOption_u64Z quantity_conv = *(LDKCOption_u64Z*)(quantity_ptr);
36287         quantity_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(quantity));
36288         void* amount_msats_ptr = untag_ptr(amount_msats);
36289         CHECK_ACCESS(amount_msats_ptr);
36290         LDKCOption_u64Z amount_msats_conv = *(LDKCOption_u64Z*)(amount_msats_ptr);
36291         amount_msats_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amount_msats));
36292         void* payer_note_ptr = untag_ptr(payer_note);
36293         CHECK_ACCESS(payer_note_ptr);
36294         LDKCOption_StrZ payer_note_conv = *(LDKCOption_StrZ*)(payer_note_ptr);
36295         payer_note_conv = COption_StrZ_clone((LDKCOption_StrZ*)untag_ptr(payer_note));
36296         LDKThirtyTwoBytes payment_id_ref;
36297         CHECK(payment_id->arr_len == 32);
36298         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
36299         void* retry_strategy_ptr = untag_ptr(retry_strategy);
36300         CHECK_ACCESS(retry_strategy_ptr);
36301         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
36302         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
36303         void* max_total_routing_fee_msat_ptr = untag_ptr(max_total_routing_fee_msat);
36304         CHECK_ACCESS(max_total_routing_fee_msat_ptr);
36305         LDKCOption_u64Z max_total_routing_fee_msat_conv = *(LDKCOption_u64Z*)(max_total_routing_fee_msat_ptr);
36306         max_total_routing_fee_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(max_total_routing_fee_msat));
36307         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
36308         *ret_conv = ChannelManager_pay_for_offer(&this_arg_conv, &offer_conv, quantity_conv, amount_msats_conv, payer_note_conv, payment_id_ref, retry_strategy_conv, max_total_routing_fee_msat_conv);
36309         return tag_ptr(ret_conv, true);
36310 }
36311
36312 int64_t  CS_LDK_ChannelManager_request_refund_payment(int64_t this_arg, int64_t refund) {
36313         LDKChannelManager this_arg_conv;
36314         this_arg_conv.inner = untag_ptr(this_arg);
36315         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36317         this_arg_conv.is_owned = false;
36318         LDKRefund refund_conv;
36319         refund_conv.inner = untag_ptr(refund);
36320         refund_conv.is_owned = ptr_is_owned(refund);
36321         CHECK_INNER_FIELD_ACCESS_OR_NULL(refund_conv);
36322         refund_conv.is_owned = false;
36323         LDKCResult_NoneBolt12SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt12SemanticErrorZ), "LDKCResult_NoneBolt12SemanticErrorZ");
36324         *ret_conv = ChannelManager_request_refund_payment(&this_arg_conv, &refund_conv);
36325         return tag_ptr(ret_conv, true);
36326 }
36327
36328 int64_t  CS_LDK_ChannelManager_create_inbound_payment(int64_t this_arg, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
36329         LDKChannelManager this_arg_conv;
36330         this_arg_conv.inner = untag_ptr(this_arg);
36331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36333         this_arg_conv.is_owned = false;
36334         void* min_value_msat_ptr = untag_ptr(min_value_msat);
36335         CHECK_ACCESS(min_value_msat_ptr);
36336         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
36337         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
36338         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
36339         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
36340         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
36341         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
36342         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
36343         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
36344         return tag_ptr(ret_conv, true);
36345 }
36346
36347 int64_t  CS_LDK_ChannelManager_create_inbound_payment_for_hash(int64_t this_arg, int8_tArray payment_hash, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry) {
36348         LDKChannelManager this_arg_conv;
36349         this_arg_conv.inner = untag_ptr(this_arg);
36350         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36352         this_arg_conv.is_owned = false;
36353         LDKThirtyTwoBytes payment_hash_ref;
36354         CHECK(payment_hash->arr_len == 32);
36355         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
36356         void* min_value_msat_ptr = untag_ptr(min_value_msat);
36357         CHECK_ACCESS(min_value_msat_ptr);
36358         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
36359         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
36360         void* min_final_cltv_expiry_ptr = untag_ptr(min_final_cltv_expiry);
36361         CHECK_ACCESS(min_final_cltv_expiry_ptr);
36362         LDKCOption_u16Z min_final_cltv_expiry_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_ptr);
36363         min_final_cltv_expiry_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry));
36364         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
36365         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_conv);
36366         return tag_ptr(ret_conv, true);
36367 }
36368
36369 int64_t  CS_LDK_ChannelManager_get_payment_preimage(int64_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
36370         LDKChannelManager this_arg_conv;
36371         this_arg_conv.inner = untag_ptr(this_arg);
36372         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36374         this_arg_conv.is_owned = false;
36375         LDKThirtyTwoBytes payment_hash_ref;
36376         CHECK(payment_hash->arr_len == 32);
36377         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
36378         LDKThirtyTwoBytes payment_secret_ref;
36379         CHECK(payment_secret->arr_len == 32);
36380         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
36381         LDKCResult_ThirtyTwoBytesAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesAPIErrorZ), "LDKCResult_ThirtyTwoBytesAPIErrorZ");
36382         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
36383         return tag_ptr(ret_conv, true);
36384 }
36385
36386 int64_t  CS_LDK_ChannelManager_get_phantom_scid(int64_t this_arg) {
36387         LDKChannelManager this_arg_conv;
36388         this_arg_conv.inner = untag_ptr(this_arg);
36389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36391         this_arg_conv.is_owned = false;
36392         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
36393         return ret_conv;
36394 }
36395
36396 int64_t  CS_LDK_ChannelManager_get_phantom_route_hints(int64_t this_arg) {
36397         LDKChannelManager this_arg_conv;
36398         this_arg_conv.inner = untag_ptr(this_arg);
36399         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36401         this_arg_conv.is_owned = false;
36402         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
36403         int64_t ret_ref = 0;
36404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36405         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36406         return ret_ref;
36407 }
36408
36409 int64_t  CS_LDK_ChannelManager_get_intercept_scid(int64_t this_arg) {
36410         LDKChannelManager this_arg_conv;
36411         this_arg_conv.inner = untag_ptr(this_arg);
36412         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36414         this_arg_conv.is_owned = false;
36415         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
36416         return ret_conv;
36417 }
36418
36419 int64_t  CS_LDK_ChannelManager_compute_inflight_htlcs(int64_t this_arg) {
36420         LDKChannelManager this_arg_conv;
36421         this_arg_conv.inner = untag_ptr(this_arg);
36422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36424         this_arg_conv.is_owned = false;
36425         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
36426         int64_t ret_ref = 0;
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36428         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36429         return ret_ref;
36430 }
36431
36432 int64_t  CS_LDK_ChannelManager_as_MessageSendEventsProvider(int64_t this_arg) {
36433         LDKChannelManager this_arg_conv;
36434         this_arg_conv.inner = untag_ptr(this_arg);
36435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36437         this_arg_conv.is_owned = false;
36438         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36439         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
36440         return tag_ptr(ret_ret, true);
36441 }
36442
36443 int64_t  CS_LDK_ChannelManager_as_EventsProvider(int64_t this_arg) {
36444         LDKChannelManager this_arg_conv;
36445         this_arg_conv.inner = untag_ptr(this_arg);
36446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36448         this_arg_conv.is_owned = false;
36449         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
36450         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
36451         return tag_ptr(ret_ret, true);
36452 }
36453
36454 int64_t  CS_LDK_ChannelManager_as_Listen(int64_t this_arg) {
36455         LDKChannelManager this_arg_conv;
36456         this_arg_conv.inner = untag_ptr(this_arg);
36457         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36459         this_arg_conv.is_owned = false;
36460         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
36461         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
36462         return tag_ptr(ret_ret, true);
36463 }
36464
36465 int64_t  CS_LDK_ChannelManager_as_Confirm(int64_t this_arg) {
36466         LDKChannelManager this_arg_conv;
36467         this_arg_conv.inner = untag_ptr(this_arg);
36468         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36470         this_arg_conv.is_owned = false;
36471         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
36472         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
36473         return tag_ptr(ret_ret, true);
36474 }
36475
36476 int64_t  CS_LDK_ChannelManager_get_event_or_persistence_needed_future(int64_t this_arg) {
36477         LDKChannelManager this_arg_conv;
36478         this_arg_conv.inner = untag_ptr(this_arg);
36479         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36481         this_arg_conv.is_owned = false;
36482         LDKFuture ret_var = ChannelManager_get_event_or_persistence_needed_future(&this_arg_conv);
36483         int64_t ret_ref = 0;
36484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36486         return ret_ref;
36487 }
36488
36489 jboolean  CS_LDK_ChannelManager_get_and_clear_needs_persistence(int64_t this_arg) {
36490         LDKChannelManager this_arg_conv;
36491         this_arg_conv.inner = untag_ptr(this_arg);
36492         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36494         this_arg_conv.is_owned = false;
36495         jboolean ret_conv = ChannelManager_get_and_clear_needs_persistence(&this_arg_conv);
36496         return ret_conv;
36497 }
36498
36499 int64_t  CS_LDK_ChannelManager_current_best_block(int64_t this_arg) {
36500         LDKChannelManager this_arg_conv;
36501         this_arg_conv.inner = untag_ptr(this_arg);
36502         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36504         this_arg_conv.is_owned = false;
36505         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
36506         int64_t ret_ref = 0;
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36509         return ret_ref;
36510 }
36511
36512 int64_t  CS_LDK_ChannelManager_node_features(int64_t this_arg) {
36513         LDKChannelManager this_arg_conv;
36514         this_arg_conv.inner = untag_ptr(this_arg);
36515         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36517         this_arg_conv.is_owned = false;
36518         LDKNodeFeatures ret_var = ChannelManager_node_features(&this_arg_conv);
36519         int64_t ret_ref = 0;
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36522         return ret_ref;
36523 }
36524
36525 int64_t  CS_LDK_ChannelManager_channel_features(int64_t this_arg) {
36526         LDKChannelManager this_arg_conv;
36527         this_arg_conv.inner = untag_ptr(this_arg);
36528         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36530         this_arg_conv.is_owned = false;
36531         LDKChannelFeatures ret_var = ChannelManager_channel_features(&this_arg_conv);
36532         int64_t ret_ref = 0;
36533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36535         return ret_ref;
36536 }
36537
36538 int64_t  CS_LDK_ChannelManager_channel_type_features(int64_t this_arg) {
36539         LDKChannelManager this_arg_conv;
36540         this_arg_conv.inner = untag_ptr(this_arg);
36541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36543         this_arg_conv.is_owned = false;
36544         LDKChannelTypeFeatures ret_var = ChannelManager_channel_type_features(&this_arg_conv);
36545         int64_t ret_ref = 0;
36546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36548         return ret_ref;
36549 }
36550
36551 int64_t  CS_LDK_ChannelManager_init_features(int64_t this_arg) {
36552         LDKChannelManager this_arg_conv;
36553         this_arg_conv.inner = untag_ptr(this_arg);
36554         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36556         this_arg_conv.is_owned = false;
36557         LDKInitFeatures ret_var = ChannelManager_init_features(&this_arg_conv);
36558         int64_t ret_ref = 0;
36559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36561         return ret_ref;
36562 }
36563
36564 int64_t  CS_LDK_ChannelManager_as_ChannelMessageHandler(int64_t this_arg) {
36565         LDKChannelManager this_arg_conv;
36566         this_arg_conv.inner = untag_ptr(this_arg);
36567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36569         this_arg_conv.is_owned = false;
36570         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
36571         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
36572         return tag_ptr(ret_ret, true);
36573 }
36574
36575 int64_t  CS_LDK_ChannelManager_as_OffersMessageHandler(int64_t this_arg) {
36576         LDKChannelManager this_arg_conv;
36577         this_arg_conv.inner = untag_ptr(this_arg);
36578         this_arg_conv.is_owned = ptr_is_owned(this_arg);
36579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36580         this_arg_conv.is_owned = false;
36581         LDKOffersMessageHandler* ret_ret = MALLOC(sizeof(LDKOffersMessageHandler), "LDKOffersMessageHandler");
36582         *ret_ret = ChannelManager_as_OffersMessageHandler(&this_arg_conv);
36583         return tag_ptr(ret_ret, true);
36584 }
36585
36586 int64_t  CS_LDK_provided_init_features(int64_t config) {
36587         LDKUserConfig config_conv;
36588         config_conv.inner = untag_ptr(config);
36589         config_conv.is_owned = ptr_is_owned(config);
36590         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
36591         config_conv.is_owned = false;
36592         LDKInitFeatures ret_var = provided_init_features(&config_conv);
36593         int64_t ret_ref = 0;
36594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36596         return ret_ref;
36597 }
36598
36599 int8_tArray  CS_LDK_CounterpartyForwardingInfo_write(int64_t obj) {
36600         LDKCounterpartyForwardingInfo obj_conv;
36601         obj_conv.inner = untag_ptr(obj);
36602         obj_conv.is_owned = ptr_is_owned(obj);
36603         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36604         obj_conv.is_owned = false;
36605         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
36606         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36607         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36608         CVec_u8Z_free(ret_var);
36609         return ret_arr;
36610 }
36611
36612 int64_t  CS_LDK_CounterpartyForwardingInfo_read(int8_tArray ser) {
36613         LDKu8slice ser_ref;
36614         ser_ref.datalen = ser->arr_len;
36615         ser_ref.data = ser->elems;
36616         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
36617         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
36618         FREE(ser);
36619         return tag_ptr(ret_conv, true);
36620 }
36621
36622 int8_tArray  CS_LDK_ChannelCounterparty_write(int64_t obj) {
36623         LDKChannelCounterparty obj_conv;
36624         obj_conv.inner = untag_ptr(obj);
36625         obj_conv.is_owned = ptr_is_owned(obj);
36626         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36627         obj_conv.is_owned = false;
36628         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
36629         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36630         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36631         CVec_u8Z_free(ret_var);
36632         return ret_arr;
36633 }
36634
36635 int64_t  CS_LDK_ChannelCounterparty_read(int8_tArray ser) {
36636         LDKu8slice ser_ref;
36637         ser_ref.datalen = ser->arr_len;
36638         ser_ref.data = ser->elems;
36639         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
36640         *ret_conv = ChannelCounterparty_read(ser_ref);
36641         FREE(ser);
36642         return tag_ptr(ret_conv, true);
36643 }
36644
36645 int8_tArray  CS_LDK_ChannelDetails_write(int64_t obj) {
36646         LDKChannelDetails obj_conv;
36647         obj_conv.inner = untag_ptr(obj);
36648         obj_conv.is_owned = ptr_is_owned(obj);
36649         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36650         obj_conv.is_owned = false;
36651         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
36652         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36653         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36654         CVec_u8Z_free(ret_var);
36655         return ret_arr;
36656 }
36657
36658 int64_t  CS_LDK_ChannelDetails_read(int8_tArray ser) {
36659         LDKu8slice ser_ref;
36660         ser_ref.datalen = ser->arr_len;
36661         ser_ref.data = ser->elems;
36662         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
36663         *ret_conv = ChannelDetails_read(ser_ref);
36664         FREE(ser);
36665         return tag_ptr(ret_conv, true);
36666 }
36667
36668 int8_tArray  CS_LDK_PhantomRouteHints_write(int64_t obj) {
36669         LDKPhantomRouteHints obj_conv;
36670         obj_conv.inner = untag_ptr(obj);
36671         obj_conv.is_owned = ptr_is_owned(obj);
36672         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36673         obj_conv.is_owned = false;
36674         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
36675         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36676         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36677         CVec_u8Z_free(ret_var);
36678         return ret_arr;
36679 }
36680
36681 int64_t  CS_LDK_PhantomRouteHints_read(int8_tArray ser) {
36682         LDKu8slice ser_ref;
36683         ser_ref.datalen = ser->arr_len;
36684         ser_ref.data = ser->elems;
36685         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
36686         *ret_conv = PhantomRouteHints_read(ser_ref);
36687         FREE(ser);
36688         return tag_ptr(ret_conv, true);
36689 }
36690
36691 int8_tArray  CS_LDK_ChannelManager_write(int64_t obj) {
36692         LDKChannelManager obj_conv;
36693         obj_conv.inner = untag_ptr(obj);
36694         obj_conv.is_owned = ptr_is_owned(obj);
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36696         obj_conv.is_owned = false;
36697         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
36698         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36699         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36700         CVec_u8Z_free(ret_var);
36701         return ret_arr;
36702 }
36703
36704 int8_tArray  CS_LDK_ChannelShutdownState_write(int64_t obj) {
36705         LDKChannelShutdownState* obj_conv = (LDKChannelShutdownState*)untag_ptr(obj);
36706         LDKCVec_u8Z ret_var = ChannelShutdownState_write(obj_conv);
36707         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36708         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36709         CVec_u8Z_free(ret_var);
36710         return ret_arr;
36711 }
36712
36713 int64_t  CS_LDK_ChannelShutdownState_read(int8_tArray ser) {
36714         LDKu8slice ser_ref;
36715         ser_ref.datalen = ser->arr_len;
36716         ser_ref.data = ser->elems;
36717         LDKCResult_ChannelShutdownStateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelShutdownStateDecodeErrorZ), "LDKCResult_ChannelShutdownStateDecodeErrorZ");
36718         *ret_conv = ChannelShutdownState_read(ser_ref);
36719         FREE(ser);
36720         return tag_ptr(ret_conv, true);
36721 }
36722
36723 void  CS_LDK_ChannelManagerReadArgs_free(int64_t this_obj) {
36724         LDKChannelManagerReadArgs this_obj_conv;
36725         this_obj_conv.inner = untag_ptr(this_obj);
36726         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36728         ChannelManagerReadArgs_free(this_obj_conv);
36729 }
36730
36731 int64_t  CS_LDK_ChannelManagerReadArgs_get_entropy_source(int64_t this_ptr) {
36732         LDKChannelManagerReadArgs this_ptr_conv;
36733         this_ptr_conv.inner = untag_ptr(this_ptr);
36734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36736         this_ptr_conv.is_owned = false;
36737         // WARNING: This object doesn't live past this scope, needs clone!
36738         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_entropy_source(&this_ptr_conv), false);
36739         return ret_ret;
36740 }
36741
36742 void  CS_LDK_ChannelManagerReadArgs_set_entropy_source(int64_t this_ptr, int64_t val) {
36743         LDKChannelManagerReadArgs this_ptr_conv;
36744         this_ptr_conv.inner = untag_ptr(this_ptr);
36745         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36747         this_ptr_conv.is_owned = false;
36748         void* val_ptr = untag_ptr(val);
36749         CHECK_ACCESS(val_ptr);
36750         LDKEntropySource val_conv = *(LDKEntropySource*)(val_ptr);
36751         if (val_conv.free == LDKEntropySource_JCalls_free) {
36752                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36753                 LDKEntropySource_JCalls_cloned(&val_conv);
36754         }
36755         ChannelManagerReadArgs_set_entropy_source(&this_ptr_conv, val_conv);
36756 }
36757
36758 int64_t  CS_LDK_ChannelManagerReadArgs_get_node_signer(int64_t this_ptr) {
36759         LDKChannelManagerReadArgs this_ptr_conv;
36760         this_ptr_conv.inner = untag_ptr(this_ptr);
36761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36763         this_ptr_conv.is_owned = false;
36764         // WARNING: This object doesn't live past this scope, needs clone!
36765         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_node_signer(&this_ptr_conv), false);
36766         return ret_ret;
36767 }
36768
36769 void  CS_LDK_ChannelManagerReadArgs_set_node_signer(int64_t this_ptr, int64_t val) {
36770         LDKChannelManagerReadArgs this_ptr_conv;
36771         this_ptr_conv.inner = untag_ptr(this_ptr);
36772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36774         this_ptr_conv.is_owned = false;
36775         void* val_ptr = untag_ptr(val);
36776         CHECK_ACCESS(val_ptr);
36777         LDKNodeSigner val_conv = *(LDKNodeSigner*)(val_ptr);
36778         if (val_conv.free == LDKNodeSigner_JCalls_free) {
36779                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36780                 LDKNodeSigner_JCalls_cloned(&val_conv);
36781         }
36782         ChannelManagerReadArgs_set_node_signer(&this_ptr_conv, val_conv);
36783 }
36784
36785 int64_t  CS_LDK_ChannelManagerReadArgs_get_signer_provider(int64_t this_ptr) {
36786         LDKChannelManagerReadArgs this_ptr_conv;
36787         this_ptr_conv.inner = untag_ptr(this_ptr);
36788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36790         this_ptr_conv.is_owned = false;
36791         // WARNING: This object doesn't live past this scope, needs clone!
36792         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_signer_provider(&this_ptr_conv), false);
36793         return ret_ret;
36794 }
36795
36796 void  CS_LDK_ChannelManagerReadArgs_set_signer_provider(int64_t this_ptr, int64_t val) {
36797         LDKChannelManagerReadArgs this_ptr_conv;
36798         this_ptr_conv.inner = untag_ptr(this_ptr);
36799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36801         this_ptr_conv.is_owned = false;
36802         void* val_ptr = untag_ptr(val);
36803         CHECK_ACCESS(val_ptr);
36804         LDKSignerProvider val_conv = *(LDKSignerProvider*)(val_ptr);
36805         if (val_conv.free == LDKSignerProvider_JCalls_free) {
36806                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36807                 LDKSignerProvider_JCalls_cloned(&val_conv);
36808         }
36809         ChannelManagerReadArgs_set_signer_provider(&this_ptr_conv, val_conv);
36810 }
36811
36812 int64_t  CS_LDK_ChannelManagerReadArgs_get_fee_estimator(int64_t this_ptr) {
36813         LDKChannelManagerReadArgs this_ptr_conv;
36814         this_ptr_conv.inner = untag_ptr(this_ptr);
36815         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36817         this_ptr_conv.is_owned = false;
36818         // WARNING: This object doesn't live past this scope, needs clone!
36819         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
36820         return ret_ret;
36821 }
36822
36823 void  CS_LDK_ChannelManagerReadArgs_set_fee_estimator(int64_t this_ptr, int64_t val) {
36824         LDKChannelManagerReadArgs this_ptr_conv;
36825         this_ptr_conv.inner = untag_ptr(this_ptr);
36826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36828         this_ptr_conv.is_owned = false;
36829         void* val_ptr = untag_ptr(val);
36830         CHECK_ACCESS(val_ptr);
36831         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
36832         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
36833                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36834                 LDKFeeEstimator_JCalls_cloned(&val_conv);
36835         }
36836         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
36837 }
36838
36839 int64_t  CS_LDK_ChannelManagerReadArgs_get_chain_monitor(int64_t this_ptr) {
36840         LDKChannelManagerReadArgs this_ptr_conv;
36841         this_ptr_conv.inner = untag_ptr(this_ptr);
36842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36844         this_ptr_conv.is_owned = false;
36845         // WARNING: This object doesn't live past this scope, needs clone!
36846         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
36847         return ret_ret;
36848 }
36849
36850 void  CS_LDK_ChannelManagerReadArgs_set_chain_monitor(int64_t this_ptr, int64_t val) {
36851         LDKChannelManagerReadArgs this_ptr_conv;
36852         this_ptr_conv.inner = untag_ptr(this_ptr);
36853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36855         this_ptr_conv.is_owned = false;
36856         void* val_ptr = untag_ptr(val);
36857         CHECK_ACCESS(val_ptr);
36858         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
36859         if (val_conv.free == LDKWatch_JCalls_free) {
36860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36861                 LDKWatch_JCalls_cloned(&val_conv);
36862         }
36863         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
36864 }
36865
36866 int64_t  CS_LDK_ChannelManagerReadArgs_get_tx_broadcaster(int64_t this_ptr) {
36867         LDKChannelManagerReadArgs this_ptr_conv;
36868         this_ptr_conv.inner = untag_ptr(this_ptr);
36869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36871         this_ptr_conv.is_owned = false;
36872         // WARNING: This object doesn't live past this scope, needs clone!
36873         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
36874         return ret_ret;
36875 }
36876
36877 void  CS_LDK_ChannelManagerReadArgs_set_tx_broadcaster(int64_t this_ptr, int64_t val) {
36878         LDKChannelManagerReadArgs this_ptr_conv;
36879         this_ptr_conv.inner = untag_ptr(this_ptr);
36880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36882         this_ptr_conv.is_owned = false;
36883         void* val_ptr = untag_ptr(val);
36884         CHECK_ACCESS(val_ptr);
36885         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
36886         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
36887                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36888                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
36889         }
36890         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
36891 }
36892
36893 int64_t  CS_LDK_ChannelManagerReadArgs_get_router(int64_t this_ptr) {
36894         LDKChannelManagerReadArgs this_ptr_conv;
36895         this_ptr_conv.inner = untag_ptr(this_ptr);
36896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36898         this_ptr_conv.is_owned = false;
36899         // WARNING: This object doesn't live past this scope, needs clone!
36900         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_router(&this_ptr_conv), false);
36901         return ret_ret;
36902 }
36903
36904 void  CS_LDK_ChannelManagerReadArgs_set_router(int64_t this_ptr, int64_t val) {
36905         LDKChannelManagerReadArgs this_ptr_conv;
36906         this_ptr_conv.inner = untag_ptr(this_ptr);
36907         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36909         this_ptr_conv.is_owned = false;
36910         void* val_ptr = untag_ptr(val);
36911         CHECK_ACCESS(val_ptr);
36912         LDKRouter val_conv = *(LDKRouter*)(val_ptr);
36913         if (val_conv.free == LDKRouter_JCalls_free) {
36914                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36915                 LDKRouter_JCalls_cloned(&val_conv);
36916         }
36917         ChannelManagerReadArgs_set_router(&this_ptr_conv, val_conv);
36918 }
36919
36920 int64_t  CS_LDK_ChannelManagerReadArgs_get_logger(int64_t this_ptr) {
36921         LDKChannelManagerReadArgs this_ptr_conv;
36922         this_ptr_conv.inner = untag_ptr(this_ptr);
36923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36925         this_ptr_conv.is_owned = false;
36926         // WARNING: This object doesn't live past this scope, needs clone!
36927         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
36928         return ret_ret;
36929 }
36930
36931 void  CS_LDK_ChannelManagerReadArgs_set_logger(int64_t this_ptr, int64_t val) {
36932         LDKChannelManagerReadArgs this_ptr_conv;
36933         this_ptr_conv.inner = untag_ptr(this_ptr);
36934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36936         this_ptr_conv.is_owned = false;
36937         void* val_ptr = untag_ptr(val);
36938         CHECK_ACCESS(val_ptr);
36939         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
36940         if (val_conv.free == LDKLogger_JCalls_free) {
36941                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36942                 LDKLogger_JCalls_cloned(&val_conv);
36943         }
36944         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
36945 }
36946
36947 int64_t  CS_LDK_ChannelManagerReadArgs_get_default_config(int64_t this_ptr) {
36948         LDKChannelManagerReadArgs this_ptr_conv;
36949         this_ptr_conv.inner = untag_ptr(this_ptr);
36950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36952         this_ptr_conv.is_owned = false;
36953         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
36954         int64_t ret_ref = 0;
36955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36957         return ret_ref;
36958 }
36959
36960 void  CS_LDK_ChannelManagerReadArgs_set_default_config(int64_t this_ptr, int64_t val) {
36961         LDKChannelManagerReadArgs this_ptr_conv;
36962         this_ptr_conv.inner = untag_ptr(this_ptr);
36963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36965         this_ptr_conv.is_owned = false;
36966         LDKUserConfig val_conv;
36967         val_conv.inner = untag_ptr(val);
36968         val_conv.is_owned = ptr_is_owned(val);
36969         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36970         val_conv = UserConfig_clone(&val_conv);
36971         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
36972 }
36973
36974 int64_t  CS_LDK_ChannelManagerReadArgs_new(int64_t entropy_source, int64_t node_signer, int64_t signer_provider, int64_t fee_estimator, int64_t chain_monitor, int64_t tx_broadcaster, int64_t router, int64_t logger, int64_t default_config, int64_tArray channel_monitors) {
36975         void* entropy_source_ptr = untag_ptr(entropy_source);
36976         CHECK_ACCESS(entropy_source_ptr);
36977         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
36978         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
36979                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36980                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
36981         }
36982         void* node_signer_ptr = untag_ptr(node_signer);
36983         CHECK_ACCESS(node_signer_ptr);
36984         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
36985         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
36986                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36987                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
36988         }
36989         void* signer_provider_ptr = untag_ptr(signer_provider);
36990         CHECK_ACCESS(signer_provider_ptr);
36991         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
36992         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
36993                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36994                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
36995         }
36996         void* fee_estimator_ptr = untag_ptr(fee_estimator);
36997         CHECK_ACCESS(fee_estimator_ptr);
36998         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
36999         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
37000                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37001                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
37002         }
37003         void* chain_monitor_ptr = untag_ptr(chain_monitor);
37004         CHECK_ACCESS(chain_monitor_ptr);
37005         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
37006         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
37007                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37008                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
37009         }
37010         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
37011         CHECK_ACCESS(tx_broadcaster_ptr);
37012         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
37013         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
37014                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37015                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
37016         }
37017         void* router_ptr = untag_ptr(router);
37018         CHECK_ACCESS(router_ptr);
37019         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
37020         if (router_conv.free == LDKRouter_JCalls_free) {
37021                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37022                 LDKRouter_JCalls_cloned(&router_conv);
37023         }
37024         void* logger_ptr = untag_ptr(logger);
37025         CHECK_ACCESS(logger_ptr);
37026         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37027         if (logger_conv.free == LDKLogger_JCalls_free) {
37028                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37029                 LDKLogger_JCalls_cloned(&logger_conv);
37030         }
37031         LDKUserConfig default_config_conv;
37032         default_config_conv.inner = untag_ptr(default_config);
37033         default_config_conv.is_owned = ptr_is_owned(default_config);
37034         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
37035         default_config_conv = UserConfig_clone(&default_config_conv);
37036         LDKCVec_ChannelMonitorZ channel_monitors_constr;
37037         channel_monitors_constr.datalen = channel_monitors->arr_len;
37038         if (channel_monitors_constr.datalen > 0)
37039                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
37040         else
37041                 channel_monitors_constr.data = NULL;
37042         int64_t* channel_monitors_vals = channel_monitors->elems;
37043         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
37044                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
37045                 LDKChannelMonitor channel_monitors_conv_16_conv;
37046                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
37047                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
37048                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
37049                 channel_monitors_conv_16_conv.is_owned = false;
37050                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
37051         }
37052         FREE(channel_monitors);
37053         LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(entropy_source_conv, node_signer_conv, signer_provider_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, router_conv, logger_conv, default_config_conv, channel_monitors_constr);
37054         int64_t ret_ref = 0;
37055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37056         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37057         return ret_ref;
37058 }
37059
37060 int64_t  CS_LDK_C2Tuple_ThirtyTwoBytesChannelManagerZ_read(int8_tArray ser, int64_t arg) {
37061         LDKu8slice ser_ref;
37062         ser_ref.datalen = ser->arr_len;
37063         ser_ref.data = ser->elems;
37064         LDKChannelManagerReadArgs arg_conv;
37065         arg_conv.inner = untag_ptr(arg);
37066         arg_conv.is_owned = ptr_is_owned(arg);
37067         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37068         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
37069         
37070         LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ");
37071         *ret_conv = C2Tuple_ThirtyTwoBytesChannelManagerZ_read(ser_ref, arg_conv);
37072         FREE(ser);
37073         return tag_ptr(ret_conv, true);
37074 }
37075
37076 void  CS_LDK_ExpandedKey_free(int64_t this_obj) {
37077         LDKExpandedKey this_obj_conv;
37078         this_obj_conv.inner = untag_ptr(this_obj);
37079         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37081         ExpandedKey_free(this_obj_conv);
37082 }
37083
37084 int64_t  CS_LDK_ExpandedKey_new(int8_tArray key_material) {
37085         uint8_t key_material_arr[32];
37086         CHECK(key_material->arr_len == 32);
37087         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
37088         uint8_t (*key_material_ref)[32] = &key_material_arr;
37089         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
37090         int64_t ret_ref = 0;
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37092         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37093         return ret_ref;
37094 }
37095
37096 int64_t  CS_LDK_create(int64_t keys, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t entropy_source, int64_t current_time, int64_t min_final_cltv_expiry_delta) {
37097         LDKExpandedKey keys_conv;
37098         keys_conv.inner = untag_ptr(keys);
37099         keys_conv.is_owned = ptr_is_owned(keys);
37100         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37101         keys_conv.is_owned = false;
37102         void* min_value_msat_ptr = untag_ptr(min_value_msat);
37103         CHECK_ACCESS(min_value_msat_ptr);
37104         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
37105         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
37106         void* entropy_source_ptr = untag_ptr(entropy_source);
37107         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
37108         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
37109         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
37110         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
37111         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
37112         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
37113         LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ), "LDKCResult_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ");
37114         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, entropy_source_conv, current_time, min_final_cltv_expiry_delta_conv);
37115         return tag_ptr(ret_conv, true);
37116 }
37117
37118 int64_t  CS_LDK_create_from_hash(int64_t keys, int64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time, int64_t min_final_cltv_expiry_delta) {
37119         LDKExpandedKey keys_conv;
37120         keys_conv.inner = untag_ptr(keys);
37121         keys_conv.is_owned = ptr_is_owned(keys);
37122         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
37123         keys_conv.is_owned = false;
37124         void* min_value_msat_ptr = untag_ptr(min_value_msat);
37125         CHECK_ACCESS(min_value_msat_ptr);
37126         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
37127         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
37128         LDKThirtyTwoBytes payment_hash_ref;
37129         CHECK(payment_hash->arr_len == 32);
37130         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
37131         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
37132         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
37133         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
37134         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
37135         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
37136         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time, min_final_cltv_expiry_delta_conv);
37137         return tag_ptr(ret_conv, true);
37138 }
37139
37140 void  CS_LDK_DecodeError_free(int64_t this_ptr) {
37141         if (!ptr_is_owned(this_ptr)) return;
37142         void* this_ptr_ptr = untag_ptr(this_ptr);
37143         CHECK_ACCESS(this_ptr_ptr);
37144         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
37145         FREE(untag_ptr(this_ptr));
37146         DecodeError_free(this_ptr_conv);
37147 }
37148
37149 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
37150         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37151         *ret_copy = DecodeError_clone(arg);
37152         int64_t ret_ref = tag_ptr(ret_copy, true);
37153         return ret_ref;
37154 }
37155 int64_t  CS_LDK_DecodeError_clone_ptr(int64_t arg) {
37156         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
37157         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
37158         return ret_conv;
37159 }
37160
37161 int64_t  CS_LDK_DecodeError_clone(int64_t orig) {
37162         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
37163         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37164         *ret_copy = DecodeError_clone(orig_conv);
37165         int64_t ret_ref = tag_ptr(ret_copy, true);
37166         return ret_ref;
37167 }
37168
37169 int64_t  CS_LDK_DecodeError_unknown_version() {
37170         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37171         *ret_copy = DecodeError_unknown_version();
37172         int64_t ret_ref = tag_ptr(ret_copy, true);
37173         return ret_ref;
37174 }
37175
37176 int64_t  CS_LDK_DecodeError_unknown_required_feature() {
37177         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37178         *ret_copy = DecodeError_unknown_required_feature();
37179         int64_t ret_ref = tag_ptr(ret_copy, true);
37180         return ret_ref;
37181 }
37182
37183 int64_t  CS_LDK_DecodeError_invalid_value() {
37184         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37185         *ret_copy = DecodeError_invalid_value();
37186         int64_t ret_ref = tag_ptr(ret_copy, true);
37187         return ret_ref;
37188 }
37189
37190 int64_t  CS_LDK_DecodeError_short_read() {
37191         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37192         *ret_copy = DecodeError_short_read();
37193         int64_t ret_ref = tag_ptr(ret_copy, true);
37194         return ret_ref;
37195 }
37196
37197 int64_t  CS_LDK_DecodeError_bad_length_descriptor() {
37198         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37199         *ret_copy = DecodeError_bad_length_descriptor();
37200         int64_t ret_ref = tag_ptr(ret_copy, true);
37201         return ret_ref;
37202 }
37203
37204 int64_t  CS_LDK_DecodeError_io(int32_t a) {
37205         LDKIOError a_conv = LDKIOError_from_cs(a);
37206         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37207         *ret_copy = DecodeError_io(a_conv);
37208         int64_t ret_ref = tag_ptr(ret_copy, true);
37209         return ret_ref;
37210 }
37211
37212 int64_t  CS_LDK_DecodeError_unsupported_compression() {
37213         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
37214         *ret_copy = DecodeError_unsupported_compression();
37215         int64_t ret_ref = tag_ptr(ret_copy, true);
37216         return ret_ref;
37217 }
37218
37219 jboolean  CS_LDK_DecodeError_eq(int64_t a, int64_t b) {
37220         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
37221         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
37222         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
37223         return ret_conv;
37224 }
37225
37226 void  CS_LDK_Init_free(int64_t this_obj) {
37227         LDKInit this_obj_conv;
37228         this_obj_conv.inner = untag_ptr(this_obj);
37229         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37231         Init_free(this_obj_conv);
37232 }
37233
37234 int64_t  CS_LDK_Init_get_features(int64_t this_ptr) {
37235         LDKInit this_ptr_conv;
37236         this_ptr_conv.inner = untag_ptr(this_ptr);
37237         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37239         this_ptr_conv.is_owned = false;
37240         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
37241         int64_t ret_ref = 0;
37242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37243         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37244         return ret_ref;
37245 }
37246
37247 void  CS_LDK_Init_set_features(int64_t this_ptr, int64_t val) {
37248         LDKInit this_ptr_conv;
37249         this_ptr_conv.inner = untag_ptr(this_ptr);
37250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37252         this_ptr_conv.is_owned = false;
37253         LDKInitFeatures val_conv;
37254         val_conv.inner = untag_ptr(val);
37255         val_conv.is_owned = ptr_is_owned(val);
37256         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37257         val_conv = InitFeatures_clone(&val_conv);
37258         Init_set_features(&this_ptr_conv, val_conv);
37259 }
37260
37261 int64_t  CS_LDK_Init_get_networks(int64_t this_ptr) {
37262         LDKInit this_ptr_conv;
37263         this_ptr_conv.inner = untag_ptr(this_ptr);
37264         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37266         this_ptr_conv.is_owned = false;
37267         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
37268         *ret_copy = Init_get_networks(&this_ptr_conv);
37269         int64_t ret_ref = tag_ptr(ret_copy, true);
37270         return ret_ref;
37271 }
37272
37273 void  CS_LDK_Init_set_networks(int64_t this_ptr, int64_t val) {
37274         LDKInit this_ptr_conv;
37275         this_ptr_conv.inner = untag_ptr(this_ptr);
37276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37278         this_ptr_conv.is_owned = false;
37279         void* val_ptr = untag_ptr(val);
37280         CHECK_ACCESS(val_ptr);
37281         LDKCOption_CVec_ThirtyTwoBytesZZ val_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(val_ptr);
37282         val_conv = COption_CVec_ThirtyTwoBytesZZ_clone((LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(val));
37283         Init_set_networks(&this_ptr_conv, val_conv);
37284 }
37285
37286 int64_t  CS_LDK_Init_get_remote_network_address(int64_t this_ptr) {
37287         LDKInit this_ptr_conv;
37288         this_ptr_conv.inner = untag_ptr(this_ptr);
37289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37291         this_ptr_conv.is_owned = false;
37292         LDKCOption_SocketAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_SocketAddressZ), "LDKCOption_SocketAddressZ");
37293         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
37294         int64_t ret_ref = tag_ptr(ret_copy, true);
37295         return ret_ref;
37296 }
37297
37298 void  CS_LDK_Init_set_remote_network_address(int64_t this_ptr, int64_t val) {
37299         LDKInit this_ptr_conv;
37300         this_ptr_conv.inner = untag_ptr(this_ptr);
37301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37303         this_ptr_conv.is_owned = false;
37304         void* val_ptr = untag_ptr(val);
37305         CHECK_ACCESS(val_ptr);
37306         LDKCOption_SocketAddressZ val_conv = *(LDKCOption_SocketAddressZ*)(val_ptr);
37307         val_conv = COption_SocketAddressZ_clone((LDKCOption_SocketAddressZ*)untag_ptr(val));
37308         Init_set_remote_network_address(&this_ptr_conv, val_conv);
37309 }
37310
37311 int64_t  CS_LDK_Init_new(int64_t features_arg, int64_t networks_arg, int64_t remote_network_address_arg) {
37312         LDKInitFeatures features_arg_conv;
37313         features_arg_conv.inner = untag_ptr(features_arg);
37314         features_arg_conv.is_owned = ptr_is_owned(features_arg);
37315         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37316         features_arg_conv = InitFeatures_clone(&features_arg_conv);
37317         void* networks_arg_ptr = untag_ptr(networks_arg);
37318         CHECK_ACCESS(networks_arg_ptr);
37319         LDKCOption_CVec_ThirtyTwoBytesZZ networks_arg_conv = *(LDKCOption_CVec_ThirtyTwoBytesZZ*)(networks_arg_ptr);
37320         networks_arg_conv = COption_CVec_ThirtyTwoBytesZZ_clone((LDKCOption_CVec_ThirtyTwoBytesZZ*)untag_ptr(networks_arg));
37321         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
37322         CHECK_ACCESS(remote_network_address_arg_ptr);
37323         LDKCOption_SocketAddressZ remote_network_address_arg_conv = *(LDKCOption_SocketAddressZ*)(remote_network_address_arg_ptr);
37324         LDKInit ret_var = Init_new(features_arg_conv, networks_arg_conv, remote_network_address_arg_conv);
37325         int64_t ret_ref = 0;
37326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37327         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37328         return ret_ref;
37329 }
37330
37331 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
37332         LDKInit ret_var = Init_clone(arg);
37333         int64_t ret_ref = 0;
37334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37336         return ret_ref;
37337 }
37338 int64_t  CS_LDK_Init_clone_ptr(int64_t arg) {
37339         LDKInit arg_conv;
37340         arg_conv.inner = untag_ptr(arg);
37341         arg_conv.is_owned = ptr_is_owned(arg);
37342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37343         arg_conv.is_owned = false;
37344         int64_t ret_conv = Init_clone_ptr(&arg_conv);
37345         return ret_conv;
37346 }
37347
37348 int64_t  CS_LDK_Init_clone(int64_t orig) {
37349         LDKInit orig_conv;
37350         orig_conv.inner = untag_ptr(orig);
37351         orig_conv.is_owned = ptr_is_owned(orig);
37352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37353         orig_conv.is_owned = false;
37354         LDKInit ret_var = Init_clone(&orig_conv);
37355         int64_t ret_ref = 0;
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37358         return ret_ref;
37359 }
37360
37361 jboolean  CS_LDK_Init_eq(int64_t a, int64_t b) {
37362         LDKInit a_conv;
37363         a_conv.inner = untag_ptr(a);
37364         a_conv.is_owned = ptr_is_owned(a);
37365         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37366         a_conv.is_owned = false;
37367         LDKInit b_conv;
37368         b_conv.inner = untag_ptr(b);
37369         b_conv.is_owned = ptr_is_owned(b);
37370         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37371         b_conv.is_owned = false;
37372         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
37373         return ret_conv;
37374 }
37375
37376 void  CS_LDK_ErrorMessage_free(int64_t this_obj) {
37377         LDKErrorMessage this_obj_conv;
37378         this_obj_conv.inner = untag_ptr(this_obj);
37379         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37381         ErrorMessage_free(this_obj_conv);
37382 }
37383
37384 int8_tArray  CS_LDK_ErrorMessage_get_channel_id(int64_t this_ptr) {
37385         LDKErrorMessage this_ptr_conv;
37386         this_ptr_conv.inner = untag_ptr(this_ptr);
37387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37389         this_ptr_conv.is_owned = false;
37390         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37391         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
37392         return ret_arr;
37393 }
37394
37395 void  CS_LDK_ErrorMessage_set_channel_id(int64_t this_ptr, int8_tArray val) {
37396         LDKErrorMessage this_ptr_conv;
37397         this_ptr_conv.inner = untag_ptr(this_ptr);
37398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37400         this_ptr_conv.is_owned = false;
37401         LDKThirtyTwoBytes val_ref;
37402         CHECK(val->arr_len == 32);
37403         memcpy(val_ref.data, val->elems, 32); FREE(val);
37404         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
37405 }
37406
37407 jstring  CS_LDK_ErrorMessage_get_data(int64_t this_ptr) {
37408         LDKErrorMessage this_ptr_conv;
37409         this_ptr_conv.inner = untag_ptr(this_ptr);
37410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37412         this_ptr_conv.is_owned = false;
37413         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
37414         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
37415         Str_free(ret_str);
37416         return ret_conv;
37417 }
37418
37419 void  CS_LDK_ErrorMessage_set_data(int64_t this_ptr, jstring val) {
37420         LDKErrorMessage this_ptr_conv;
37421         this_ptr_conv.inner = untag_ptr(this_ptr);
37422         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37424         this_ptr_conv.is_owned = false;
37425         LDKStr val_conv = str_ref_to_owned_c(val);
37426         ErrorMessage_set_data(&this_ptr_conv, val_conv);
37427 }
37428
37429 int64_t  CS_LDK_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
37430         LDKThirtyTwoBytes channel_id_arg_ref;
37431         CHECK(channel_id_arg->arr_len == 32);
37432         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
37433         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
37434         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
37435         int64_t ret_ref = 0;
37436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37437         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37438         return ret_ref;
37439 }
37440
37441 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
37442         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
37443         int64_t ret_ref = 0;
37444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37446         return ret_ref;
37447 }
37448 int64_t  CS_LDK_ErrorMessage_clone_ptr(int64_t arg) {
37449         LDKErrorMessage arg_conv;
37450         arg_conv.inner = untag_ptr(arg);
37451         arg_conv.is_owned = ptr_is_owned(arg);
37452         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37453         arg_conv.is_owned = false;
37454         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
37455         return ret_conv;
37456 }
37457
37458 int64_t  CS_LDK_ErrorMessage_clone(int64_t orig) {
37459         LDKErrorMessage orig_conv;
37460         orig_conv.inner = untag_ptr(orig);
37461         orig_conv.is_owned = ptr_is_owned(orig);
37462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37463         orig_conv.is_owned = false;
37464         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
37465         int64_t ret_ref = 0;
37466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37467         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37468         return ret_ref;
37469 }
37470
37471 jboolean  CS_LDK_ErrorMessage_eq(int64_t a, int64_t b) {
37472         LDKErrorMessage a_conv;
37473         a_conv.inner = untag_ptr(a);
37474         a_conv.is_owned = ptr_is_owned(a);
37475         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37476         a_conv.is_owned = false;
37477         LDKErrorMessage b_conv;
37478         b_conv.inner = untag_ptr(b);
37479         b_conv.is_owned = ptr_is_owned(b);
37480         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37481         b_conv.is_owned = false;
37482         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
37483         return ret_conv;
37484 }
37485
37486 void  CS_LDK_WarningMessage_free(int64_t this_obj) {
37487         LDKWarningMessage this_obj_conv;
37488         this_obj_conv.inner = untag_ptr(this_obj);
37489         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37491         WarningMessage_free(this_obj_conv);
37492 }
37493
37494 int8_tArray  CS_LDK_WarningMessage_get_channel_id(int64_t this_ptr) {
37495         LDKWarningMessage this_ptr_conv;
37496         this_ptr_conv.inner = untag_ptr(this_ptr);
37497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37499         this_ptr_conv.is_owned = false;
37500         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37501         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
37502         return ret_arr;
37503 }
37504
37505 void  CS_LDK_WarningMessage_set_channel_id(int64_t this_ptr, int8_tArray val) {
37506         LDKWarningMessage this_ptr_conv;
37507         this_ptr_conv.inner = untag_ptr(this_ptr);
37508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37510         this_ptr_conv.is_owned = false;
37511         LDKThirtyTwoBytes val_ref;
37512         CHECK(val->arr_len == 32);
37513         memcpy(val_ref.data, val->elems, 32); FREE(val);
37514         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
37515 }
37516
37517 jstring  CS_LDK_WarningMessage_get_data(int64_t this_ptr) {
37518         LDKWarningMessage this_ptr_conv;
37519         this_ptr_conv.inner = untag_ptr(this_ptr);
37520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37522         this_ptr_conv.is_owned = false;
37523         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
37524         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
37525         Str_free(ret_str);
37526         return ret_conv;
37527 }
37528
37529 void  CS_LDK_WarningMessage_set_data(int64_t this_ptr, jstring val) {
37530         LDKWarningMessage this_ptr_conv;
37531         this_ptr_conv.inner = untag_ptr(this_ptr);
37532         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37534         this_ptr_conv.is_owned = false;
37535         LDKStr val_conv = str_ref_to_owned_c(val);
37536         WarningMessage_set_data(&this_ptr_conv, val_conv);
37537 }
37538
37539 int64_t  CS_LDK_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
37540         LDKThirtyTwoBytes channel_id_arg_ref;
37541         CHECK(channel_id_arg->arr_len == 32);
37542         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
37543         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
37544         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
37545         int64_t ret_ref = 0;
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37548         return ret_ref;
37549 }
37550
37551 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
37552         LDKWarningMessage ret_var = WarningMessage_clone(arg);
37553         int64_t ret_ref = 0;
37554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37556         return ret_ref;
37557 }
37558 int64_t  CS_LDK_WarningMessage_clone_ptr(int64_t arg) {
37559         LDKWarningMessage arg_conv;
37560         arg_conv.inner = untag_ptr(arg);
37561         arg_conv.is_owned = ptr_is_owned(arg);
37562         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37563         arg_conv.is_owned = false;
37564         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
37565         return ret_conv;
37566 }
37567
37568 int64_t  CS_LDK_WarningMessage_clone(int64_t orig) {
37569         LDKWarningMessage orig_conv;
37570         orig_conv.inner = untag_ptr(orig);
37571         orig_conv.is_owned = ptr_is_owned(orig);
37572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37573         orig_conv.is_owned = false;
37574         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
37575         int64_t ret_ref = 0;
37576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37578         return ret_ref;
37579 }
37580
37581 jboolean  CS_LDK_WarningMessage_eq(int64_t a, int64_t b) {
37582         LDKWarningMessage a_conv;
37583         a_conv.inner = untag_ptr(a);
37584         a_conv.is_owned = ptr_is_owned(a);
37585         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37586         a_conv.is_owned = false;
37587         LDKWarningMessage b_conv;
37588         b_conv.inner = untag_ptr(b);
37589         b_conv.is_owned = ptr_is_owned(b);
37590         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37591         b_conv.is_owned = false;
37592         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
37593         return ret_conv;
37594 }
37595
37596 void  CS_LDK_Ping_free(int64_t this_obj) {
37597         LDKPing this_obj_conv;
37598         this_obj_conv.inner = untag_ptr(this_obj);
37599         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37601         Ping_free(this_obj_conv);
37602 }
37603
37604 int16_t  CS_LDK_Ping_get_ponglen(int64_t this_ptr) {
37605         LDKPing this_ptr_conv;
37606         this_ptr_conv.inner = untag_ptr(this_ptr);
37607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37609         this_ptr_conv.is_owned = false;
37610         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
37611         return ret_conv;
37612 }
37613
37614 void  CS_LDK_Ping_set_ponglen(int64_t this_ptr, int16_t val) {
37615         LDKPing this_ptr_conv;
37616         this_ptr_conv.inner = untag_ptr(this_ptr);
37617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37619         this_ptr_conv.is_owned = false;
37620         Ping_set_ponglen(&this_ptr_conv, val);
37621 }
37622
37623 int16_t  CS_LDK_Ping_get_byteslen(int64_t this_ptr) {
37624         LDKPing this_ptr_conv;
37625         this_ptr_conv.inner = untag_ptr(this_ptr);
37626         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37628         this_ptr_conv.is_owned = false;
37629         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
37630         return ret_conv;
37631 }
37632
37633 void  CS_LDK_Ping_set_byteslen(int64_t this_ptr, int16_t val) {
37634         LDKPing this_ptr_conv;
37635         this_ptr_conv.inner = untag_ptr(this_ptr);
37636         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37638         this_ptr_conv.is_owned = false;
37639         Ping_set_byteslen(&this_ptr_conv, val);
37640 }
37641
37642 int64_t  CS_LDK_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
37643         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
37644         int64_t ret_ref = 0;
37645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37647         return ret_ref;
37648 }
37649
37650 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
37651         LDKPing ret_var = Ping_clone(arg);
37652         int64_t ret_ref = 0;
37653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37655         return ret_ref;
37656 }
37657 int64_t  CS_LDK_Ping_clone_ptr(int64_t arg) {
37658         LDKPing arg_conv;
37659         arg_conv.inner = untag_ptr(arg);
37660         arg_conv.is_owned = ptr_is_owned(arg);
37661         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37662         arg_conv.is_owned = false;
37663         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
37664         return ret_conv;
37665 }
37666
37667 int64_t  CS_LDK_Ping_clone(int64_t orig) {
37668         LDKPing orig_conv;
37669         orig_conv.inner = untag_ptr(orig);
37670         orig_conv.is_owned = ptr_is_owned(orig);
37671         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37672         orig_conv.is_owned = false;
37673         LDKPing ret_var = Ping_clone(&orig_conv);
37674         int64_t ret_ref = 0;
37675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37676         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37677         return ret_ref;
37678 }
37679
37680 jboolean  CS_LDK_Ping_eq(int64_t a, int64_t b) {
37681         LDKPing a_conv;
37682         a_conv.inner = untag_ptr(a);
37683         a_conv.is_owned = ptr_is_owned(a);
37684         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37685         a_conv.is_owned = false;
37686         LDKPing b_conv;
37687         b_conv.inner = untag_ptr(b);
37688         b_conv.is_owned = ptr_is_owned(b);
37689         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37690         b_conv.is_owned = false;
37691         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
37692         return ret_conv;
37693 }
37694
37695 void  CS_LDK_Pong_free(int64_t this_obj) {
37696         LDKPong this_obj_conv;
37697         this_obj_conv.inner = untag_ptr(this_obj);
37698         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37700         Pong_free(this_obj_conv);
37701 }
37702
37703 int16_t  CS_LDK_Pong_get_byteslen(int64_t this_ptr) {
37704         LDKPong this_ptr_conv;
37705         this_ptr_conv.inner = untag_ptr(this_ptr);
37706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37708         this_ptr_conv.is_owned = false;
37709         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
37710         return ret_conv;
37711 }
37712
37713 void  CS_LDK_Pong_set_byteslen(int64_t this_ptr, int16_t val) {
37714         LDKPong this_ptr_conv;
37715         this_ptr_conv.inner = untag_ptr(this_ptr);
37716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37718         this_ptr_conv.is_owned = false;
37719         Pong_set_byteslen(&this_ptr_conv, val);
37720 }
37721
37722 int64_t  CS_LDK_Pong_new(int16_t byteslen_arg) {
37723         LDKPong ret_var = Pong_new(byteslen_arg);
37724         int64_t ret_ref = 0;
37725         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37726         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37727         return ret_ref;
37728 }
37729
37730 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
37731         LDKPong ret_var = Pong_clone(arg);
37732         int64_t ret_ref = 0;
37733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37735         return ret_ref;
37736 }
37737 int64_t  CS_LDK_Pong_clone_ptr(int64_t arg) {
37738         LDKPong arg_conv;
37739         arg_conv.inner = untag_ptr(arg);
37740         arg_conv.is_owned = ptr_is_owned(arg);
37741         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37742         arg_conv.is_owned = false;
37743         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
37744         return ret_conv;
37745 }
37746
37747 int64_t  CS_LDK_Pong_clone(int64_t orig) {
37748         LDKPong orig_conv;
37749         orig_conv.inner = untag_ptr(orig);
37750         orig_conv.is_owned = ptr_is_owned(orig);
37751         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37752         orig_conv.is_owned = false;
37753         LDKPong ret_var = Pong_clone(&orig_conv);
37754         int64_t ret_ref = 0;
37755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37757         return ret_ref;
37758 }
37759
37760 jboolean  CS_LDK_Pong_eq(int64_t a, int64_t b) {
37761         LDKPong a_conv;
37762         a_conv.inner = untag_ptr(a);
37763         a_conv.is_owned = ptr_is_owned(a);
37764         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37765         a_conv.is_owned = false;
37766         LDKPong b_conv;
37767         b_conv.inner = untag_ptr(b);
37768         b_conv.is_owned = ptr_is_owned(b);
37769         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37770         b_conv.is_owned = false;
37771         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
37772         return ret_conv;
37773 }
37774
37775 void  CS_LDK_OpenChannel_free(int64_t this_obj) {
37776         LDKOpenChannel this_obj_conv;
37777         this_obj_conv.inner = untag_ptr(this_obj);
37778         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37780         OpenChannel_free(this_obj_conv);
37781 }
37782
37783 int8_tArray  CS_LDK_OpenChannel_get_chain_hash(int64_t this_ptr) {
37784         LDKOpenChannel this_ptr_conv;
37785         this_ptr_conv.inner = untag_ptr(this_ptr);
37786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37788         this_ptr_conv.is_owned = false;
37789         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37790         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
37791         return ret_arr;
37792 }
37793
37794 void  CS_LDK_OpenChannel_set_chain_hash(int64_t this_ptr, int8_tArray val) {
37795         LDKOpenChannel this_ptr_conv;
37796         this_ptr_conv.inner = untag_ptr(this_ptr);
37797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37799         this_ptr_conv.is_owned = false;
37800         LDKThirtyTwoBytes val_ref;
37801         CHECK(val->arr_len == 32);
37802         memcpy(val_ref.data, val->elems, 32); FREE(val);
37803         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
37804 }
37805
37806 int8_tArray  CS_LDK_OpenChannel_get_temporary_channel_id(int64_t this_ptr) {
37807         LDKOpenChannel this_ptr_conv;
37808         this_ptr_conv.inner = untag_ptr(this_ptr);
37809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37811         this_ptr_conv.is_owned = false;
37812         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37813         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
37814         return ret_arr;
37815 }
37816
37817 void  CS_LDK_OpenChannel_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
37818         LDKOpenChannel this_ptr_conv;
37819         this_ptr_conv.inner = untag_ptr(this_ptr);
37820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37822         this_ptr_conv.is_owned = false;
37823         LDKThirtyTwoBytes val_ref;
37824         CHECK(val->arr_len == 32);
37825         memcpy(val_ref.data, val->elems, 32); FREE(val);
37826         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
37827 }
37828
37829 int64_t  CS_LDK_OpenChannel_get_funding_satoshis(int64_t this_ptr) {
37830         LDKOpenChannel this_ptr_conv;
37831         this_ptr_conv.inner = untag_ptr(this_ptr);
37832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37834         this_ptr_conv.is_owned = false;
37835         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
37836         return ret_conv;
37837 }
37838
37839 void  CS_LDK_OpenChannel_set_funding_satoshis(int64_t this_ptr, int64_t val) {
37840         LDKOpenChannel this_ptr_conv;
37841         this_ptr_conv.inner = untag_ptr(this_ptr);
37842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37844         this_ptr_conv.is_owned = false;
37845         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
37846 }
37847
37848 int64_t  CS_LDK_OpenChannel_get_push_msat(int64_t this_ptr) {
37849         LDKOpenChannel this_ptr_conv;
37850         this_ptr_conv.inner = untag_ptr(this_ptr);
37851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37853         this_ptr_conv.is_owned = false;
37854         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
37855         return ret_conv;
37856 }
37857
37858 void  CS_LDK_OpenChannel_set_push_msat(int64_t this_ptr, int64_t val) {
37859         LDKOpenChannel this_ptr_conv;
37860         this_ptr_conv.inner = untag_ptr(this_ptr);
37861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37863         this_ptr_conv.is_owned = false;
37864         OpenChannel_set_push_msat(&this_ptr_conv, val);
37865 }
37866
37867 int64_t  CS_LDK_OpenChannel_get_dust_limit_satoshis(int64_t this_ptr) {
37868         LDKOpenChannel this_ptr_conv;
37869         this_ptr_conv.inner = untag_ptr(this_ptr);
37870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37872         this_ptr_conv.is_owned = false;
37873         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
37874         return ret_conv;
37875 }
37876
37877 void  CS_LDK_OpenChannel_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
37878         LDKOpenChannel this_ptr_conv;
37879         this_ptr_conv.inner = untag_ptr(this_ptr);
37880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37882         this_ptr_conv.is_owned = false;
37883         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
37884 }
37885
37886 int64_t  CS_LDK_OpenChannel_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
37887         LDKOpenChannel this_ptr_conv;
37888         this_ptr_conv.inner = untag_ptr(this_ptr);
37889         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37891         this_ptr_conv.is_owned = false;
37892         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
37893         return ret_conv;
37894 }
37895
37896 void  CS_LDK_OpenChannel_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
37897         LDKOpenChannel this_ptr_conv;
37898         this_ptr_conv.inner = untag_ptr(this_ptr);
37899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37901         this_ptr_conv.is_owned = false;
37902         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
37903 }
37904
37905 int64_t  CS_LDK_OpenChannel_get_channel_reserve_satoshis(int64_t this_ptr) {
37906         LDKOpenChannel this_ptr_conv;
37907         this_ptr_conv.inner = untag_ptr(this_ptr);
37908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37910         this_ptr_conv.is_owned = false;
37911         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
37912         return ret_conv;
37913 }
37914
37915 void  CS_LDK_OpenChannel_set_channel_reserve_satoshis(int64_t this_ptr, int64_t val) {
37916         LDKOpenChannel this_ptr_conv;
37917         this_ptr_conv.inner = untag_ptr(this_ptr);
37918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37920         this_ptr_conv.is_owned = false;
37921         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
37922 }
37923
37924 int64_t  CS_LDK_OpenChannel_get_htlc_minimum_msat(int64_t this_ptr) {
37925         LDKOpenChannel this_ptr_conv;
37926         this_ptr_conv.inner = untag_ptr(this_ptr);
37927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37929         this_ptr_conv.is_owned = false;
37930         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
37931         return ret_conv;
37932 }
37933
37934 void  CS_LDK_OpenChannel_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
37935         LDKOpenChannel this_ptr_conv;
37936         this_ptr_conv.inner = untag_ptr(this_ptr);
37937         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37939         this_ptr_conv.is_owned = false;
37940         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
37941 }
37942
37943 int32_t  CS_LDK_OpenChannel_get_feerate_per_kw(int64_t this_ptr) {
37944         LDKOpenChannel this_ptr_conv;
37945         this_ptr_conv.inner = untag_ptr(this_ptr);
37946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37948         this_ptr_conv.is_owned = false;
37949         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
37950         return ret_conv;
37951 }
37952
37953 void  CS_LDK_OpenChannel_set_feerate_per_kw(int64_t this_ptr, int32_t val) {
37954         LDKOpenChannel this_ptr_conv;
37955         this_ptr_conv.inner = untag_ptr(this_ptr);
37956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37958         this_ptr_conv.is_owned = false;
37959         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
37960 }
37961
37962 int16_t  CS_LDK_OpenChannel_get_to_self_delay(int64_t this_ptr) {
37963         LDKOpenChannel this_ptr_conv;
37964         this_ptr_conv.inner = untag_ptr(this_ptr);
37965         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37967         this_ptr_conv.is_owned = false;
37968         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
37969         return ret_conv;
37970 }
37971
37972 void  CS_LDK_OpenChannel_set_to_self_delay(int64_t this_ptr, int16_t val) {
37973         LDKOpenChannel this_ptr_conv;
37974         this_ptr_conv.inner = untag_ptr(this_ptr);
37975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37977         this_ptr_conv.is_owned = false;
37978         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
37979 }
37980
37981 int16_t  CS_LDK_OpenChannel_get_max_accepted_htlcs(int64_t this_ptr) {
37982         LDKOpenChannel this_ptr_conv;
37983         this_ptr_conv.inner = untag_ptr(this_ptr);
37984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37986         this_ptr_conv.is_owned = false;
37987         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
37988         return ret_conv;
37989 }
37990
37991 void  CS_LDK_OpenChannel_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
37992         LDKOpenChannel this_ptr_conv;
37993         this_ptr_conv.inner = untag_ptr(this_ptr);
37994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37996         this_ptr_conv.is_owned = false;
37997         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
37998 }
37999
38000 int8_tArray  CS_LDK_OpenChannel_get_funding_pubkey(int64_t this_ptr) {
38001         LDKOpenChannel this_ptr_conv;
38002         this_ptr_conv.inner = untag_ptr(this_ptr);
38003         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38005         this_ptr_conv.is_owned = false;
38006         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38007         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
38008         return ret_arr;
38009 }
38010
38011 void  CS_LDK_OpenChannel_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
38012         LDKOpenChannel this_ptr_conv;
38013         this_ptr_conv.inner = untag_ptr(this_ptr);
38014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38016         this_ptr_conv.is_owned = false;
38017         LDKPublicKey val_ref;
38018         CHECK(val->arr_len == 33);
38019         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38020         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
38021 }
38022
38023 int8_tArray  CS_LDK_OpenChannel_get_revocation_basepoint(int64_t this_ptr) {
38024         LDKOpenChannel this_ptr_conv;
38025         this_ptr_conv.inner = untag_ptr(this_ptr);
38026         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38028         this_ptr_conv.is_owned = false;
38029         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38030         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
38031         return ret_arr;
38032 }
38033
38034 void  CS_LDK_OpenChannel_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
38035         LDKOpenChannel this_ptr_conv;
38036         this_ptr_conv.inner = untag_ptr(this_ptr);
38037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38039         this_ptr_conv.is_owned = false;
38040         LDKPublicKey val_ref;
38041         CHECK(val->arr_len == 33);
38042         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38043         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
38044 }
38045
38046 int8_tArray  CS_LDK_OpenChannel_get_payment_point(int64_t this_ptr) {
38047         LDKOpenChannel this_ptr_conv;
38048         this_ptr_conv.inner = untag_ptr(this_ptr);
38049         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38051         this_ptr_conv.is_owned = false;
38052         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38053         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
38054         return ret_arr;
38055 }
38056
38057 void  CS_LDK_OpenChannel_set_payment_point(int64_t this_ptr, int8_tArray val) {
38058         LDKOpenChannel this_ptr_conv;
38059         this_ptr_conv.inner = untag_ptr(this_ptr);
38060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38062         this_ptr_conv.is_owned = false;
38063         LDKPublicKey val_ref;
38064         CHECK(val->arr_len == 33);
38065         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38066         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
38067 }
38068
38069 int8_tArray  CS_LDK_OpenChannel_get_delayed_payment_basepoint(int64_t this_ptr) {
38070         LDKOpenChannel this_ptr_conv;
38071         this_ptr_conv.inner = untag_ptr(this_ptr);
38072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38074         this_ptr_conv.is_owned = false;
38075         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38076         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
38077         return ret_arr;
38078 }
38079
38080 void  CS_LDK_OpenChannel_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
38081         LDKOpenChannel this_ptr_conv;
38082         this_ptr_conv.inner = untag_ptr(this_ptr);
38083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38085         this_ptr_conv.is_owned = false;
38086         LDKPublicKey val_ref;
38087         CHECK(val->arr_len == 33);
38088         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38089         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
38090 }
38091
38092 int8_tArray  CS_LDK_OpenChannel_get_htlc_basepoint(int64_t this_ptr) {
38093         LDKOpenChannel this_ptr_conv;
38094         this_ptr_conv.inner = untag_ptr(this_ptr);
38095         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38097         this_ptr_conv.is_owned = false;
38098         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38099         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
38100         return ret_arr;
38101 }
38102
38103 void  CS_LDK_OpenChannel_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
38104         LDKOpenChannel this_ptr_conv;
38105         this_ptr_conv.inner = untag_ptr(this_ptr);
38106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38108         this_ptr_conv.is_owned = false;
38109         LDKPublicKey val_ref;
38110         CHECK(val->arr_len == 33);
38111         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38112         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
38113 }
38114
38115 int8_tArray  CS_LDK_OpenChannel_get_first_per_commitment_point(int64_t this_ptr) {
38116         LDKOpenChannel this_ptr_conv;
38117         this_ptr_conv.inner = untag_ptr(this_ptr);
38118         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38120         this_ptr_conv.is_owned = false;
38121         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38122         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
38123         return ret_arr;
38124 }
38125
38126 void  CS_LDK_OpenChannel_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
38127         LDKOpenChannel this_ptr_conv;
38128         this_ptr_conv.inner = untag_ptr(this_ptr);
38129         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38131         this_ptr_conv.is_owned = false;
38132         LDKPublicKey val_ref;
38133         CHECK(val->arr_len == 33);
38134         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38135         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
38136 }
38137
38138 int8_t  CS_LDK_OpenChannel_get_channel_flags(int64_t this_ptr) {
38139         LDKOpenChannel this_ptr_conv;
38140         this_ptr_conv.inner = untag_ptr(this_ptr);
38141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38143         this_ptr_conv.is_owned = false;
38144         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
38145         return ret_conv;
38146 }
38147
38148 void  CS_LDK_OpenChannel_set_channel_flags(int64_t this_ptr, int8_t val) {
38149         LDKOpenChannel this_ptr_conv;
38150         this_ptr_conv.inner = untag_ptr(this_ptr);
38151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38153         this_ptr_conv.is_owned = false;
38154         OpenChannel_set_channel_flags(&this_ptr_conv, val);
38155 }
38156
38157 int64_t  CS_LDK_OpenChannel_get_shutdown_scriptpubkey(int64_t this_ptr) {
38158         LDKOpenChannel this_ptr_conv;
38159         this_ptr_conv.inner = untag_ptr(this_ptr);
38160         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38162         this_ptr_conv.is_owned = false;
38163         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
38164         *ret_copy = OpenChannel_get_shutdown_scriptpubkey(&this_ptr_conv);
38165         int64_t ret_ref = tag_ptr(ret_copy, true);
38166         return ret_ref;
38167 }
38168
38169 void  CS_LDK_OpenChannel_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
38170         LDKOpenChannel this_ptr_conv;
38171         this_ptr_conv.inner = untag_ptr(this_ptr);
38172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38174         this_ptr_conv.is_owned = false;
38175         void* val_ptr = untag_ptr(val);
38176         CHECK_ACCESS(val_ptr);
38177         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
38178         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
38179         OpenChannel_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
38180 }
38181
38182 int64_t  CS_LDK_OpenChannel_get_channel_type(int64_t this_ptr) {
38183         LDKOpenChannel this_ptr_conv;
38184         this_ptr_conv.inner = untag_ptr(this_ptr);
38185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38187         this_ptr_conv.is_owned = false;
38188         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
38189         int64_t ret_ref = 0;
38190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38192         return ret_ref;
38193 }
38194
38195 void  CS_LDK_OpenChannel_set_channel_type(int64_t this_ptr, int64_t val) {
38196         LDKOpenChannel this_ptr_conv;
38197         this_ptr_conv.inner = untag_ptr(this_ptr);
38198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38200         this_ptr_conv.is_owned = false;
38201         LDKChannelTypeFeatures val_conv;
38202         val_conv.inner = untag_ptr(val);
38203         val_conv.is_owned = ptr_is_owned(val);
38204         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38205         val_conv = ChannelTypeFeatures_clone(&val_conv);
38206         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
38207 }
38208
38209 int64_t  CS_LDK_OpenChannel_new(int8_tArray chain_hash_arg, int8_tArray temporary_channel_id_arg, int64_t funding_satoshis_arg, int64_t push_msat_arg, int64_t dust_limit_satoshis_arg, int64_t max_htlc_value_in_flight_msat_arg, int64_t channel_reserve_satoshis_arg, int64_t htlc_minimum_msat_arg, int32_t feerate_per_kw_arg, int16_t to_self_delay_arg, int16_t max_accepted_htlcs_arg, 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, int8_tArray first_per_commitment_point_arg, int8_t channel_flags_arg, int64_t shutdown_scriptpubkey_arg, int64_t channel_type_arg) {
38210         LDKThirtyTwoBytes chain_hash_arg_ref;
38211         CHECK(chain_hash_arg->arr_len == 32);
38212         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
38213         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
38214         CHECK(temporary_channel_id_arg->arr_len == 32);
38215         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
38216         LDKPublicKey funding_pubkey_arg_ref;
38217         CHECK(funding_pubkey_arg->arr_len == 33);
38218         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
38219         LDKPublicKey revocation_basepoint_arg_ref;
38220         CHECK(revocation_basepoint_arg->arr_len == 33);
38221         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
38222         LDKPublicKey payment_point_arg_ref;
38223         CHECK(payment_point_arg->arr_len == 33);
38224         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
38225         LDKPublicKey delayed_payment_basepoint_arg_ref;
38226         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
38227         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
38228         LDKPublicKey htlc_basepoint_arg_ref;
38229         CHECK(htlc_basepoint_arg->arr_len == 33);
38230         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
38231         LDKPublicKey first_per_commitment_point_arg_ref;
38232         CHECK(first_per_commitment_point_arg->arr_len == 33);
38233         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
38234         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
38235         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
38236         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
38237         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
38238         LDKChannelTypeFeatures channel_type_arg_conv;
38239         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
38240         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
38241         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
38242         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
38243         LDKOpenChannel ret_var = OpenChannel_new(chain_hash_arg_ref, temporary_channel_id_arg_ref, funding_satoshis_arg, push_msat_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_arg, htlc_minimum_msat_arg, feerate_per_kw_arg, to_self_delay_arg, max_accepted_htlcs_arg, funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref, first_per_commitment_point_arg_ref, channel_flags_arg, shutdown_scriptpubkey_arg_conv, channel_type_arg_conv);
38244         int64_t ret_ref = 0;
38245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38247         return ret_ref;
38248 }
38249
38250 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
38251         LDKOpenChannel ret_var = OpenChannel_clone(arg);
38252         int64_t ret_ref = 0;
38253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38255         return ret_ref;
38256 }
38257 int64_t  CS_LDK_OpenChannel_clone_ptr(int64_t arg) {
38258         LDKOpenChannel arg_conv;
38259         arg_conv.inner = untag_ptr(arg);
38260         arg_conv.is_owned = ptr_is_owned(arg);
38261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38262         arg_conv.is_owned = false;
38263         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
38264         return ret_conv;
38265 }
38266
38267 int64_t  CS_LDK_OpenChannel_clone(int64_t orig) {
38268         LDKOpenChannel orig_conv;
38269         orig_conv.inner = untag_ptr(orig);
38270         orig_conv.is_owned = ptr_is_owned(orig);
38271         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38272         orig_conv.is_owned = false;
38273         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
38274         int64_t ret_ref = 0;
38275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38277         return ret_ref;
38278 }
38279
38280 jboolean  CS_LDK_OpenChannel_eq(int64_t a, int64_t b) {
38281         LDKOpenChannel a_conv;
38282         a_conv.inner = untag_ptr(a);
38283         a_conv.is_owned = ptr_is_owned(a);
38284         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38285         a_conv.is_owned = false;
38286         LDKOpenChannel b_conv;
38287         b_conv.inner = untag_ptr(b);
38288         b_conv.is_owned = ptr_is_owned(b);
38289         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38290         b_conv.is_owned = false;
38291         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
38292         return ret_conv;
38293 }
38294
38295 void  CS_LDK_OpenChannelV2_free(int64_t this_obj) {
38296         LDKOpenChannelV2 this_obj_conv;
38297         this_obj_conv.inner = untag_ptr(this_obj);
38298         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38300         OpenChannelV2_free(this_obj_conv);
38301 }
38302
38303 int8_tArray  CS_LDK_OpenChannelV2_get_chain_hash(int64_t this_ptr) {
38304         LDKOpenChannelV2 this_ptr_conv;
38305         this_ptr_conv.inner = untag_ptr(this_ptr);
38306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38308         this_ptr_conv.is_owned = false;
38309         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
38310         memcpy(ret_arr->elems, *OpenChannelV2_get_chain_hash(&this_ptr_conv), 32);
38311         return ret_arr;
38312 }
38313
38314 void  CS_LDK_OpenChannelV2_set_chain_hash(int64_t this_ptr, int8_tArray val) {
38315         LDKOpenChannelV2 this_ptr_conv;
38316         this_ptr_conv.inner = untag_ptr(this_ptr);
38317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38319         this_ptr_conv.is_owned = false;
38320         LDKThirtyTwoBytes val_ref;
38321         CHECK(val->arr_len == 32);
38322         memcpy(val_ref.data, val->elems, 32); FREE(val);
38323         OpenChannelV2_set_chain_hash(&this_ptr_conv, val_ref);
38324 }
38325
38326 int8_tArray  CS_LDK_OpenChannelV2_get_temporary_channel_id(int64_t this_ptr) {
38327         LDKOpenChannelV2 this_ptr_conv;
38328         this_ptr_conv.inner = untag_ptr(this_ptr);
38329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38331         this_ptr_conv.is_owned = false;
38332         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
38333         memcpy(ret_arr->elems, *OpenChannelV2_get_temporary_channel_id(&this_ptr_conv), 32);
38334         return ret_arr;
38335 }
38336
38337 void  CS_LDK_OpenChannelV2_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
38338         LDKOpenChannelV2 this_ptr_conv;
38339         this_ptr_conv.inner = untag_ptr(this_ptr);
38340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38342         this_ptr_conv.is_owned = false;
38343         LDKThirtyTwoBytes val_ref;
38344         CHECK(val->arr_len == 32);
38345         memcpy(val_ref.data, val->elems, 32); FREE(val);
38346         OpenChannelV2_set_temporary_channel_id(&this_ptr_conv, val_ref);
38347 }
38348
38349 int32_t  CS_LDK_OpenChannelV2_get_funding_feerate_sat_per_1000_weight(int64_t this_ptr) {
38350         LDKOpenChannelV2 this_ptr_conv;
38351         this_ptr_conv.inner = untag_ptr(this_ptr);
38352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38354         this_ptr_conv.is_owned = false;
38355         int32_t ret_conv = OpenChannelV2_get_funding_feerate_sat_per_1000_weight(&this_ptr_conv);
38356         return ret_conv;
38357 }
38358
38359 void  CS_LDK_OpenChannelV2_set_funding_feerate_sat_per_1000_weight(int64_t this_ptr, int32_t val) {
38360         LDKOpenChannelV2 this_ptr_conv;
38361         this_ptr_conv.inner = untag_ptr(this_ptr);
38362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38364         this_ptr_conv.is_owned = false;
38365         OpenChannelV2_set_funding_feerate_sat_per_1000_weight(&this_ptr_conv, val);
38366 }
38367
38368 int32_t  CS_LDK_OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(int64_t this_ptr) {
38369         LDKOpenChannelV2 this_ptr_conv;
38370         this_ptr_conv.inner = untag_ptr(this_ptr);
38371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38373         this_ptr_conv.is_owned = false;
38374         int32_t ret_conv = OpenChannelV2_get_commitment_feerate_sat_per_1000_weight(&this_ptr_conv);
38375         return ret_conv;
38376 }
38377
38378 void  CS_LDK_OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(int64_t this_ptr, int32_t val) {
38379         LDKOpenChannelV2 this_ptr_conv;
38380         this_ptr_conv.inner = untag_ptr(this_ptr);
38381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38383         this_ptr_conv.is_owned = false;
38384         OpenChannelV2_set_commitment_feerate_sat_per_1000_weight(&this_ptr_conv, val);
38385 }
38386
38387 int64_t  CS_LDK_OpenChannelV2_get_funding_satoshis(int64_t this_ptr) {
38388         LDKOpenChannelV2 this_ptr_conv;
38389         this_ptr_conv.inner = untag_ptr(this_ptr);
38390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38392         this_ptr_conv.is_owned = false;
38393         int64_t ret_conv = OpenChannelV2_get_funding_satoshis(&this_ptr_conv);
38394         return ret_conv;
38395 }
38396
38397 void  CS_LDK_OpenChannelV2_set_funding_satoshis(int64_t this_ptr, int64_t val) {
38398         LDKOpenChannelV2 this_ptr_conv;
38399         this_ptr_conv.inner = untag_ptr(this_ptr);
38400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38402         this_ptr_conv.is_owned = false;
38403         OpenChannelV2_set_funding_satoshis(&this_ptr_conv, val);
38404 }
38405
38406 int64_t  CS_LDK_OpenChannelV2_get_dust_limit_satoshis(int64_t this_ptr) {
38407         LDKOpenChannelV2 this_ptr_conv;
38408         this_ptr_conv.inner = untag_ptr(this_ptr);
38409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38411         this_ptr_conv.is_owned = false;
38412         int64_t ret_conv = OpenChannelV2_get_dust_limit_satoshis(&this_ptr_conv);
38413         return ret_conv;
38414 }
38415
38416 void  CS_LDK_OpenChannelV2_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
38417         LDKOpenChannelV2 this_ptr_conv;
38418         this_ptr_conv.inner = untag_ptr(this_ptr);
38419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38421         this_ptr_conv.is_owned = false;
38422         OpenChannelV2_set_dust_limit_satoshis(&this_ptr_conv, val);
38423 }
38424
38425 int64_t  CS_LDK_OpenChannelV2_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
38426         LDKOpenChannelV2 this_ptr_conv;
38427         this_ptr_conv.inner = untag_ptr(this_ptr);
38428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38430         this_ptr_conv.is_owned = false;
38431         int64_t ret_conv = OpenChannelV2_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
38432         return ret_conv;
38433 }
38434
38435 void  CS_LDK_OpenChannelV2_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
38436         LDKOpenChannelV2 this_ptr_conv;
38437         this_ptr_conv.inner = untag_ptr(this_ptr);
38438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38440         this_ptr_conv.is_owned = false;
38441         OpenChannelV2_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
38442 }
38443
38444 int64_t  CS_LDK_OpenChannelV2_get_htlc_minimum_msat(int64_t this_ptr) {
38445         LDKOpenChannelV2 this_ptr_conv;
38446         this_ptr_conv.inner = untag_ptr(this_ptr);
38447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38449         this_ptr_conv.is_owned = false;
38450         int64_t ret_conv = OpenChannelV2_get_htlc_minimum_msat(&this_ptr_conv);
38451         return ret_conv;
38452 }
38453
38454 void  CS_LDK_OpenChannelV2_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
38455         LDKOpenChannelV2 this_ptr_conv;
38456         this_ptr_conv.inner = untag_ptr(this_ptr);
38457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38459         this_ptr_conv.is_owned = false;
38460         OpenChannelV2_set_htlc_minimum_msat(&this_ptr_conv, val);
38461 }
38462
38463 int16_t  CS_LDK_OpenChannelV2_get_to_self_delay(int64_t this_ptr) {
38464         LDKOpenChannelV2 this_ptr_conv;
38465         this_ptr_conv.inner = untag_ptr(this_ptr);
38466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38468         this_ptr_conv.is_owned = false;
38469         int16_t ret_conv = OpenChannelV2_get_to_self_delay(&this_ptr_conv);
38470         return ret_conv;
38471 }
38472
38473 void  CS_LDK_OpenChannelV2_set_to_self_delay(int64_t this_ptr, int16_t val) {
38474         LDKOpenChannelV2 this_ptr_conv;
38475         this_ptr_conv.inner = untag_ptr(this_ptr);
38476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38478         this_ptr_conv.is_owned = false;
38479         OpenChannelV2_set_to_self_delay(&this_ptr_conv, val);
38480 }
38481
38482 int16_t  CS_LDK_OpenChannelV2_get_max_accepted_htlcs(int64_t this_ptr) {
38483         LDKOpenChannelV2 this_ptr_conv;
38484         this_ptr_conv.inner = untag_ptr(this_ptr);
38485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38487         this_ptr_conv.is_owned = false;
38488         int16_t ret_conv = OpenChannelV2_get_max_accepted_htlcs(&this_ptr_conv);
38489         return ret_conv;
38490 }
38491
38492 void  CS_LDK_OpenChannelV2_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
38493         LDKOpenChannelV2 this_ptr_conv;
38494         this_ptr_conv.inner = untag_ptr(this_ptr);
38495         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38497         this_ptr_conv.is_owned = false;
38498         OpenChannelV2_set_max_accepted_htlcs(&this_ptr_conv, val);
38499 }
38500
38501 int32_t  CS_LDK_OpenChannelV2_get_locktime(int64_t this_ptr) {
38502         LDKOpenChannelV2 this_ptr_conv;
38503         this_ptr_conv.inner = untag_ptr(this_ptr);
38504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38506         this_ptr_conv.is_owned = false;
38507         int32_t ret_conv = OpenChannelV2_get_locktime(&this_ptr_conv);
38508         return ret_conv;
38509 }
38510
38511 void  CS_LDK_OpenChannelV2_set_locktime(int64_t this_ptr, int32_t val) {
38512         LDKOpenChannelV2 this_ptr_conv;
38513         this_ptr_conv.inner = untag_ptr(this_ptr);
38514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38516         this_ptr_conv.is_owned = false;
38517         OpenChannelV2_set_locktime(&this_ptr_conv, val);
38518 }
38519
38520 int8_tArray  CS_LDK_OpenChannelV2_get_funding_pubkey(int64_t this_ptr) {
38521         LDKOpenChannelV2 this_ptr_conv;
38522         this_ptr_conv.inner = untag_ptr(this_ptr);
38523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38525         this_ptr_conv.is_owned = false;
38526         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38527         memcpy(ret_arr->elems, OpenChannelV2_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
38528         return ret_arr;
38529 }
38530
38531 void  CS_LDK_OpenChannelV2_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
38532         LDKOpenChannelV2 this_ptr_conv;
38533         this_ptr_conv.inner = untag_ptr(this_ptr);
38534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38536         this_ptr_conv.is_owned = false;
38537         LDKPublicKey val_ref;
38538         CHECK(val->arr_len == 33);
38539         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38540         OpenChannelV2_set_funding_pubkey(&this_ptr_conv, val_ref);
38541 }
38542
38543 int8_tArray  CS_LDK_OpenChannelV2_get_revocation_basepoint(int64_t this_ptr) {
38544         LDKOpenChannelV2 this_ptr_conv;
38545         this_ptr_conv.inner = untag_ptr(this_ptr);
38546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38548         this_ptr_conv.is_owned = false;
38549         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38550         memcpy(ret_arr->elems, OpenChannelV2_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
38551         return ret_arr;
38552 }
38553
38554 void  CS_LDK_OpenChannelV2_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
38555         LDKOpenChannelV2 this_ptr_conv;
38556         this_ptr_conv.inner = untag_ptr(this_ptr);
38557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38559         this_ptr_conv.is_owned = false;
38560         LDKPublicKey val_ref;
38561         CHECK(val->arr_len == 33);
38562         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38563         OpenChannelV2_set_revocation_basepoint(&this_ptr_conv, val_ref);
38564 }
38565
38566 int8_tArray  CS_LDK_OpenChannelV2_get_payment_basepoint(int64_t this_ptr) {
38567         LDKOpenChannelV2 this_ptr_conv;
38568         this_ptr_conv.inner = untag_ptr(this_ptr);
38569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38571         this_ptr_conv.is_owned = false;
38572         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38573         memcpy(ret_arr->elems, OpenChannelV2_get_payment_basepoint(&this_ptr_conv).compressed_form, 33);
38574         return ret_arr;
38575 }
38576
38577 void  CS_LDK_OpenChannelV2_set_payment_basepoint(int64_t this_ptr, int8_tArray val) {
38578         LDKOpenChannelV2 this_ptr_conv;
38579         this_ptr_conv.inner = untag_ptr(this_ptr);
38580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38582         this_ptr_conv.is_owned = false;
38583         LDKPublicKey val_ref;
38584         CHECK(val->arr_len == 33);
38585         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38586         OpenChannelV2_set_payment_basepoint(&this_ptr_conv, val_ref);
38587 }
38588
38589 int8_tArray  CS_LDK_OpenChannelV2_get_delayed_payment_basepoint(int64_t this_ptr) {
38590         LDKOpenChannelV2 this_ptr_conv;
38591         this_ptr_conv.inner = untag_ptr(this_ptr);
38592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38594         this_ptr_conv.is_owned = false;
38595         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38596         memcpy(ret_arr->elems, OpenChannelV2_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
38597         return ret_arr;
38598 }
38599
38600 void  CS_LDK_OpenChannelV2_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
38601         LDKOpenChannelV2 this_ptr_conv;
38602         this_ptr_conv.inner = untag_ptr(this_ptr);
38603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38605         this_ptr_conv.is_owned = false;
38606         LDKPublicKey val_ref;
38607         CHECK(val->arr_len == 33);
38608         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38609         OpenChannelV2_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
38610 }
38611
38612 int8_tArray  CS_LDK_OpenChannelV2_get_htlc_basepoint(int64_t this_ptr) {
38613         LDKOpenChannelV2 this_ptr_conv;
38614         this_ptr_conv.inner = untag_ptr(this_ptr);
38615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38617         this_ptr_conv.is_owned = false;
38618         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38619         memcpy(ret_arr->elems, OpenChannelV2_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
38620         return ret_arr;
38621 }
38622
38623 void  CS_LDK_OpenChannelV2_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
38624         LDKOpenChannelV2 this_ptr_conv;
38625         this_ptr_conv.inner = untag_ptr(this_ptr);
38626         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38628         this_ptr_conv.is_owned = false;
38629         LDKPublicKey val_ref;
38630         CHECK(val->arr_len == 33);
38631         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38632         OpenChannelV2_set_htlc_basepoint(&this_ptr_conv, val_ref);
38633 }
38634
38635 int8_tArray  CS_LDK_OpenChannelV2_get_first_per_commitment_point(int64_t this_ptr) {
38636         LDKOpenChannelV2 this_ptr_conv;
38637         this_ptr_conv.inner = untag_ptr(this_ptr);
38638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38640         this_ptr_conv.is_owned = false;
38641         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38642         memcpy(ret_arr->elems, OpenChannelV2_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
38643         return ret_arr;
38644 }
38645
38646 void  CS_LDK_OpenChannelV2_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
38647         LDKOpenChannelV2 this_ptr_conv;
38648         this_ptr_conv.inner = untag_ptr(this_ptr);
38649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38651         this_ptr_conv.is_owned = false;
38652         LDKPublicKey val_ref;
38653         CHECK(val->arr_len == 33);
38654         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38655         OpenChannelV2_set_first_per_commitment_point(&this_ptr_conv, val_ref);
38656 }
38657
38658 int8_tArray  CS_LDK_OpenChannelV2_get_second_per_commitment_point(int64_t this_ptr) {
38659         LDKOpenChannelV2 this_ptr_conv;
38660         this_ptr_conv.inner = untag_ptr(this_ptr);
38661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38663         this_ptr_conv.is_owned = false;
38664         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38665         memcpy(ret_arr->elems, OpenChannelV2_get_second_per_commitment_point(&this_ptr_conv).compressed_form, 33);
38666         return ret_arr;
38667 }
38668
38669 void  CS_LDK_OpenChannelV2_set_second_per_commitment_point(int64_t this_ptr, int8_tArray val) {
38670         LDKOpenChannelV2 this_ptr_conv;
38671         this_ptr_conv.inner = untag_ptr(this_ptr);
38672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38674         this_ptr_conv.is_owned = false;
38675         LDKPublicKey val_ref;
38676         CHECK(val->arr_len == 33);
38677         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38678         OpenChannelV2_set_second_per_commitment_point(&this_ptr_conv, val_ref);
38679 }
38680
38681 int8_t  CS_LDK_OpenChannelV2_get_channel_flags(int64_t this_ptr) {
38682         LDKOpenChannelV2 this_ptr_conv;
38683         this_ptr_conv.inner = untag_ptr(this_ptr);
38684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38686         this_ptr_conv.is_owned = false;
38687         int8_t ret_conv = OpenChannelV2_get_channel_flags(&this_ptr_conv);
38688         return ret_conv;
38689 }
38690
38691 void  CS_LDK_OpenChannelV2_set_channel_flags(int64_t this_ptr, int8_t val) {
38692         LDKOpenChannelV2 this_ptr_conv;
38693         this_ptr_conv.inner = untag_ptr(this_ptr);
38694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38696         this_ptr_conv.is_owned = false;
38697         OpenChannelV2_set_channel_flags(&this_ptr_conv, val);
38698 }
38699
38700 int64_t  CS_LDK_OpenChannelV2_get_shutdown_scriptpubkey(int64_t this_ptr) {
38701         LDKOpenChannelV2 this_ptr_conv;
38702         this_ptr_conv.inner = untag_ptr(this_ptr);
38703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38705         this_ptr_conv.is_owned = false;
38706         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
38707         *ret_copy = OpenChannelV2_get_shutdown_scriptpubkey(&this_ptr_conv);
38708         int64_t ret_ref = tag_ptr(ret_copy, true);
38709         return ret_ref;
38710 }
38711
38712 void  CS_LDK_OpenChannelV2_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
38713         LDKOpenChannelV2 this_ptr_conv;
38714         this_ptr_conv.inner = untag_ptr(this_ptr);
38715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38717         this_ptr_conv.is_owned = false;
38718         void* val_ptr = untag_ptr(val);
38719         CHECK_ACCESS(val_ptr);
38720         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
38721         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
38722         OpenChannelV2_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
38723 }
38724
38725 int64_t  CS_LDK_OpenChannelV2_get_channel_type(int64_t this_ptr) {
38726         LDKOpenChannelV2 this_ptr_conv;
38727         this_ptr_conv.inner = untag_ptr(this_ptr);
38728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38730         this_ptr_conv.is_owned = false;
38731         LDKChannelTypeFeatures ret_var = OpenChannelV2_get_channel_type(&this_ptr_conv);
38732         int64_t ret_ref = 0;
38733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38735         return ret_ref;
38736 }
38737
38738 void  CS_LDK_OpenChannelV2_set_channel_type(int64_t this_ptr, int64_t val) {
38739         LDKOpenChannelV2 this_ptr_conv;
38740         this_ptr_conv.inner = untag_ptr(this_ptr);
38741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38743         this_ptr_conv.is_owned = false;
38744         LDKChannelTypeFeatures val_conv;
38745         val_conv.inner = untag_ptr(val);
38746         val_conv.is_owned = ptr_is_owned(val);
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38748         val_conv = ChannelTypeFeatures_clone(&val_conv);
38749         OpenChannelV2_set_channel_type(&this_ptr_conv, val_conv);
38750 }
38751
38752 int32_t  CS_LDK_OpenChannelV2_get_require_confirmed_inputs(int64_t this_ptr) {
38753         LDKOpenChannelV2 this_ptr_conv;
38754         this_ptr_conv.inner = untag_ptr(this_ptr);
38755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38757         this_ptr_conv.is_owned = false;
38758         int32_t ret_conv = LDKCOption_NoneZ_to_cs(OpenChannelV2_get_require_confirmed_inputs(&this_ptr_conv));
38759         return ret_conv;
38760 }
38761
38762 void  CS_LDK_OpenChannelV2_set_require_confirmed_inputs(int64_t this_ptr, int32_t val) {
38763         LDKOpenChannelV2 this_ptr_conv;
38764         this_ptr_conv.inner = untag_ptr(this_ptr);
38765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38767         this_ptr_conv.is_owned = false;
38768         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_cs(val);
38769         OpenChannelV2_set_require_confirmed_inputs(&this_ptr_conv, val_conv);
38770 }
38771
38772 int64_t  CS_LDK_OpenChannelV2_new(int8_tArray chain_hash_arg, int8_tArray temporary_channel_id_arg, int32_t funding_feerate_sat_per_1000_weight_arg, int32_t commitment_feerate_sat_per_1000_weight_arg, int64_t funding_satoshis_arg, int64_t dust_limit_satoshis_arg, int64_t max_htlc_value_in_flight_msat_arg, int64_t htlc_minimum_msat_arg, int16_t to_self_delay_arg, int16_t max_accepted_htlcs_arg, int32_t locktime_arg, int8_tArray funding_pubkey_arg, int8_tArray revocation_basepoint_arg, int8_tArray payment_basepoint_arg, int8_tArray delayed_payment_basepoint_arg, int8_tArray htlc_basepoint_arg, int8_tArray first_per_commitment_point_arg, int8_tArray second_per_commitment_point_arg, int8_t channel_flags_arg, int64_t shutdown_scriptpubkey_arg, int64_t channel_type_arg, int32_t require_confirmed_inputs_arg) {
38773         LDKThirtyTwoBytes chain_hash_arg_ref;
38774         CHECK(chain_hash_arg->arr_len == 32);
38775         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
38776         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
38777         CHECK(temporary_channel_id_arg->arr_len == 32);
38778         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
38779         LDKPublicKey funding_pubkey_arg_ref;
38780         CHECK(funding_pubkey_arg->arr_len == 33);
38781         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
38782         LDKPublicKey revocation_basepoint_arg_ref;
38783         CHECK(revocation_basepoint_arg->arr_len == 33);
38784         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
38785         LDKPublicKey payment_basepoint_arg_ref;
38786         CHECK(payment_basepoint_arg->arr_len == 33);
38787         memcpy(payment_basepoint_arg_ref.compressed_form, payment_basepoint_arg->elems, 33); FREE(payment_basepoint_arg);
38788         LDKPublicKey delayed_payment_basepoint_arg_ref;
38789         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
38790         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
38791         LDKPublicKey htlc_basepoint_arg_ref;
38792         CHECK(htlc_basepoint_arg->arr_len == 33);
38793         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
38794         LDKPublicKey first_per_commitment_point_arg_ref;
38795         CHECK(first_per_commitment_point_arg->arr_len == 33);
38796         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
38797         LDKPublicKey second_per_commitment_point_arg_ref;
38798         CHECK(second_per_commitment_point_arg->arr_len == 33);
38799         memcpy(second_per_commitment_point_arg_ref.compressed_form, second_per_commitment_point_arg->elems, 33); FREE(second_per_commitment_point_arg);
38800         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
38801         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
38802         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
38803         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
38804         LDKChannelTypeFeatures channel_type_arg_conv;
38805         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
38806         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
38807         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
38808         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
38809         LDKCOption_NoneZ require_confirmed_inputs_arg_conv = LDKCOption_NoneZ_from_cs(require_confirmed_inputs_arg);
38810         LDKOpenChannelV2 ret_var = OpenChannelV2_new(chain_hash_arg_ref, temporary_channel_id_arg_ref, funding_feerate_sat_per_1000_weight_arg, commitment_feerate_sat_per_1000_weight_arg, funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, to_self_delay_arg, max_accepted_htlcs_arg, locktime_arg, funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_basepoint_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref, first_per_commitment_point_arg_ref, second_per_commitment_point_arg_ref, channel_flags_arg, shutdown_scriptpubkey_arg_conv, channel_type_arg_conv, require_confirmed_inputs_arg_conv);
38811         int64_t ret_ref = 0;
38812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38813         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38814         return ret_ref;
38815 }
38816
38817 static inline uint64_t OpenChannelV2_clone_ptr(LDKOpenChannelV2 *NONNULL_PTR arg) {
38818         LDKOpenChannelV2 ret_var = OpenChannelV2_clone(arg);
38819         int64_t ret_ref = 0;
38820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38821         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38822         return ret_ref;
38823 }
38824 int64_t  CS_LDK_OpenChannelV2_clone_ptr(int64_t arg) {
38825         LDKOpenChannelV2 arg_conv;
38826         arg_conv.inner = untag_ptr(arg);
38827         arg_conv.is_owned = ptr_is_owned(arg);
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38829         arg_conv.is_owned = false;
38830         int64_t ret_conv = OpenChannelV2_clone_ptr(&arg_conv);
38831         return ret_conv;
38832 }
38833
38834 int64_t  CS_LDK_OpenChannelV2_clone(int64_t orig) {
38835         LDKOpenChannelV2 orig_conv;
38836         orig_conv.inner = untag_ptr(orig);
38837         orig_conv.is_owned = ptr_is_owned(orig);
38838         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38839         orig_conv.is_owned = false;
38840         LDKOpenChannelV2 ret_var = OpenChannelV2_clone(&orig_conv);
38841         int64_t ret_ref = 0;
38842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38843         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38844         return ret_ref;
38845 }
38846
38847 jboolean  CS_LDK_OpenChannelV2_eq(int64_t a, int64_t b) {
38848         LDKOpenChannelV2 a_conv;
38849         a_conv.inner = untag_ptr(a);
38850         a_conv.is_owned = ptr_is_owned(a);
38851         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38852         a_conv.is_owned = false;
38853         LDKOpenChannelV2 b_conv;
38854         b_conv.inner = untag_ptr(b);
38855         b_conv.is_owned = ptr_is_owned(b);
38856         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38857         b_conv.is_owned = false;
38858         jboolean ret_conv = OpenChannelV2_eq(&a_conv, &b_conv);
38859         return ret_conv;
38860 }
38861
38862 void  CS_LDK_AcceptChannel_free(int64_t this_obj) {
38863         LDKAcceptChannel this_obj_conv;
38864         this_obj_conv.inner = untag_ptr(this_obj);
38865         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38867         AcceptChannel_free(this_obj_conv);
38868 }
38869
38870 int8_tArray  CS_LDK_AcceptChannel_get_temporary_channel_id(int64_t this_ptr) {
38871         LDKAcceptChannel this_ptr_conv;
38872         this_ptr_conv.inner = untag_ptr(this_ptr);
38873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38875         this_ptr_conv.is_owned = false;
38876         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
38877         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
38878         return ret_arr;
38879 }
38880
38881 void  CS_LDK_AcceptChannel_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
38882         LDKAcceptChannel this_ptr_conv;
38883         this_ptr_conv.inner = untag_ptr(this_ptr);
38884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38886         this_ptr_conv.is_owned = false;
38887         LDKThirtyTwoBytes val_ref;
38888         CHECK(val->arr_len == 32);
38889         memcpy(val_ref.data, val->elems, 32); FREE(val);
38890         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
38891 }
38892
38893 int64_t  CS_LDK_AcceptChannel_get_dust_limit_satoshis(int64_t this_ptr) {
38894         LDKAcceptChannel this_ptr_conv;
38895         this_ptr_conv.inner = untag_ptr(this_ptr);
38896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38898         this_ptr_conv.is_owned = false;
38899         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
38900         return ret_conv;
38901 }
38902
38903 void  CS_LDK_AcceptChannel_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
38904         LDKAcceptChannel this_ptr_conv;
38905         this_ptr_conv.inner = untag_ptr(this_ptr);
38906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38908         this_ptr_conv.is_owned = false;
38909         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
38910 }
38911
38912 int64_t  CS_LDK_AcceptChannel_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
38913         LDKAcceptChannel this_ptr_conv;
38914         this_ptr_conv.inner = untag_ptr(this_ptr);
38915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38917         this_ptr_conv.is_owned = false;
38918         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
38919         return ret_conv;
38920 }
38921
38922 void  CS_LDK_AcceptChannel_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
38923         LDKAcceptChannel this_ptr_conv;
38924         this_ptr_conv.inner = untag_ptr(this_ptr);
38925         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38927         this_ptr_conv.is_owned = false;
38928         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
38929 }
38930
38931 int64_t  CS_LDK_AcceptChannel_get_channel_reserve_satoshis(int64_t this_ptr) {
38932         LDKAcceptChannel this_ptr_conv;
38933         this_ptr_conv.inner = untag_ptr(this_ptr);
38934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38936         this_ptr_conv.is_owned = false;
38937         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
38938         return ret_conv;
38939 }
38940
38941 void  CS_LDK_AcceptChannel_set_channel_reserve_satoshis(int64_t this_ptr, int64_t val) {
38942         LDKAcceptChannel this_ptr_conv;
38943         this_ptr_conv.inner = untag_ptr(this_ptr);
38944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38946         this_ptr_conv.is_owned = false;
38947         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
38948 }
38949
38950 int64_t  CS_LDK_AcceptChannel_get_htlc_minimum_msat(int64_t this_ptr) {
38951         LDKAcceptChannel this_ptr_conv;
38952         this_ptr_conv.inner = untag_ptr(this_ptr);
38953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38955         this_ptr_conv.is_owned = false;
38956         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
38957         return ret_conv;
38958 }
38959
38960 void  CS_LDK_AcceptChannel_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
38961         LDKAcceptChannel this_ptr_conv;
38962         this_ptr_conv.inner = untag_ptr(this_ptr);
38963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38965         this_ptr_conv.is_owned = false;
38966         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
38967 }
38968
38969 int32_t  CS_LDK_AcceptChannel_get_minimum_depth(int64_t this_ptr) {
38970         LDKAcceptChannel this_ptr_conv;
38971         this_ptr_conv.inner = untag_ptr(this_ptr);
38972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38974         this_ptr_conv.is_owned = false;
38975         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
38976         return ret_conv;
38977 }
38978
38979 void  CS_LDK_AcceptChannel_set_minimum_depth(int64_t this_ptr, int32_t val) {
38980         LDKAcceptChannel this_ptr_conv;
38981         this_ptr_conv.inner = untag_ptr(this_ptr);
38982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38984         this_ptr_conv.is_owned = false;
38985         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
38986 }
38987
38988 int16_t  CS_LDK_AcceptChannel_get_to_self_delay(int64_t this_ptr) {
38989         LDKAcceptChannel this_ptr_conv;
38990         this_ptr_conv.inner = untag_ptr(this_ptr);
38991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38993         this_ptr_conv.is_owned = false;
38994         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
38995         return ret_conv;
38996 }
38997
38998 void  CS_LDK_AcceptChannel_set_to_self_delay(int64_t this_ptr, int16_t val) {
38999         LDKAcceptChannel this_ptr_conv;
39000         this_ptr_conv.inner = untag_ptr(this_ptr);
39001         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39003         this_ptr_conv.is_owned = false;
39004         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
39005 }
39006
39007 int16_t  CS_LDK_AcceptChannel_get_max_accepted_htlcs(int64_t this_ptr) {
39008         LDKAcceptChannel this_ptr_conv;
39009         this_ptr_conv.inner = untag_ptr(this_ptr);
39010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39012         this_ptr_conv.is_owned = false;
39013         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
39014         return ret_conv;
39015 }
39016
39017 void  CS_LDK_AcceptChannel_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
39018         LDKAcceptChannel this_ptr_conv;
39019         this_ptr_conv.inner = untag_ptr(this_ptr);
39020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39022         this_ptr_conv.is_owned = false;
39023         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
39024 }
39025
39026 int8_tArray  CS_LDK_AcceptChannel_get_funding_pubkey(int64_t this_ptr) {
39027         LDKAcceptChannel this_ptr_conv;
39028         this_ptr_conv.inner = untag_ptr(this_ptr);
39029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39031         this_ptr_conv.is_owned = false;
39032         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39033         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
39034         return ret_arr;
39035 }
39036
39037 void  CS_LDK_AcceptChannel_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
39038         LDKAcceptChannel this_ptr_conv;
39039         this_ptr_conv.inner = untag_ptr(this_ptr);
39040         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39042         this_ptr_conv.is_owned = false;
39043         LDKPublicKey val_ref;
39044         CHECK(val->arr_len == 33);
39045         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39046         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
39047 }
39048
39049 int8_tArray  CS_LDK_AcceptChannel_get_revocation_basepoint(int64_t this_ptr) {
39050         LDKAcceptChannel this_ptr_conv;
39051         this_ptr_conv.inner = untag_ptr(this_ptr);
39052         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39054         this_ptr_conv.is_owned = false;
39055         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39056         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
39057         return ret_arr;
39058 }
39059
39060 void  CS_LDK_AcceptChannel_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
39061         LDKAcceptChannel this_ptr_conv;
39062         this_ptr_conv.inner = untag_ptr(this_ptr);
39063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39065         this_ptr_conv.is_owned = false;
39066         LDKPublicKey val_ref;
39067         CHECK(val->arr_len == 33);
39068         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39069         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
39070 }
39071
39072 int8_tArray  CS_LDK_AcceptChannel_get_payment_point(int64_t this_ptr) {
39073         LDKAcceptChannel this_ptr_conv;
39074         this_ptr_conv.inner = untag_ptr(this_ptr);
39075         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39077         this_ptr_conv.is_owned = false;
39078         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39079         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
39080         return ret_arr;
39081 }
39082
39083 void  CS_LDK_AcceptChannel_set_payment_point(int64_t this_ptr, int8_tArray val) {
39084         LDKAcceptChannel this_ptr_conv;
39085         this_ptr_conv.inner = untag_ptr(this_ptr);
39086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39088         this_ptr_conv.is_owned = false;
39089         LDKPublicKey val_ref;
39090         CHECK(val->arr_len == 33);
39091         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39092         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
39093 }
39094
39095 int8_tArray  CS_LDK_AcceptChannel_get_delayed_payment_basepoint(int64_t this_ptr) {
39096         LDKAcceptChannel this_ptr_conv;
39097         this_ptr_conv.inner = untag_ptr(this_ptr);
39098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39100         this_ptr_conv.is_owned = false;
39101         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39102         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
39103         return ret_arr;
39104 }
39105
39106 void  CS_LDK_AcceptChannel_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
39107         LDKAcceptChannel this_ptr_conv;
39108         this_ptr_conv.inner = untag_ptr(this_ptr);
39109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39111         this_ptr_conv.is_owned = false;
39112         LDKPublicKey val_ref;
39113         CHECK(val->arr_len == 33);
39114         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39115         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39116 }
39117
39118 int8_tArray  CS_LDK_AcceptChannel_get_htlc_basepoint(int64_t this_ptr) {
39119         LDKAcceptChannel this_ptr_conv;
39120         this_ptr_conv.inner = untag_ptr(this_ptr);
39121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39123         this_ptr_conv.is_owned = false;
39124         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39125         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
39126         return ret_arr;
39127 }
39128
39129 void  CS_LDK_AcceptChannel_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
39130         LDKAcceptChannel this_ptr_conv;
39131         this_ptr_conv.inner = untag_ptr(this_ptr);
39132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39134         this_ptr_conv.is_owned = false;
39135         LDKPublicKey val_ref;
39136         CHECK(val->arr_len == 33);
39137         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39138         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
39139 }
39140
39141 int8_tArray  CS_LDK_AcceptChannel_get_first_per_commitment_point(int64_t this_ptr) {
39142         LDKAcceptChannel this_ptr_conv;
39143         this_ptr_conv.inner = untag_ptr(this_ptr);
39144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39146         this_ptr_conv.is_owned = false;
39147         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39148         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
39149         return ret_arr;
39150 }
39151
39152 void  CS_LDK_AcceptChannel_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
39153         LDKAcceptChannel this_ptr_conv;
39154         this_ptr_conv.inner = untag_ptr(this_ptr);
39155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39157         this_ptr_conv.is_owned = false;
39158         LDKPublicKey val_ref;
39159         CHECK(val->arr_len == 33);
39160         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39161         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
39162 }
39163
39164 int64_t  CS_LDK_AcceptChannel_get_shutdown_scriptpubkey(int64_t this_ptr) {
39165         LDKAcceptChannel this_ptr_conv;
39166         this_ptr_conv.inner = untag_ptr(this_ptr);
39167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39169         this_ptr_conv.is_owned = false;
39170         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
39171         *ret_copy = AcceptChannel_get_shutdown_scriptpubkey(&this_ptr_conv);
39172         int64_t ret_ref = tag_ptr(ret_copy, true);
39173         return ret_ref;
39174 }
39175
39176 void  CS_LDK_AcceptChannel_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
39177         LDKAcceptChannel this_ptr_conv;
39178         this_ptr_conv.inner = untag_ptr(this_ptr);
39179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39181         this_ptr_conv.is_owned = false;
39182         void* val_ptr = untag_ptr(val);
39183         CHECK_ACCESS(val_ptr);
39184         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
39185         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
39186         AcceptChannel_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
39187 }
39188
39189 int64_t  CS_LDK_AcceptChannel_get_channel_type(int64_t this_ptr) {
39190         LDKAcceptChannel this_ptr_conv;
39191         this_ptr_conv.inner = untag_ptr(this_ptr);
39192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39194         this_ptr_conv.is_owned = false;
39195         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
39196         int64_t ret_ref = 0;
39197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39199         return ret_ref;
39200 }
39201
39202 void  CS_LDK_AcceptChannel_set_channel_type(int64_t this_ptr, int64_t val) {
39203         LDKAcceptChannel this_ptr_conv;
39204         this_ptr_conv.inner = untag_ptr(this_ptr);
39205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39207         this_ptr_conv.is_owned = false;
39208         LDKChannelTypeFeatures val_conv;
39209         val_conv.inner = untag_ptr(val);
39210         val_conv.is_owned = ptr_is_owned(val);
39211         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39212         val_conv = ChannelTypeFeatures_clone(&val_conv);
39213         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
39214 }
39215
39216 int64_t  CS_LDK_AcceptChannel_new(int8_tArray temporary_channel_id_arg, int64_t dust_limit_satoshis_arg, int64_t max_htlc_value_in_flight_msat_arg, int64_t channel_reserve_satoshis_arg, int64_t htlc_minimum_msat_arg, int32_t minimum_depth_arg, int16_t to_self_delay_arg, int16_t max_accepted_htlcs_arg, 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, int8_tArray first_per_commitment_point_arg, int64_t shutdown_scriptpubkey_arg, int64_t channel_type_arg) {
39217         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
39218         CHECK(temporary_channel_id_arg->arr_len == 32);
39219         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
39220         LDKPublicKey funding_pubkey_arg_ref;
39221         CHECK(funding_pubkey_arg->arr_len == 33);
39222         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
39223         LDKPublicKey revocation_basepoint_arg_ref;
39224         CHECK(revocation_basepoint_arg->arr_len == 33);
39225         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
39226         LDKPublicKey payment_point_arg_ref;
39227         CHECK(payment_point_arg->arr_len == 33);
39228         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
39229         LDKPublicKey delayed_payment_basepoint_arg_ref;
39230         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
39231         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
39232         LDKPublicKey htlc_basepoint_arg_ref;
39233         CHECK(htlc_basepoint_arg->arr_len == 33);
39234         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
39235         LDKPublicKey first_per_commitment_point_arg_ref;
39236         CHECK(first_per_commitment_point_arg->arr_len == 33);
39237         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
39238         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
39239         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
39240         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
39241         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
39242         LDKChannelTypeFeatures channel_type_arg_conv;
39243         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
39244         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
39245         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
39246         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
39247         LDKAcceptChannel ret_var = AcceptChannel_new(temporary_channel_id_arg_ref, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, channel_reserve_satoshis_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref, first_per_commitment_point_arg_ref, shutdown_scriptpubkey_arg_conv, channel_type_arg_conv);
39248         int64_t ret_ref = 0;
39249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39251         return ret_ref;
39252 }
39253
39254 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
39255         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
39256         int64_t ret_ref = 0;
39257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39259         return ret_ref;
39260 }
39261 int64_t  CS_LDK_AcceptChannel_clone_ptr(int64_t arg) {
39262         LDKAcceptChannel arg_conv;
39263         arg_conv.inner = untag_ptr(arg);
39264         arg_conv.is_owned = ptr_is_owned(arg);
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39266         arg_conv.is_owned = false;
39267         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
39268         return ret_conv;
39269 }
39270
39271 int64_t  CS_LDK_AcceptChannel_clone(int64_t orig) {
39272         LDKAcceptChannel orig_conv;
39273         orig_conv.inner = untag_ptr(orig);
39274         orig_conv.is_owned = ptr_is_owned(orig);
39275         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39276         orig_conv.is_owned = false;
39277         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
39278         int64_t ret_ref = 0;
39279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39280         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39281         return ret_ref;
39282 }
39283
39284 jboolean  CS_LDK_AcceptChannel_eq(int64_t a, int64_t b) {
39285         LDKAcceptChannel a_conv;
39286         a_conv.inner = untag_ptr(a);
39287         a_conv.is_owned = ptr_is_owned(a);
39288         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39289         a_conv.is_owned = false;
39290         LDKAcceptChannel b_conv;
39291         b_conv.inner = untag_ptr(b);
39292         b_conv.is_owned = ptr_is_owned(b);
39293         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39294         b_conv.is_owned = false;
39295         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
39296         return ret_conv;
39297 }
39298
39299 void  CS_LDK_AcceptChannelV2_free(int64_t this_obj) {
39300         LDKAcceptChannelV2 this_obj_conv;
39301         this_obj_conv.inner = untag_ptr(this_obj);
39302         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39304         AcceptChannelV2_free(this_obj_conv);
39305 }
39306
39307 int8_tArray  CS_LDK_AcceptChannelV2_get_temporary_channel_id(int64_t this_ptr) {
39308         LDKAcceptChannelV2 this_ptr_conv;
39309         this_ptr_conv.inner = untag_ptr(this_ptr);
39310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39312         this_ptr_conv.is_owned = false;
39313         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39314         memcpy(ret_arr->elems, *AcceptChannelV2_get_temporary_channel_id(&this_ptr_conv), 32);
39315         return ret_arr;
39316 }
39317
39318 void  CS_LDK_AcceptChannelV2_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
39319         LDKAcceptChannelV2 this_ptr_conv;
39320         this_ptr_conv.inner = untag_ptr(this_ptr);
39321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39323         this_ptr_conv.is_owned = false;
39324         LDKThirtyTwoBytes val_ref;
39325         CHECK(val->arr_len == 32);
39326         memcpy(val_ref.data, val->elems, 32); FREE(val);
39327         AcceptChannelV2_set_temporary_channel_id(&this_ptr_conv, val_ref);
39328 }
39329
39330 int64_t  CS_LDK_AcceptChannelV2_get_funding_satoshis(int64_t this_ptr) {
39331         LDKAcceptChannelV2 this_ptr_conv;
39332         this_ptr_conv.inner = untag_ptr(this_ptr);
39333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39335         this_ptr_conv.is_owned = false;
39336         int64_t ret_conv = AcceptChannelV2_get_funding_satoshis(&this_ptr_conv);
39337         return ret_conv;
39338 }
39339
39340 void  CS_LDK_AcceptChannelV2_set_funding_satoshis(int64_t this_ptr, int64_t val) {
39341         LDKAcceptChannelV2 this_ptr_conv;
39342         this_ptr_conv.inner = untag_ptr(this_ptr);
39343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39345         this_ptr_conv.is_owned = false;
39346         AcceptChannelV2_set_funding_satoshis(&this_ptr_conv, val);
39347 }
39348
39349 int64_t  CS_LDK_AcceptChannelV2_get_dust_limit_satoshis(int64_t this_ptr) {
39350         LDKAcceptChannelV2 this_ptr_conv;
39351         this_ptr_conv.inner = untag_ptr(this_ptr);
39352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39354         this_ptr_conv.is_owned = false;
39355         int64_t ret_conv = AcceptChannelV2_get_dust_limit_satoshis(&this_ptr_conv);
39356         return ret_conv;
39357 }
39358
39359 void  CS_LDK_AcceptChannelV2_set_dust_limit_satoshis(int64_t this_ptr, int64_t val) {
39360         LDKAcceptChannelV2 this_ptr_conv;
39361         this_ptr_conv.inner = untag_ptr(this_ptr);
39362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39364         this_ptr_conv.is_owned = false;
39365         AcceptChannelV2_set_dust_limit_satoshis(&this_ptr_conv, val);
39366 }
39367
39368 int64_t  CS_LDK_AcceptChannelV2_get_max_htlc_value_in_flight_msat(int64_t this_ptr) {
39369         LDKAcceptChannelV2 this_ptr_conv;
39370         this_ptr_conv.inner = untag_ptr(this_ptr);
39371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39373         this_ptr_conv.is_owned = false;
39374         int64_t ret_conv = AcceptChannelV2_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
39375         return ret_conv;
39376 }
39377
39378 void  CS_LDK_AcceptChannelV2_set_max_htlc_value_in_flight_msat(int64_t this_ptr, int64_t val) {
39379         LDKAcceptChannelV2 this_ptr_conv;
39380         this_ptr_conv.inner = untag_ptr(this_ptr);
39381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39383         this_ptr_conv.is_owned = false;
39384         AcceptChannelV2_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
39385 }
39386
39387 int64_t  CS_LDK_AcceptChannelV2_get_htlc_minimum_msat(int64_t this_ptr) {
39388         LDKAcceptChannelV2 this_ptr_conv;
39389         this_ptr_conv.inner = untag_ptr(this_ptr);
39390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39392         this_ptr_conv.is_owned = false;
39393         int64_t ret_conv = AcceptChannelV2_get_htlc_minimum_msat(&this_ptr_conv);
39394         return ret_conv;
39395 }
39396
39397 void  CS_LDK_AcceptChannelV2_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
39398         LDKAcceptChannelV2 this_ptr_conv;
39399         this_ptr_conv.inner = untag_ptr(this_ptr);
39400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39402         this_ptr_conv.is_owned = false;
39403         AcceptChannelV2_set_htlc_minimum_msat(&this_ptr_conv, val);
39404 }
39405
39406 int32_t  CS_LDK_AcceptChannelV2_get_minimum_depth(int64_t this_ptr) {
39407         LDKAcceptChannelV2 this_ptr_conv;
39408         this_ptr_conv.inner = untag_ptr(this_ptr);
39409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39411         this_ptr_conv.is_owned = false;
39412         int32_t ret_conv = AcceptChannelV2_get_minimum_depth(&this_ptr_conv);
39413         return ret_conv;
39414 }
39415
39416 void  CS_LDK_AcceptChannelV2_set_minimum_depth(int64_t this_ptr, int32_t val) {
39417         LDKAcceptChannelV2 this_ptr_conv;
39418         this_ptr_conv.inner = untag_ptr(this_ptr);
39419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39421         this_ptr_conv.is_owned = false;
39422         AcceptChannelV2_set_minimum_depth(&this_ptr_conv, val);
39423 }
39424
39425 int16_t  CS_LDK_AcceptChannelV2_get_to_self_delay(int64_t this_ptr) {
39426         LDKAcceptChannelV2 this_ptr_conv;
39427         this_ptr_conv.inner = untag_ptr(this_ptr);
39428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39430         this_ptr_conv.is_owned = false;
39431         int16_t ret_conv = AcceptChannelV2_get_to_self_delay(&this_ptr_conv);
39432         return ret_conv;
39433 }
39434
39435 void  CS_LDK_AcceptChannelV2_set_to_self_delay(int64_t this_ptr, int16_t val) {
39436         LDKAcceptChannelV2 this_ptr_conv;
39437         this_ptr_conv.inner = untag_ptr(this_ptr);
39438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39440         this_ptr_conv.is_owned = false;
39441         AcceptChannelV2_set_to_self_delay(&this_ptr_conv, val);
39442 }
39443
39444 int16_t  CS_LDK_AcceptChannelV2_get_max_accepted_htlcs(int64_t this_ptr) {
39445         LDKAcceptChannelV2 this_ptr_conv;
39446         this_ptr_conv.inner = untag_ptr(this_ptr);
39447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39449         this_ptr_conv.is_owned = false;
39450         int16_t ret_conv = AcceptChannelV2_get_max_accepted_htlcs(&this_ptr_conv);
39451         return ret_conv;
39452 }
39453
39454 void  CS_LDK_AcceptChannelV2_set_max_accepted_htlcs(int64_t this_ptr, int16_t val) {
39455         LDKAcceptChannelV2 this_ptr_conv;
39456         this_ptr_conv.inner = untag_ptr(this_ptr);
39457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39459         this_ptr_conv.is_owned = false;
39460         AcceptChannelV2_set_max_accepted_htlcs(&this_ptr_conv, val);
39461 }
39462
39463 int8_tArray  CS_LDK_AcceptChannelV2_get_funding_pubkey(int64_t this_ptr) {
39464         LDKAcceptChannelV2 this_ptr_conv;
39465         this_ptr_conv.inner = untag_ptr(this_ptr);
39466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39468         this_ptr_conv.is_owned = false;
39469         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39470         memcpy(ret_arr->elems, AcceptChannelV2_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
39471         return ret_arr;
39472 }
39473
39474 void  CS_LDK_AcceptChannelV2_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
39475         LDKAcceptChannelV2 this_ptr_conv;
39476         this_ptr_conv.inner = untag_ptr(this_ptr);
39477         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39479         this_ptr_conv.is_owned = false;
39480         LDKPublicKey val_ref;
39481         CHECK(val->arr_len == 33);
39482         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39483         AcceptChannelV2_set_funding_pubkey(&this_ptr_conv, val_ref);
39484 }
39485
39486 int8_tArray  CS_LDK_AcceptChannelV2_get_revocation_basepoint(int64_t this_ptr) {
39487         LDKAcceptChannelV2 this_ptr_conv;
39488         this_ptr_conv.inner = untag_ptr(this_ptr);
39489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39491         this_ptr_conv.is_owned = false;
39492         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39493         memcpy(ret_arr->elems, AcceptChannelV2_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
39494         return ret_arr;
39495 }
39496
39497 void  CS_LDK_AcceptChannelV2_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
39498         LDKAcceptChannelV2 this_ptr_conv;
39499         this_ptr_conv.inner = untag_ptr(this_ptr);
39500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39502         this_ptr_conv.is_owned = false;
39503         LDKPublicKey val_ref;
39504         CHECK(val->arr_len == 33);
39505         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39506         AcceptChannelV2_set_revocation_basepoint(&this_ptr_conv, val_ref);
39507 }
39508
39509 int8_tArray  CS_LDK_AcceptChannelV2_get_payment_basepoint(int64_t this_ptr) {
39510         LDKAcceptChannelV2 this_ptr_conv;
39511         this_ptr_conv.inner = untag_ptr(this_ptr);
39512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39514         this_ptr_conv.is_owned = false;
39515         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39516         memcpy(ret_arr->elems, AcceptChannelV2_get_payment_basepoint(&this_ptr_conv).compressed_form, 33);
39517         return ret_arr;
39518 }
39519
39520 void  CS_LDK_AcceptChannelV2_set_payment_basepoint(int64_t this_ptr, int8_tArray val) {
39521         LDKAcceptChannelV2 this_ptr_conv;
39522         this_ptr_conv.inner = untag_ptr(this_ptr);
39523         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39525         this_ptr_conv.is_owned = false;
39526         LDKPublicKey val_ref;
39527         CHECK(val->arr_len == 33);
39528         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39529         AcceptChannelV2_set_payment_basepoint(&this_ptr_conv, val_ref);
39530 }
39531
39532 int8_tArray  CS_LDK_AcceptChannelV2_get_delayed_payment_basepoint(int64_t this_ptr) {
39533         LDKAcceptChannelV2 this_ptr_conv;
39534         this_ptr_conv.inner = untag_ptr(this_ptr);
39535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39537         this_ptr_conv.is_owned = false;
39538         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39539         memcpy(ret_arr->elems, AcceptChannelV2_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
39540         return ret_arr;
39541 }
39542
39543 void  CS_LDK_AcceptChannelV2_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
39544         LDKAcceptChannelV2 this_ptr_conv;
39545         this_ptr_conv.inner = untag_ptr(this_ptr);
39546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39548         this_ptr_conv.is_owned = false;
39549         LDKPublicKey val_ref;
39550         CHECK(val->arr_len == 33);
39551         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39552         AcceptChannelV2_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39553 }
39554
39555 int8_tArray  CS_LDK_AcceptChannelV2_get_htlc_basepoint(int64_t this_ptr) {
39556         LDKAcceptChannelV2 this_ptr_conv;
39557         this_ptr_conv.inner = untag_ptr(this_ptr);
39558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39560         this_ptr_conv.is_owned = false;
39561         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39562         memcpy(ret_arr->elems, AcceptChannelV2_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
39563         return ret_arr;
39564 }
39565
39566 void  CS_LDK_AcceptChannelV2_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
39567         LDKAcceptChannelV2 this_ptr_conv;
39568         this_ptr_conv.inner = untag_ptr(this_ptr);
39569         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39571         this_ptr_conv.is_owned = false;
39572         LDKPublicKey val_ref;
39573         CHECK(val->arr_len == 33);
39574         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39575         AcceptChannelV2_set_htlc_basepoint(&this_ptr_conv, val_ref);
39576 }
39577
39578 int8_tArray  CS_LDK_AcceptChannelV2_get_first_per_commitment_point(int64_t this_ptr) {
39579         LDKAcceptChannelV2 this_ptr_conv;
39580         this_ptr_conv.inner = untag_ptr(this_ptr);
39581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39583         this_ptr_conv.is_owned = false;
39584         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39585         memcpy(ret_arr->elems, AcceptChannelV2_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
39586         return ret_arr;
39587 }
39588
39589 void  CS_LDK_AcceptChannelV2_set_first_per_commitment_point(int64_t this_ptr, int8_tArray val) {
39590         LDKAcceptChannelV2 this_ptr_conv;
39591         this_ptr_conv.inner = untag_ptr(this_ptr);
39592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39594         this_ptr_conv.is_owned = false;
39595         LDKPublicKey val_ref;
39596         CHECK(val->arr_len == 33);
39597         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39598         AcceptChannelV2_set_first_per_commitment_point(&this_ptr_conv, val_ref);
39599 }
39600
39601 int8_tArray  CS_LDK_AcceptChannelV2_get_second_per_commitment_point(int64_t this_ptr) {
39602         LDKAcceptChannelV2 this_ptr_conv;
39603         this_ptr_conv.inner = untag_ptr(this_ptr);
39604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39606         this_ptr_conv.is_owned = false;
39607         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39608         memcpy(ret_arr->elems, AcceptChannelV2_get_second_per_commitment_point(&this_ptr_conv).compressed_form, 33);
39609         return ret_arr;
39610 }
39611
39612 void  CS_LDK_AcceptChannelV2_set_second_per_commitment_point(int64_t this_ptr, int8_tArray val) {
39613         LDKAcceptChannelV2 this_ptr_conv;
39614         this_ptr_conv.inner = untag_ptr(this_ptr);
39615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39617         this_ptr_conv.is_owned = false;
39618         LDKPublicKey val_ref;
39619         CHECK(val->arr_len == 33);
39620         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39621         AcceptChannelV2_set_second_per_commitment_point(&this_ptr_conv, val_ref);
39622 }
39623
39624 int64_t  CS_LDK_AcceptChannelV2_get_shutdown_scriptpubkey(int64_t this_ptr) {
39625         LDKAcceptChannelV2 this_ptr_conv;
39626         this_ptr_conv.inner = untag_ptr(this_ptr);
39627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39629         this_ptr_conv.is_owned = false;
39630         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
39631         *ret_copy = AcceptChannelV2_get_shutdown_scriptpubkey(&this_ptr_conv);
39632         int64_t ret_ref = tag_ptr(ret_copy, true);
39633         return ret_ref;
39634 }
39635
39636 void  CS_LDK_AcceptChannelV2_set_shutdown_scriptpubkey(int64_t this_ptr, int64_t val) {
39637         LDKAcceptChannelV2 this_ptr_conv;
39638         this_ptr_conv.inner = untag_ptr(this_ptr);
39639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39641         this_ptr_conv.is_owned = false;
39642         void* val_ptr = untag_ptr(val);
39643         CHECK_ACCESS(val_ptr);
39644         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
39645         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
39646         AcceptChannelV2_set_shutdown_scriptpubkey(&this_ptr_conv, val_conv);
39647 }
39648
39649 int64_t  CS_LDK_AcceptChannelV2_get_channel_type(int64_t this_ptr) {
39650         LDKAcceptChannelV2 this_ptr_conv;
39651         this_ptr_conv.inner = untag_ptr(this_ptr);
39652         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39654         this_ptr_conv.is_owned = false;
39655         LDKChannelTypeFeatures ret_var = AcceptChannelV2_get_channel_type(&this_ptr_conv);
39656         int64_t ret_ref = 0;
39657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39659         return ret_ref;
39660 }
39661
39662 void  CS_LDK_AcceptChannelV2_set_channel_type(int64_t this_ptr, int64_t val) {
39663         LDKAcceptChannelV2 this_ptr_conv;
39664         this_ptr_conv.inner = untag_ptr(this_ptr);
39665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39667         this_ptr_conv.is_owned = false;
39668         LDKChannelTypeFeatures val_conv;
39669         val_conv.inner = untag_ptr(val);
39670         val_conv.is_owned = ptr_is_owned(val);
39671         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39672         val_conv = ChannelTypeFeatures_clone(&val_conv);
39673         AcceptChannelV2_set_channel_type(&this_ptr_conv, val_conv);
39674 }
39675
39676 int32_t  CS_LDK_AcceptChannelV2_get_require_confirmed_inputs(int64_t this_ptr) {
39677         LDKAcceptChannelV2 this_ptr_conv;
39678         this_ptr_conv.inner = untag_ptr(this_ptr);
39679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39681         this_ptr_conv.is_owned = false;
39682         int32_t ret_conv = LDKCOption_NoneZ_to_cs(AcceptChannelV2_get_require_confirmed_inputs(&this_ptr_conv));
39683         return ret_conv;
39684 }
39685
39686 void  CS_LDK_AcceptChannelV2_set_require_confirmed_inputs(int64_t this_ptr, int32_t val) {
39687         LDKAcceptChannelV2 this_ptr_conv;
39688         this_ptr_conv.inner = untag_ptr(this_ptr);
39689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39691         this_ptr_conv.is_owned = false;
39692         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_cs(val);
39693         AcceptChannelV2_set_require_confirmed_inputs(&this_ptr_conv, val_conv);
39694 }
39695
39696 int64_t  CS_LDK_AcceptChannelV2_new(int8_tArray temporary_channel_id_arg, int64_t funding_satoshis_arg, int64_t dust_limit_satoshis_arg, int64_t max_htlc_value_in_flight_msat_arg, int64_t htlc_minimum_msat_arg, int32_t minimum_depth_arg, int16_t to_self_delay_arg, int16_t max_accepted_htlcs_arg, int8_tArray funding_pubkey_arg, int8_tArray revocation_basepoint_arg, int8_tArray payment_basepoint_arg, int8_tArray delayed_payment_basepoint_arg, int8_tArray htlc_basepoint_arg, int8_tArray first_per_commitment_point_arg, int8_tArray second_per_commitment_point_arg, int64_t shutdown_scriptpubkey_arg, int64_t channel_type_arg, int32_t require_confirmed_inputs_arg) {
39697         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
39698         CHECK(temporary_channel_id_arg->arr_len == 32);
39699         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
39700         LDKPublicKey funding_pubkey_arg_ref;
39701         CHECK(funding_pubkey_arg->arr_len == 33);
39702         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
39703         LDKPublicKey revocation_basepoint_arg_ref;
39704         CHECK(revocation_basepoint_arg->arr_len == 33);
39705         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
39706         LDKPublicKey payment_basepoint_arg_ref;
39707         CHECK(payment_basepoint_arg->arr_len == 33);
39708         memcpy(payment_basepoint_arg_ref.compressed_form, payment_basepoint_arg->elems, 33); FREE(payment_basepoint_arg);
39709         LDKPublicKey delayed_payment_basepoint_arg_ref;
39710         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
39711         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
39712         LDKPublicKey htlc_basepoint_arg_ref;
39713         CHECK(htlc_basepoint_arg->arr_len == 33);
39714         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
39715         LDKPublicKey first_per_commitment_point_arg_ref;
39716         CHECK(first_per_commitment_point_arg->arr_len == 33);
39717         memcpy(first_per_commitment_point_arg_ref.compressed_form, first_per_commitment_point_arg->elems, 33); FREE(first_per_commitment_point_arg);
39718         LDKPublicKey second_per_commitment_point_arg_ref;
39719         CHECK(second_per_commitment_point_arg->arr_len == 33);
39720         memcpy(second_per_commitment_point_arg_ref.compressed_form, second_per_commitment_point_arg->elems, 33); FREE(second_per_commitment_point_arg);
39721         void* shutdown_scriptpubkey_arg_ptr = untag_ptr(shutdown_scriptpubkey_arg);
39722         CHECK_ACCESS(shutdown_scriptpubkey_arg_ptr);
39723         LDKCOption_CVec_u8ZZ shutdown_scriptpubkey_arg_conv = *(LDKCOption_CVec_u8ZZ*)(shutdown_scriptpubkey_arg_ptr);
39724         shutdown_scriptpubkey_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(shutdown_scriptpubkey_arg));
39725         LDKChannelTypeFeatures channel_type_arg_conv;
39726         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
39727         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
39728         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
39729         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
39730         LDKCOption_NoneZ require_confirmed_inputs_arg_conv = LDKCOption_NoneZ_from_cs(require_confirmed_inputs_arg);
39731         LDKAcceptChannelV2 ret_var = AcceptChannelV2_new(temporary_channel_id_arg_ref, funding_satoshis_arg, dust_limit_satoshis_arg, max_htlc_value_in_flight_msat_arg, htlc_minimum_msat_arg, minimum_depth_arg, to_self_delay_arg, max_accepted_htlcs_arg, funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_basepoint_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref, first_per_commitment_point_arg_ref, second_per_commitment_point_arg_ref, shutdown_scriptpubkey_arg_conv, channel_type_arg_conv, require_confirmed_inputs_arg_conv);
39732         int64_t ret_ref = 0;
39733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39735         return ret_ref;
39736 }
39737
39738 static inline uint64_t AcceptChannelV2_clone_ptr(LDKAcceptChannelV2 *NONNULL_PTR arg) {
39739         LDKAcceptChannelV2 ret_var = AcceptChannelV2_clone(arg);
39740         int64_t ret_ref = 0;
39741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39742         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39743         return ret_ref;
39744 }
39745 int64_t  CS_LDK_AcceptChannelV2_clone_ptr(int64_t arg) {
39746         LDKAcceptChannelV2 arg_conv;
39747         arg_conv.inner = untag_ptr(arg);
39748         arg_conv.is_owned = ptr_is_owned(arg);
39749         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39750         arg_conv.is_owned = false;
39751         int64_t ret_conv = AcceptChannelV2_clone_ptr(&arg_conv);
39752         return ret_conv;
39753 }
39754
39755 int64_t  CS_LDK_AcceptChannelV2_clone(int64_t orig) {
39756         LDKAcceptChannelV2 orig_conv;
39757         orig_conv.inner = untag_ptr(orig);
39758         orig_conv.is_owned = ptr_is_owned(orig);
39759         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39760         orig_conv.is_owned = false;
39761         LDKAcceptChannelV2 ret_var = AcceptChannelV2_clone(&orig_conv);
39762         int64_t ret_ref = 0;
39763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39765         return ret_ref;
39766 }
39767
39768 jboolean  CS_LDK_AcceptChannelV2_eq(int64_t a, int64_t b) {
39769         LDKAcceptChannelV2 a_conv;
39770         a_conv.inner = untag_ptr(a);
39771         a_conv.is_owned = ptr_is_owned(a);
39772         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39773         a_conv.is_owned = false;
39774         LDKAcceptChannelV2 b_conv;
39775         b_conv.inner = untag_ptr(b);
39776         b_conv.is_owned = ptr_is_owned(b);
39777         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39778         b_conv.is_owned = false;
39779         jboolean ret_conv = AcceptChannelV2_eq(&a_conv, &b_conv);
39780         return ret_conv;
39781 }
39782
39783 void  CS_LDK_FundingCreated_free(int64_t this_obj) {
39784         LDKFundingCreated this_obj_conv;
39785         this_obj_conv.inner = untag_ptr(this_obj);
39786         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39788         FundingCreated_free(this_obj_conv);
39789 }
39790
39791 int8_tArray  CS_LDK_FundingCreated_get_temporary_channel_id(int64_t this_ptr) {
39792         LDKFundingCreated this_ptr_conv;
39793         this_ptr_conv.inner = untag_ptr(this_ptr);
39794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39796         this_ptr_conv.is_owned = false;
39797         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39798         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
39799         return ret_arr;
39800 }
39801
39802 void  CS_LDK_FundingCreated_set_temporary_channel_id(int64_t this_ptr, int8_tArray val) {
39803         LDKFundingCreated this_ptr_conv;
39804         this_ptr_conv.inner = untag_ptr(this_ptr);
39805         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39807         this_ptr_conv.is_owned = false;
39808         LDKThirtyTwoBytes val_ref;
39809         CHECK(val->arr_len == 32);
39810         memcpy(val_ref.data, val->elems, 32); FREE(val);
39811         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
39812 }
39813
39814 int8_tArray  CS_LDK_FundingCreated_get_funding_txid(int64_t this_ptr) {
39815         LDKFundingCreated this_ptr_conv;
39816         this_ptr_conv.inner = untag_ptr(this_ptr);
39817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39819         this_ptr_conv.is_owned = false;
39820         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39821         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
39822         return ret_arr;
39823 }
39824
39825 void  CS_LDK_FundingCreated_set_funding_txid(int64_t this_ptr, int8_tArray val) {
39826         LDKFundingCreated this_ptr_conv;
39827         this_ptr_conv.inner = untag_ptr(this_ptr);
39828         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39830         this_ptr_conv.is_owned = false;
39831         LDKThirtyTwoBytes val_ref;
39832         CHECK(val->arr_len == 32);
39833         memcpy(val_ref.data, val->elems, 32); FREE(val);
39834         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
39835 }
39836
39837 int16_t  CS_LDK_FundingCreated_get_funding_output_index(int64_t this_ptr) {
39838         LDKFundingCreated this_ptr_conv;
39839         this_ptr_conv.inner = untag_ptr(this_ptr);
39840         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39842         this_ptr_conv.is_owned = false;
39843         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
39844         return ret_conv;
39845 }
39846
39847 void  CS_LDK_FundingCreated_set_funding_output_index(int64_t this_ptr, int16_t val) {
39848         LDKFundingCreated this_ptr_conv;
39849         this_ptr_conv.inner = untag_ptr(this_ptr);
39850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39852         this_ptr_conv.is_owned = false;
39853         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
39854 }
39855
39856 int8_tArray  CS_LDK_FundingCreated_get_signature(int64_t this_ptr) {
39857         LDKFundingCreated this_ptr_conv;
39858         this_ptr_conv.inner = untag_ptr(this_ptr);
39859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39861         this_ptr_conv.is_owned = false;
39862         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
39863         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
39864         return ret_arr;
39865 }
39866
39867 void  CS_LDK_FundingCreated_set_signature(int64_t this_ptr, int8_tArray val) {
39868         LDKFundingCreated this_ptr_conv;
39869         this_ptr_conv.inner = untag_ptr(this_ptr);
39870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39872         this_ptr_conv.is_owned = false;
39873         LDKECDSASignature val_ref;
39874         CHECK(val->arr_len == 64);
39875         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
39876         FundingCreated_set_signature(&this_ptr_conv, val_ref);
39877 }
39878
39879 int64_t  CS_LDK_FundingCreated_new(int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
39880         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
39881         CHECK(temporary_channel_id_arg->arr_len == 32);
39882         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
39883         LDKThirtyTwoBytes funding_txid_arg_ref;
39884         CHECK(funding_txid_arg->arr_len == 32);
39885         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
39886         LDKECDSASignature signature_arg_ref;
39887         CHECK(signature_arg->arr_len == 64);
39888         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
39889         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
39890         int64_t ret_ref = 0;
39891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39892         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39893         return ret_ref;
39894 }
39895
39896 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
39897         LDKFundingCreated ret_var = FundingCreated_clone(arg);
39898         int64_t ret_ref = 0;
39899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39901         return ret_ref;
39902 }
39903 int64_t  CS_LDK_FundingCreated_clone_ptr(int64_t arg) {
39904         LDKFundingCreated arg_conv;
39905         arg_conv.inner = untag_ptr(arg);
39906         arg_conv.is_owned = ptr_is_owned(arg);
39907         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39908         arg_conv.is_owned = false;
39909         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
39910         return ret_conv;
39911 }
39912
39913 int64_t  CS_LDK_FundingCreated_clone(int64_t orig) {
39914         LDKFundingCreated orig_conv;
39915         orig_conv.inner = untag_ptr(orig);
39916         orig_conv.is_owned = ptr_is_owned(orig);
39917         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39918         orig_conv.is_owned = false;
39919         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
39920         int64_t ret_ref = 0;
39921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39923         return ret_ref;
39924 }
39925
39926 jboolean  CS_LDK_FundingCreated_eq(int64_t a, int64_t b) {
39927         LDKFundingCreated a_conv;
39928         a_conv.inner = untag_ptr(a);
39929         a_conv.is_owned = ptr_is_owned(a);
39930         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39931         a_conv.is_owned = false;
39932         LDKFundingCreated b_conv;
39933         b_conv.inner = untag_ptr(b);
39934         b_conv.is_owned = ptr_is_owned(b);
39935         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39936         b_conv.is_owned = false;
39937         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
39938         return ret_conv;
39939 }
39940
39941 void  CS_LDK_FundingSigned_free(int64_t this_obj) {
39942         LDKFundingSigned this_obj_conv;
39943         this_obj_conv.inner = untag_ptr(this_obj);
39944         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39946         FundingSigned_free(this_obj_conv);
39947 }
39948
39949 int8_tArray  CS_LDK_FundingSigned_get_channel_id(int64_t this_ptr) {
39950         LDKFundingSigned this_ptr_conv;
39951         this_ptr_conv.inner = untag_ptr(this_ptr);
39952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39954         this_ptr_conv.is_owned = false;
39955         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39956         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
39957         return ret_arr;
39958 }
39959
39960 void  CS_LDK_FundingSigned_set_channel_id(int64_t this_ptr, int8_tArray val) {
39961         LDKFundingSigned this_ptr_conv;
39962         this_ptr_conv.inner = untag_ptr(this_ptr);
39963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39965         this_ptr_conv.is_owned = false;
39966         LDKThirtyTwoBytes val_ref;
39967         CHECK(val->arr_len == 32);
39968         memcpy(val_ref.data, val->elems, 32); FREE(val);
39969         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
39970 }
39971
39972 int8_tArray  CS_LDK_FundingSigned_get_signature(int64_t this_ptr) {
39973         LDKFundingSigned this_ptr_conv;
39974         this_ptr_conv.inner = untag_ptr(this_ptr);
39975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39977         this_ptr_conv.is_owned = false;
39978         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
39979         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
39980         return ret_arr;
39981 }
39982
39983 void  CS_LDK_FundingSigned_set_signature(int64_t this_ptr, int8_tArray val) {
39984         LDKFundingSigned this_ptr_conv;
39985         this_ptr_conv.inner = untag_ptr(this_ptr);
39986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39988         this_ptr_conv.is_owned = false;
39989         LDKECDSASignature val_ref;
39990         CHECK(val->arr_len == 64);
39991         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
39992         FundingSigned_set_signature(&this_ptr_conv, val_ref);
39993 }
39994
39995 int64_t  CS_LDK_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
39996         LDKThirtyTwoBytes channel_id_arg_ref;
39997         CHECK(channel_id_arg->arr_len == 32);
39998         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
39999         LDKECDSASignature signature_arg_ref;
40000         CHECK(signature_arg->arr_len == 64);
40001         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
40002         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
40003         int64_t ret_ref = 0;
40004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40006         return ret_ref;
40007 }
40008
40009 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
40010         LDKFundingSigned ret_var = FundingSigned_clone(arg);
40011         int64_t ret_ref = 0;
40012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40013         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40014         return ret_ref;
40015 }
40016 int64_t  CS_LDK_FundingSigned_clone_ptr(int64_t arg) {
40017         LDKFundingSigned arg_conv;
40018         arg_conv.inner = untag_ptr(arg);
40019         arg_conv.is_owned = ptr_is_owned(arg);
40020         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40021         arg_conv.is_owned = false;
40022         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
40023         return ret_conv;
40024 }
40025
40026 int64_t  CS_LDK_FundingSigned_clone(int64_t orig) {
40027         LDKFundingSigned orig_conv;
40028         orig_conv.inner = untag_ptr(orig);
40029         orig_conv.is_owned = ptr_is_owned(orig);
40030         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40031         orig_conv.is_owned = false;
40032         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
40033         int64_t ret_ref = 0;
40034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40035         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40036         return ret_ref;
40037 }
40038
40039 jboolean  CS_LDK_FundingSigned_eq(int64_t a, int64_t b) {
40040         LDKFundingSigned a_conv;
40041         a_conv.inner = untag_ptr(a);
40042         a_conv.is_owned = ptr_is_owned(a);
40043         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40044         a_conv.is_owned = false;
40045         LDKFundingSigned b_conv;
40046         b_conv.inner = untag_ptr(b);
40047         b_conv.is_owned = ptr_is_owned(b);
40048         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40049         b_conv.is_owned = false;
40050         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
40051         return ret_conv;
40052 }
40053
40054 void  CS_LDK_ChannelReady_free(int64_t this_obj) {
40055         LDKChannelReady this_obj_conv;
40056         this_obj_conv.inner = untag_ptr(this_obj);
40057         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40059         ChannelReady_free(this_obj_conv);
40060 }
40061
40062 int8_tArray  CS_LDK_ChannelReady_get_channel_id(int64_t this_ptr) {
40063         LDKChannelReady this_ptr_conv;
40064         this_ptr_conv.inner = untag_ptr(this_ptr);
40065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40067         this_ptr_conv.is_owned = false;
40068         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40069         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
40070         return ret_arr;
40071 }
40072
40073 void  CS_LDK_ChannelReady_set_channel_id(int64_t this_ptr, int8_tArray val) {
40074         LDKChannelReady this_ptr_conv;
40075         this_ptr_conv.inner = untag_ptr(this_ptr);
40076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40078         this_ptr_conv.is_owned = false;
40079         LDKThirtyTwoBytes val_ref;
40080         CHECK(val->arr_len == 32);
40081         memcpy(val_ref.data, val->elems, 32); FREE(val);
40082         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
40083 }
40084
40085 int8_tArray  CS_LDK_ChannelReady_get_next_per_commitment_point(int64_t this_ptr) {
40086         LDKChannelReady this_ptr_conv;
40087         this_ptr_conv.inner = untag_ptr(this_ptr);
40088         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40090         this_ptr_conv.is_owned = false;
40091         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40092         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
40093         return ret_arr;
40094 }
40095
40096 void  CS_LDK_ChannelReady_set_next_per_commitment_point(int64_t this_ptr, int8_tArray val) {
40097         LDKChannelReady this_ptr_conv;
40098         this_ptr_conv.inner = untag_ptr(this_ptr);
40099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40101         this_ptr_conv.is_owned = false;
40102         LDKPublicKey val_ref;
40103         CHECK(val->arr_len == 33);
40104         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40105         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
40106 }
40107
40108 int64_t  CS_LDK_ChannelReady_get_short_channel_id_alias(int64_t this_ptr) {
40109         LDKChannelReady this_ptr_conv;
40110         this_ptr_conv.inner = untag_ptr(this_ptr);
40111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40113         this_ptr_conv.is_owned = false;
40114         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40115         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
40116         int64_t ret_ref = tag_ptr(ret_copy, true);
40117         return ret_ref;
40118 }
40119
40120 void  CS_LDK_ChannelReady_set_short_channel_id_alias(int64_t this_ptr, int64_t val) {
40121         LDKChannelReady this_ptr_conv;
40122         this_ptr_conv.inner = untag_ptr(this_ptr);
40123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40125         this_ptr_conv.is_owned = false;
40126         void* val_ptr = untag_ptr(val);
40127         CHECK_ACCESS(val_ptr);
40128         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40129         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
40130         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
40131 }
40132
40133 int64_t  CS_LDK_ChannelReady_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
40134         LDKThirtyTwoBytes channel_id_arg_ref;
40135         CHECK(channel_id_arg->arr_len == 32);
40136         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40137         LDKPublicKey next_per_commitment_point_arg_ref;
40138         CHECK(next_per_commitment_point_arg->arr_len == 33);
40139         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
40140         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
40141         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
40142         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
40143         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
40144         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
40145         int64_t ret_ref = 0;
40146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40147         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40148         return ret_ref;
40149 }
40150
40151 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
40152         LDKChannelReady ret_var = ChannelReady_clone(arg);
40153         int64_t ret_ref = 0;
40154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40155         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40156         return ret_ref;
40157 }
40158 int64_t  CS_LDK_ChannelReady_clone_ptr(int64_t arg) {
40159         LDKChannelReady arg_conv;
40160         arg_conv.inner = untag_ptr(arg);
40161         arg_conv.is_owned = ptr_is_owned(arg);
40162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40163         arg_conv.is_owned = false;
40164         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
40165         return ret_conv;
40166 }
40167
40168 int64_t  CS_LDK_ChannelReady_clone(int64_t orig) {
40169         LDKChannelReady orig_conv;
40170         orig_conv.inner = untag_ptr(orig);
40171         orig_conv.is_owned = ptr_is_owned(orig);
40172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40173         orig_conv.is_owned = false;
40174         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
40175         int64_t ret_ref = 0;
40176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40177         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40178         return ret_ref;
40179 }
40180
40181 jboolean  CS_LDK_ChannelReady_eq(int64_t a, int64_t b) {
40182         LDKChannelReady a_conv;
40183         a_conv.inner = untag_ptr(a);
40184         a_conv.is_owned = ptr_is_owned(a);
40185         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40186         a_conv.is_owned = false;
40187         LDKChannelReady b_conv;
40188         b_conv.inner = untag_ptr(b);
40189         b_conv.is_owned = ptr_is_owned(b);
40190         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40191         b_conv.is_owned = false;
40192         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
40193         return ret_conv;
40194 }
40195
40196 void  CS_LDK_TxAddInput_free(int64_t this_obj) {
40197         LDKTxAddInput this_obj_conv;
40198         this_obj_conv.inner = untag_ptr(this_obj);
40199         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40201         TxAddInput_free(this_obj_conv);
40202 }
40203
40204 int8_tArray  CS_LDK_TxAddInput_get_channel_id(int64_t this_ptr) {
40205         LDKTxAddInput this_ptr_conv;
40206         this_ptr_conv.inner = untag_ptr(this_ptr);
40207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40209         this_ptr_conv.is_owned = false;
40210         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40211         memcpy(ret_arr->elems, *TxAddInput_get_channel_id(&this_ptr_conv), 32);
40212         return ret_arr;
40213 }
40214
40215 void  CS_LDK_TxAddInput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40216         LDKTxAddInput this_ptr_conv;
40217         this_ptr_conv.inner = untag_ptr(this_ptr);
40218         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40220         this_ptr_conv.is_owned = false;
40221         LDKThirtyTwoBytes val_ref;
40222         CHECK(val->arr_len == 32);
40223         memcpy(val_ref.data, val->elems, 32); FREE(val);
40224         TxAddInput_set_channel_id(&this_ptr_conv, val_ref);
40225 }
40226
40227 int64_t  CS_LDK_TxAddInput_get_serial_id(int64_t this_ptr) {
40228         LDKTxAddInput this_ptr_conv;
40229         this_ptr_conv.inner = untag_ptr(this_ptr);
40230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40232         this_ptr_conv.is_owned = false;
40233         int64_t ret_conv = TxAddInput_get_serial_id(&this_ptr_conv);
40234         return ret_conv;
40235 }
40236
40237 void  CS_LDK_TxAddInput_set_serial_id(int64_t this_ptr, int64_t val) {
40238         LDKTxAddInput this_ptr_conv;
40239         this_ptr_conv.inner = untag_ptr(this_ptr);
40240         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40242         this_ptr_conv.is_owned = false;
40243         TxAddInput_set_serial_id(&this_ptr_conv, val);
40244 }
40245
40246 int64_t  CS_LDK_TxAddInput_get_prevtx(int64_t this_ptr) {
40247         LDKTxAddInput this_ptr_conv;
40248         this_ptr_conv.inner = untag_ptr(this_ptr);
40249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40251         this_ptr_conv.is_owned = false;
40252         LDKTransactionU16LenLimited ret_var = TxAddInput_get_prevtx(&this_ptr_conv);
40253         int64_t ret_ref = 0;
40254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40256         return ret_ref;
40257 }
40258
40259 void  CS_LDK_TxAddInput_set_prevtx(int64_t this_ptr, int64_t val) {
40260         LDKTxAddInput this_ptr_conv;
40261         this_ptr_conv.inner = untag_ptr(this_ptr);
40262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40264         this_ptr_conv.is_owned = false;
40265         LDKTransactionU16LenLimited val_conv;
40266         val_conv.inner = untag_ptr(val);
40267         val_conv.is_owned = ptr_is_owned(val);
40268         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40269         val_conv = TransactionU16LenLimited_clone(&val_conv);
40270         TxAddInput_set_prevtx(&this_ptr_conv, val_conv);
40271 }
40272
40273 int32_t  CS_LDK_TxAddInput_get_prevtx_out(int64_t this_ptr) {
40274         LDKTxAddInput this_ptr_conv;
40275         this_ptr_conv.inner = untag_ptr(this_ptr);
40276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40278         this_ptr_conv.is_owned = false;
40279         int32_t ret_conv = TxAddInput_get_prevtx_out(&this_ptr_conv);
40280         return ret_conv;
40281 }
40282
40283 void  CS_LDK_TxAddInput_set_prevtx_out(int64_t this_ptr, int32_t val) {
40284         LDKTxAddInput this_ptr_conv;
40285         this_ptr_conv.inner = untag_ptr(this_ptr);
40286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40288         this_ptr_conv.is_owned = false;
40289         TxAddInput_set_prevtx_out(&this_ptr_conv, val);
40290 }
40291
40292 int32_t  CS_LDK_TxAddInput_get_sequence(int64_t this_ptr) {
40293         LDKTxAddInput this_ptr_conv;
40294         this_ptr_conv.inner = untag_ptr(this_ptr);
40295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40297         this_ptr_conv.is_owned = false;
40298         int32_t ret_conv = TxAddInput_get_sequence(&this_ptr_conv);
40299         return ret_conv;
40300 }
40301
40302 void  CS_LDK_TxAddInput_set_sequence(int64_t this_ptr, int32_t val) {
40303         LDKTxAddInput this_ptr_conv;
40304         this_ptr_conv.inner = untag_ptr(this_ptr);
40305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40307         this_ptr_conv.is_owned = false;
40308         TxAddInput_set_sequence(&this_ptr_conv, val);
40309 }
40310
40311 int64_t  CS_LDK_TxAddInput_new(int8_tArray channel_id_arg, int64_t serial_id_arg, int64_t prevtx_arg, int32_t prevtx_out_arg, int32_t sequence_arg) {
40312         LDKThirtyTwoBytes channel_id_arg_ref;
40313         CHECK(channel_id_arg->arr_len == 32);
40314         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40315         LDKTransactionU16LenLimited prevtx_arg_conv;
40316         prevtx_arg_conv.inner = untag_ptr(prevtx_arg);
40317         prevtx_arg_conv.is_owned = ptr_is_owned(prevtx_arg);
40318         CHECK_INNER_FIELD_ACCESS_OR_NULL(prevtx_arg_conv);
40319         prevtx_arg_conv = TransactionU16LenLimited_clone(&prevtx_arg_conv);
40320         LDKTxAddInput ret_var = TxAddInput_new(channel_id_arg_ref, serial_id_arg, prevtx_arg_conv, prevtx_out_arg, sequence_arg);
40321         int64_t ret_ref = 0;
40322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40323         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40324         return ret_ref;
40325 }
40326
40327 static inline uint64_t TxAddInput_clone_ptr(LDKTxAddInput *NONNULL_PTR arg) {
40328         LDKTxAddInput ret_var = TxAddInput_clone(arg);
40329         int64_t ret_ref = 0;
40330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40332         return ret_ref;
40333 }
40334 int64_t  CS_LDK_TxAddInput_clone_ptr(int64_t arg) {
40335         LDKTxAddInput arg_conv;
40336         arg_conv.inner = untag_ptr(arg);
40337         arg_conv.is_owned = ptr_is_owned(arg);
40338         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40339         arg_conv.is_owned = false;
40340         int64_t ret_conv = TxAddInput_clone_ptr(&arg_conv);
40341         return ret_conv;
40342 }
40343
40344 int64_t  CS_LDK_TxAddInput_clone(int64_t orig) {
40345         LDKTxAddInput orig_conv;
40346         orig_conv.inner = untag_ptr(orig);
40347         orig_conv.is_owned = ptr_is_owned(orig);
40348         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40349         orig_conv.is_owned = false;
40350         LDKTxAddInput ret_var = TxAddInput_clone(&orig_conv);
40351         int64_t ret_ref = 0;
40352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40353         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40354         return ret_ref;
40355 }
40356
40357 jboolean  CS_LDK_TxAddInput_eq(int64_t a, int64_t b) {
40358         LDKTxAddInput a_conv;
40359         a_conv.inner = untag_ptr(a);
40360         a_conv.is_owned = ptr_is_owned(a);
40361         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40362         a_conv.is_owned = false;
40363         LDKTxAddInput b_conv;
40364         b_conv.inner = untag_ptr(b);
40365         b_conv.is_owned = ptr_is_owned(b);
40366         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40367         b_conv.is_owned = false;
40368         jboolean ret_conv = TxAddInput_eq(&a_conv, &b_conv);
40369         return ret_conv;
40370 }
40371
40372 void  CS_LDK_TxAddOutput_free(int64_t this_obj) {
40373         LDKTxAddOutput this_obj_conv;
40374         this_obj_conv.inner = untag_ptr(this_obj);
40375         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40377         TxAddOutput_free(this_obj_conv);
40378 }
40379
40380 int8_tArray  CS_LDK_TxAddOutput_get_channel_id(int64_t this_ptr) {
40381         LDKTxAddOutput this_ptr_conv;
40382         this_ptr_conv.inner = untag_ptr(this_ptr);
40383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40385         this_ptr_conv.is_owned = false;
40386         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40387         memcpy(ret_arr->elems, *TxAddOutput_get_channel_id(&this_ptr_conv), 32);
40388         return ret_arr;
40389 }
40390
40391 void  CS_LDK_TxAddOutput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40392         LDKTxAddOutput this_ptr_conv;
40393         this_ptr_conv.inner = untag_ptr(this_ptr);
40394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40396         this_ptr_conv.is_owned = false;
40397         LDKThirtyTwoBytes val_ref;
40398         CHECK(val->arr_len == 32);
40399         memcpy(val_ref.data, val->elems, 32); FREE(val);
40400         TxAddOutput_set_channel_id(&this_ptr_conv, val_ref);
40401 }
40402
40403 int64_t  CS_LDK_TxAddOutput_get_serial_id(int64_t this_ptr) {
40404         LDKTxAddOutput this_ptr_conv;
40405         this_ptr_conv.inner = untag_ptr(this_ptr);
40406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40408         this_ptr_conv.is_owned = false;
40409         int64_t ret_conv = TxAddOutput_get_serial_id(&this_ptr_conv);
40410         return ret_conv;
40411 }
40412
40413 void  CS_LDK_TxAddOutput_set_serial_id(int64_t this_ptr, int64_t val) {
40414         LDKTxAddOutput this_ptr_conv;
40415         this_ptr_conv.inner = untag_ptr(this_ptr);
40416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40418         this_ptr_conv.is_owned = false;
40419         TxAddOutput_set_serial_id(&this_ptr_conv, val);
40420 }
40421
40422 int64_t  CS_LDK_TxAddOutput_get_sats(int64_t this_ptr) {
40423         LDKTxAddOutput this_ptr_conv;
40424         this_ptr_conv.inner = untag_ptr(this_ptr);
40425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40427         this_ptr_conv.is_owned = false;
40428         int64_t ret_conv = TxAddOutput_get_sats(&this_ptr_conv);
40429         return ret_conv;
40430 }
40431
40432 void  CS_LDK_TxAddOutput_set_sats(int64_t this_ptr, int64_t val) {
40433         LDKTxAddOutput this_ptr_conv;
40434         this_ptr_conv.inner = untag_ptr(this_ptr);
40435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40437         this_ptr_conv.is_owned = false;
40438         TxAddOutput_set_sats(&this_ptr_conv, val);
40439 }
40440
40441 int8_tArray  CS_LDK_TxAddOutput_get_script(int64_t this_ptr) {
40442         LDKTxAddOutput this_ptr_conv;
40443         this_ptr_conv.inner = untag_ptr(this_ptr);
40444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40446         this_ptr_conv.is_owned = false;
40447         LDKu8slice ret_var = TxAddOutput_get_script(&this_ptr_conv);
40448         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40449         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40450         return ret_arr;
40451 }
40452
40453 void  CS_LDK_TxAddOutput_set_script(int64_t this_ptr, int8_tArray val) {
40454         LDKTxAddOutput this_ptr_conv;
40455         this_ptr_conv.inner = untag_ptr(this_ptr);
40456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40458         this_ptr_conv.is_owned = false;
40459         LDKCVec_u8Z val_ref;
40460         val_ref.datalen = val->arr_len;
40461         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
40462         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
40463         TxAddOutput_set_script(&this_ptr_conv, val_ref);
40464 }
40465
40466 int64_t  CS_LDK_TxAddOutput_new(int8_tArray channel_id_arg, int64_t serial_id_arg, int64_t sats_arg, int8_tArray script_arg) {
40467         LDKThirtyTwoBytes channel_id_arg_ref;
40468         CHECK(channel_id_arg->arr_len == 32);
40469         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40470         LDKCVec_u8Z script_arg_ref;
40471         script_arg_ref.datalen = script_arg->arr_len;
40472         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
40473         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
40474         LDKTxAddOutput ret_var = TxAddOutput_new(channel_id_arg_ref, serial_id_arg, sats_arg, script_arg_ref);
40475         int64_t ret_ref = 0;
40476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40478         return ret_ref;
40479 }
40480
40481 static inline uint64_t TxAddOutput_clone_ptr(LDKTxAddOutput *NONNULL_PTR arg) {
40482         LDKTxAddOutput ret_var = TxAddOutput_clone(arg);
40483         int64_t ret_ref = 0;
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40485         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40486         return ret_ref;
40487 }
40488 int64_t  CS_LDK_TxAddOutput_clone_ptr(int64_t arg) {
40489         LDKTxAddOutput arg_conv;
40490         arg_conv.inner = untag_ptr(arg);
40491         arg_conv.is_owned = ptr_is_owned(arg);
40492         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40493         arg_conv.is_owned = false;
40494         int64_t ret_conv = TxAddOutput_clone_ptr(&arg_conv);
40495         return ret_conv;
40496 }
40497
40498 int64_t  CS_LDK_TxAddOutput_clone(int64_t orig) {
40499         LDKTxAddOutput orig_conv;
40500         orig_conv.inner = untag_ptr(orig);
40501         orig_conv.is_owned = ptr_is_owned(orig);
40502         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40503         orig_conv.is_owned = false;
40504         LDKTxAddOutput ret_var = TxAddOutput_clone(&orig_conv);
40505         int64_t ret_ref = 0;
40506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40508         return ret_ref;
40509 }
40510
40511 jboolean  CS_LDK_TxAddOutput_eq(int64_t a, int64_t b) {
40512         LDKTxAddOutput a_conv;
40513         a_conv.inner = untag_ptr(a);
40514         a_conv.is_owned = ptr_is_owned(a);
40515         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40516         a_conv.is_owned = false;
40517         LDKTxAddOutput b_conv;
40518         b_conv.inner = untag_ptr(b);
40519         b_conv.is_owned = ptr_is_owned(b);
40520         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40521         b_conv.is_owned = false;
40522         jboolean ret_conv = TxAddOutput_eq(&a_conv, &b_conv);
40523         return ret_conv;
40524 }
40525
40526 void  CS_LDK_TxRemoveInput_free(int64_t this_obj) {
40527         LDKTxRemoveInput this_obj_conv;
40528         this_obj_conv.inner = untag_ptr(this_obj);
40529         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40531         TxRemoveInput_free(this_obj_conv);
40532 }
40533
40534 int8_tArray  CS_LDK_TxRemoveInput_get_channel_id(int64_t this_ptr) {
40535         LDKTxRemoveInput this_ptr_conv;
40536         this_ptr_conv.inner = untag_ptr(this_ptr);
40537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40539         this_ptr_conv.is_owned = false;
40540         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40541         memcpy(ret_arr->elems, *TxRemoveInput_get_channel_id(&this_ptr_conv), 32);
40542         return ret_arr;
40543 }
40544
40545 void  CS_LDK_TxRemoveInput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40546         LDKTxRemoveInput this_ptr_conv;
40547         this_ptr_conv.inner = untag_ptr(this_ptr);
40548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40550         this_ptr_conv.is_owned = false;
40551         LDKThirtyTwoBytes val_ref;
40552         CHECK(val->arr_len == 32);
40553         memcpy(val_ref.data, val->elems, 32); FREE(val);
40554         TxRemoveInput_set_channel_id(&this_ptr_conv, val_ref);
40555 }
40556
40557 int64_t  CS_LDK_TxRemoveInput_get_serial_id(int64_t this_ptr) {
40558         LDKTxRemoveInput this_ptr_conv;
40559         this_ptr_conv.inner = untag_ptr(this_ptr);
40560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40562         this_ptr_conv.is_owned = false;
40563         int64_t ret_conv = TxRemoveInput_get_serial_id(&this_ptr_conv);
40564         return ret_conv;
40565 }
40566
40567 void  CS_LDK_TxRemoveInput_set_serial_id(int64_t this_ptr, int64_t val) {
40568         LDKTxRemoveInput this_ptr_conv;
40569         this_ptr_conv.inner = untag_ptr(this_ptr);
40570         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40572         this_ptr_conv.is_owned = false;
40573         TxRemoveInput_set_serial_id(&this_ptr_conv, val);
40574 }
40575
40576 int64_t  CS_LDK_TxRemoveInput_new(int8_tArray channel_id_arg, int64_t serial_id_arg) {
40577         LDKThirtyTwoBytes channel_id_arg_ref;
40578         CHECK(channel_id_arg->arr_len == 32);
40579         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40580         LDKTxRemoveInput ret_var = TxRemoveInput_new(channel_id_arg_ref, serial_id_arg);
40581         int64_t ret_ref = 0;
40582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40584         return ret_ref;
40585 }
40586
40587 static inline uint64_t TxRemoveInput_clone_ptr(LDKTxRemoveInput *NONNULL_PTR arg) {
40588         LDKTxRemoveInput ret_var = TxRemoveInput_clone(arg);
40589         int64_t ret_ref = 0;
40590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40592         return ret_ref;
40593 }
40594 int64_t  CS_LDK_TxRemoveInput_clone_ptr(int64_t arg) {
40595         LDKTxRemoveInput arg_conv;
40596         arg_conv.inner = untag_ptr(arg);
40597         arg_conv.is_owned = ptr_is_owned(arg);
40598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40599         arg_conv.is_owned = false;
40600         int64_t ret_conv = TxRemoveInput_clone_ptr(&arg_conv);
40601         return ret_conv;
40602 }
40603
40604 int64_t  CS_LDK_TxRemoveInput_clone(int64_t orig) {
40605         LDKTxRemoveInput orig_conv;
40606         orig_conv.inner = untag_ptr(orig);
40607         orig_conv.is_owned = ptr_is_owned(orig);
40608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40609         orig_conv.is_owned = false;
40610         LDKTxRemoveInput ret_var = TxRemoveInput_clone(&orig_conv);
40611         int64_t ret_ref = 0;
40612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40614         return ret_ref;
40615 }
40616
40617 jboolean  CS_LDK_TxRemoveInput_eq(int64_t a, int64_t b) {
40618         LDKTxRemoveInput a_conv;
40619         a_conv.inner = untag_ptr(a);
40620         a_conv.is_owned = ptr_is_owned(a);
40621         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40622         a_conv.is_owned = false;
40623         LDKTxRemoveInput b_conv;
40624         b_conv.inner = untag_ptr(b);
40625         b_conv.is_owned = ptr_is_owned(b);
40626         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40627         b_conv.is_owned = false;
40628         jboolean ret_conv = TxRemoveInput_eq(&a_conv, &b_conv);
40629         return ret_conv;
40630 }
40631
40632 void  CS_LDK_TxRemoveOutput_free(int64_t this_obj) {
40633         LDKTxRemoveOutput this_obj_conv;
40634         this_obj_conv.inner = untag_ptr(this_obj);
40635         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40637         TxRemoveOutput_free(this_obj_conv);
40638 }
40639
40640 int8_tArray  CS_LDK_TxRemoveOutput_get_channel_id(int64_t this_ptr) {
40641         LDKTxRemoveOutput this_ptr_conv;
40642         this_ptr_conv.inner = untag_ptr(this_ptr);
40643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40645         this_ptr_conv.is_owned = false;
40646         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40647         memcpy(ret_arr->elems, *TxRemoveOutput_get_channel_id(&this_ptr_conv), 32);
40648         return ret_arr;
40649 }
40650
40651 void  CS_LDK_TxRemoveOutput_set_channel_id(int64_t this_ptr, int8_tArray val) {
40652         LDKTxRemoveOutput this_ptr_conv;
40653         this_ptr_conv.inner = untag_ptr(this_ptr);
40654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40656         this_ptr_conv.is_owned = false;
40657         LDKThirtyTwoBytes val_ref;
40658         CHECK(val->arr_len == 32);
40659         memcpy(val_ref.data, val->elems, 32); FREE(val);
40660         TxRemoveOutput_set_channel_id(&this_ptr_conv, val_ref);
40661 }
40662
40663 int64_t  CS_LDK_TxRemoveOutput_get_serial_id(int64_t this_ptr) {
40664         LDKTxRemoveOutput this_ptr_conv;
40665         this_ptr_conv.inner = untag_ptr(this_ptr);
40666         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40668         this_ptr_conv.is_owned = false;
40669         int64_t ret_conv = TxRemoveOutput_get_serial_id(&this_ptr_conv);
40670         return ret_conv;
40671 }
40672
40673 void  CS_LDK_TxRemoveOutput_set_serial_id(int64_t this_ptr, int64_t val) {
40674         LDKTxRemoveOutput this_ptr_conv;
40675         this_ptr_conv.inner = untag_ptr(this_ptr);
40676         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40678         this_ptr_conv.is_owned = false;
40679         TxRemoveOutput_set_serial_id(&this_ptr_conv, val);
40680 }
40681
40682 int64_t  CS_LDK_TxRemoveOutput_new(int8_tArray channel_id_arg, int64_t serial_id_arg) {
40683         LDKThirtyTwoBytes channel_id_arg_ref;
40684         CHECK(channel_id_arg->arr_len == 32);
40685         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40686         LDKTxRemoveOutput ret_var = TxRemoveOutput_new(channel_id_arg_ref, serial_id_arg);
40687         int64_t ret_ref = 0;
40688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40690         return ret_ref;
40691 }
40692
40693 static inline uint64_t TxRemoveOutput_clone_ptr(LDKTxRemoveOutput *NONNULL_PTR arg) {
40694         LDKTxRemoveOutput ret_var = TxRemoveOutput_clone(arg);
40695         int64_t ret_ref = 0;
40696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40698         return ret_ref;
40699 }
40700 int64_t  CS_LDK_TxRemoveOutput_clone_ptr(int64_t arg) {
40701         LDKTxRemoveOutput arg_conv;
40702         arg_conv.inner = untag_ptr(arg);
40703         arg_conv.is_owned = ptr_is_owned(arg);
40704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40705         arg_conv.is_owned = false;
40706         int64_t ret_conv = TxRemoveOutput_clone_ptr(&arg_conv);
40707         return ret_conv;
40708 }
40709
40710 int64_t  CS_LDK_TxRemoveOutput_clone(int64_t orig) {
40711         LDKTxRemoveOutput orig_conv;
40712         orig_conv.inner = untag_ptr(orig);
40713         orig_conv.is_owned = ptr_is_owned(orig);
40714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40715         orig_conv.is_owned = false;
40716         LDKTxRemoveOutput ret_var = TxRemoveOutput_clone(&orig_conv);
40717         int64_t ret_ref = 0;
40718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40720         return ret_ref;
40721 }
40722
40723 jboolean  CS_LDK_TxRemoveOutput_eq(int64_t a, int64_t b) {
40724         LDKTxRemoveOutput a_conv;
40725         a_conv.inner = untag_ptr(a);
40726         a_conv.is_owned = ptr_is_owned(a);
40727         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40728         a_conv.is_owned = false;
40729         LDKTxRemoveOutput b_conv;
40730         b_conv.inner = untag_ptr(b);
40731         b_conv.is_owned = ptr_is_owned(b);
40732         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40733         b_conv.is_owned = false;
40734         jboolean ret_conv = TxRemoveOutput_eq(&a_conv, &b_conv);
40735         return ret_conv;
40736 }
40737
40738 void  CS_LDK_TxComplete_free(int64_t this_obj) {
40739         LDKTxComplete this_obj_conv;
40740         this_obj_conv.inner = untag_ptr(this_obj);
40741         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40743         TxComplete_free(this_obj_conv);
40744 }
40745
40746 int8_tArray  CS_LDK_TxComplete_get_channel_id(int64_t this_ptr) {
40747         LDKTxComplete this_ptr_conv;
40748         this_ptr_conv.inner = untag_ptr(this_ptr);
40749         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40751         this_ptr_conv.is_owned = false;
40752         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40753         memcpy(ret_arr->elems, *TxComplete_get_channel_id(&this_ptr_conv), 32);
40754         return ret_arr;
40755 }
40756
40757 void  CS_LDK_TxComplete_set_channel_id(int64_t this_ptr, int8_tArray val) {
40758         LDKTxComplete this_ptr_conv;
40759         this_ptr_conv.inner = untag_ptr(this_ptr);
40760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40762         this_ptr_conv.is_owned = false;
40763         LDKThirtyTwoBytes val_ref;
40764         CHECK(val->arr_len == 32);
40765         memcpy(val_ref.data, val->elems, 32); FREE(val);
40766         TxComplete_set_channel_id(&this_ptr_conv, val_ref);
40767 }
40768
40769 int64_t  CS_LDK_TxComplete_new(int8_tArray channel_id_arg) {
40770         LDKThirtyTwoBytes channel_id_arg_ref;
40771         CHECK(channel_id_arg->arr_len == 32);
40772         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40773         LDKTxComplete ret_var = TxComplete_new(channel_id_arg_ref);
40774         int64_t ret_ref = 0;
40775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40777         return ret_ref;
40778 }
40779
40780 static inline uint64_t TxComplete_clone_ptr(LDKTxComplete *NONNULL_PTR arg) {
40781         LDKTxComplete ret_var = TxComplete_clone(arg);
40782         int64_t ret_ref = 0;
40783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40784         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40785         return ret_ref;
40786 }
40787 int64_t  CS_LDK_TxComplete_clone_ptr(int64_t arg) {
40788         LDKTxComplete arg_conv;
40789         arg_conv.inner = untag_ptr(arg);
40790         arg_conv.is_owned = ptr_is_owned(arg);
40791         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40792         arg_conv.is_owned = false;
40793         int64_t ret_conv = TxComplete_clone_ptr(&arg_conv);
40794         return ret_conv;
40795 }
40796
40797 int64_t  CS_LDK_TxComplete_clone(int64_t orig) {
40798         LDKTxComplete orig_conv;
40799         orig_conv.inner = untag_ptr(orig);
40800         orig_conv.is_owned = ptr_is_owned(orig);
40801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40802         orig_conv.is_owned = false;
40803         LDKTxComplete ret_var = TxComplete_clone(&orig_conv);
40804         int64_t ret_ref = 0;
40805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40806         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40807         return ret_ref;
40808 }
40809
40810 jboolean  CS_LDK_TxComplete_eq(int64_t a, int64_t b) {
40811         LDKTxComplete a_conv;
40812         a_conv.inner = untag_ptr(a);
40813         a_conv.is_owned = ptr_is_owned(a);
40814         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40815         a_conv.is_owned = false;
40816         LDKTxComplete b_conv;
40817         b_conv.inner = untag_ptr(b);
40818         b_conv.is_owned = ptr_is_owned(b);
40819         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40820         b_conv.is_owned = false;
40821         jboolean ret_conv = TxComplete_eq(&a_conv, &b_conv);
40822         return ret_conv;
40823 }
40824
40825 void  CS_LDK_TxSignatures_free(int64_t this_obj) {
40826         LDKTxSignatures this_obj_conv;
40827         this_obj_conv.inner = untag_ptr(this_obj);
40828         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40830         TxSignatures_free(this_obj_conv);
40831 }
40832
40833 int8_tArray  CS_LDK_TxSignatures_get_channel_id(int64_t this_ptr) {
40834         LDKTxSignatures this_ptr_conv;
40835         this_ptr_conv.inner = untag_ptr(this_ptr);
40836         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40838         this_ptr_conv.is_owned = false;
40839         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40840         memcpy(ret_arr->elems, *TxSignatures_get_channel_id(&this_ptr_conv), 32);
40841         return ret_arr;
40842 }
40843
40844 void  CS_LDK_TxSignatures_set_channel_id(int64_t this_ptr, int8_tArray val) {
40845         LDKTxSignatures this_ptr_conv;
40846         this_ptr_conv.inner = untag_ptr(this_ptr);
40847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40849         this_ptr_conv.is_owned = false;
40850         LDKThirtyTwoBytes val_ref;
40851         CHECK(val->arr_len == 32);
40852         memcpy(val_ref.data, val->elems, 32); FREE(val);
40853         TxSignatures_set_channel_id(&this_ptr_conv, val_ref);
40854 }
40855
40856 int8_tArray  CS_LDK_TxSignatures_get_tx_hash(int64_t this_ptr) {
40857         LDKTxSignatures this_ptr_conv;
40858         this_ptr_conv.inner = untag_ptr(this_ptr);
40859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40861         this_ptr_conv.is_owned = false;
40862         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40863         memcpy(ret_arr->elems, *TxSignatures_get_tx_hash(&this_ptr_conv), 32);
40864         return ret_arr;
40865 }
40866
40867 void  CS_LDK_TxSignatures_set_tx_hash(int64_t this_ptr, int8_tArray val) {
40868         LDKTxSignatures this_ptr_conv;
40869         this_ptr_conv.inner = untag_ptr(this_ptr);
40870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40872         this_ptr_conv.is_owned = false;
40873         LDKThirtyTwoBytes val_ref;
40874         CHECK(val->arr_len == 32);
40875         memcpy(val_ref.data, val->elems, 32); FREE(val);
40876         TxSignatures_set_tx_hash(&this_ptr_conv, val_ref);
40877 }
40878
40879 ptrArray  CS_LDK_TxSignatures_get_witnesses(int64_t this_ptr) {
40880         LDKTxSignatures this_ptr_conv;
40881         this_ptr_conv.inner = untag_ptr(this_ptr);
40882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40884         this_ptr_conv.is_owned = false;
40885         LDKCVec_WitnessZ ret_var = TxSignatures_get_witnesses(&this_ptr_conv);
40886         ptrArray ret_arr = NULL;
40887         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
40888         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
40889         for (size_t i = 0; i < ret_var.datalen; i++) {
40890                 LDKWitness ret_conv_8_var = ret_var.data[i];
40891                 int8_tArray ret_conv_8_arr = init_int8_tArray(ret_conv_8_var.datalen, __LINE__);
40892                 memcpy(ret_conv_8_arr->elems, ret_conv_8_var.data, ret_conv_8_var.datalen);
40893                 Witness_free(ret_conv_8_var);
40894                 ret_arr_ptr[i] = ret_conv_8_arr;
40895         }
40896         
40897         FREE(ret_var.data);
40898         return ret_arr;
40899 }
40900
40901 void  CS_LDK_TxSignatures_set_witnesses(int64_t this_ptr, ptrArray val) {
40902         LDKTxSignatures this_ptr_conv;
40903         this_ptr_conv.inner = untag_ptr(this_ptr);
40904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40906         this_ptr_conv.is_owned = false;
40907         LDKCVec_WitnessZ val_constr;
40908         val_constr.datalen = val->arr_len;
40909         if (val_constr.datalen > 0)
40910                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKWitness), "LDKCVec_WitnessZ Elements");
40911         else
40912                 val_constr.data = NULL;
40913         int8_tArray* val_vals = (void*) val->elems;
40914         for (size_t i = 0; i < val_constr.datalen; i++) {
40915                 int8_tArray val_conv_8 = val_vals[i];
40916                 LDKWitness val_conv_8_ref;
40917                 val_conv_8_ref.datalen = val_conv_8->arr_len;
40918                 val_conv_8_ref.data = MALLOC(val_conv_8_ref.datalen, "LDKWitness Bytes");
40919                 memcpy(val_conv_8_ref.data, val_conv_8->elems, val_conv_8_ref.datalen); FREE(val_conv_8);
40920                 val_conv_8_ref.data_is_owned = true;
40921                 val_constr.data[i] = val_conv_8_ref;
40922         }
40923         FREE(val);
40924         TxSignatures_set_witnesses(&this_ptr_conv, val_constr);
40925 }
40926
40927 int64_t  CS_LDK_TxSignatures_new(int8_tArray channel_id_arg, int8_tArray tx_hash_arg, ptrArray witnesses_arg) {
40928         LDKThirtyTwoBytes channel_id_arg_ref;
40929         CHECK(channel_id_arg->arr_len == 32);
40930         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
40931         LDKThirtyTwoBytes tx_hash_arg_ref;
40932         CHECK(tx_hash_arg->arr_len == 32);
40933         memcpy(tx_hash_arg_ref.data, tx_hash_arg->elems, 32); FREE(tx_hash_arg);
40934         LDKCVec_WitnessZ witnesses_arg_constr;
40935         witnesses_arg_constr.datalen = witnesses_arg->arr_len;
40936         if (witnesses_arg_constr.datalen > 0)
40937                 witnesses_arg_constr.data = MALLOC(witnesses_arg_constr.datalen * sizeof(LDKWitness), "LDKCVec_WitnessZ Elements");
40938         else
40939                 witnesses_arg_constr.data = NULL;
40940         int8_tArray* witnesses_arg_vals = (void*) witnesses_arg->elems;
40941         for (size_t i = 0; i < witnesses_arg_constr.datalen; i++) {
40942                 int8_tArray witnesses_arg_conv_8 = witnesses_arg_vals[i];
40943                 LDKWitness witnesses_arg_conv_8_ref;
40944                 witnesses_arg_conv_8_ref.datalen = witnesses_arg_conv_8->arr_len;
40945                 witnesses_arg_conv_8_ref.data = MALLOC(witnesses_arg_conv_8_ref.datalen, "LDKWitness Bytes");
40946                 memcpy(witnesses_arg_conv_8_ref.data, witnesses_arg_conv_8->elems, witnesses_arg_conv_8_ref.datalen); FREE(witnesses_arg_conv_8);
40947                 witnesses_arg_conv_8_ref.data_is_owned = true;
40948                 witnesses_arg_constr.data[i] = witnesses_arg_conv_8_ref;
40949         }
40950         FREE(witnesses_arg);
40951         LDKTxSignatures ret_var = TxSignatures_new(channel_id_arg_ref, tx_hash_arg_ref, witnesses_arg_constr);
40952         int64_t ret_ref = 0;
40953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40955         return ret_ref;
40956 }
40957
40958 static inline uint64_t TxSignatures_clone_ptr(LDKTxSignatures *NONNULL_PTR arg) {
40959         LDKTxSignatures ret_var = TxSignatures_clone(arg);
40960         int64_t ret_ref = 0;
40961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40962         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40963         return ret_ref;
40964 }
40965 int64_t  CS_LDK_TxSignatures_clone_ptr(int64_t arg) {
40966         LDKTxSignatures arg_conv;
40967         arg_conv.inner = untag_ptr(arg);
40968         arg_conv.is_owned = ptr_is_owned(arg);
40969         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40970         arg_conv.is_owned = false;
40971         int64_t ret_conv = TxSignatures_clone_ptr(&arg_conv);
40972         return ret_conv;
40973 }
40974
40975 int64_t  CS_LDK_TxSignatures_clone(int64_t orig) {
40976         LDKTxSignatures orig_conv;
40977         orig_conv.inner = untag_ptr(orig);
40978         orig_conv.is_owned = ptr_is_owned(orig);
40979         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40980         orig_conv.is_owned = false;
40981         LDKTxSignatures ret_var = TxSignatures_clone(&orig_conv);
40982         int64_t ret_ref = 0;
40983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40984         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40985         return ret_ref;
40986 }
40987
40988 jboolean  CS_LDK_TxSignatures_eq(int64_t a, int64_t b) {
40989         LDKTxSignatures a_conv;
40990         a_conv.inner = untag_ptr(a);
40991         a_conv.is_owned = ptr_is_owned(a);
40992         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40993         a_conv.is_owned = false;
40994         LDKTxSignatures b_conv;
40995         b_conv.inner = untag_ptr(b);
40996         b_conv.is_owned = ptr_is_owned(b);
40997         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40998         b_conv.is_owned = false;
40999         jboolean ret_conv = TxSignatures_eq(&a_conv, &b_conv);
41000         return ret_conv;
41001 }
41002
41003 void  CS_LDK_TxInitRbf_free(int64_t this_obj) {
41004         LDKTxInitRbf this_obj_conv;
41005         this_obj_conv.inner = untag_ptr(this_obj);
41006         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41008         TxInitRbf_free(this_obj_conv);
41009 }
41010
41011 int8_tArray  CS_LDK_TxInitRbf_get_channel_id(int64_t this_ptr) {
41012         LDKTxInitRbf this_ptr_conv;
41013         this_ptr_conv.inner = untag_ptr(this_ptr);
41014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41016         this_ptr_conv.is_owned = false;
41017         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41018         memcpy(ret_arr->elems, *TxInitRbf_get_channel_id(&this_ptr_conv), 32);
41019         return ret_arr;
41020 }
41021
41022 void  CS_LDK_TxInitRbf_set_channel_id(int64_t this_ptr, int8_tArray val) {
41023         LDKTxInitRbf this_ptr_conv;
41024         this_ptr_conv.inner = untag_ptr(this_ptr);
41025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41027         this_ptr_conv.is_owned = false;
41028         LDKThirtyTwoBytes val_ref;
41029         CHECK(val->arr_len == 32);
41030         memcpy(val_ref.data, val->elems, 32); FREE(val);
41031         TxInitRbf_set_channel_id(&this_ptr_conv, val_ref);
41032 }
41033
41034 int32_t  CS_LDK_TxInitRbf_get_locktime(int64_t this_ptr) {
41035         LDKTxInitRbf this_ptr_conv;
41036         this_ptr_conv.inner = untag_ptr(this_ptr);
41037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41039         this_ptr_conv.is_owned = false;
41040         int32_t ret_conv = TxInitRbf_get_locktime(&this_ptr_conv);
41041         return ret_conv;
41042 }
41043
41044 void  CS_LDK_TxInitRbf_set_locktime(int64_t this_ptr, int32_t val) {
41045         LDKTxInitRbf this_ptr_conv;
41046         this_ptr_conv.inner = untag_ptr(this_ptr);
41047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41049         this_ptr_conv.is_owned = false;
41050         TxInitRbf_set_locktime(&this_ptr_conv, val);
41051 }
41052
41053 int32_t  CS_LDK_TxInitRbf_get_feerate_sat_per_1000_weight(int64_t this_ptr) {
41054         LDKTxInitRbf this_ptr_conv;
41055         this_ptr_conv.inner = untag_ptr(this_ptr);
41056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41058         this_ptr_conv.is_owned = false;
41059         int32_t ret_conv = TxInitRbf_get_feerate_sat_per_1000_weight(&this_ptr_conv);
41060         return ret_conv;
41061 }
41062
41063 void  CS_LDK_TxInitRbf_set_feerate_sat_per_1000_weight(int64_t this_ptr, int32_t val) {
41064         LDKTxInitRbf this_ptr_conv;
41065         this_ptr_conv.inner = untag_ptr(this_ptr);
41066         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41068         this_ptr_conv.is_owned = false;
41069         TxInitRbf_set_feerate_sat_per_1000_weight(&this_ptr_conv, val);
41070 }
41071
41072 int64_t  CS_LDK_TxInitRbf_get_funding_output_contribution(int64_t this_ptr) {
41073         LDKTxInitRbf this_ptr_conv;
41074         this_ptr_conv.inner = untag_ptr(this_ptr);
41075         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41077         this_ptr_conv.is_owned = false;
41078         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
41079         *ret_copy = TxInitRbf_get_funding_output_contribution(&this_ptr_conv);
41080         int64_t ret_ref = tag_ptr(ret_copy, true);
41081         return ret_ref;
41082 }
41083
41084 void  CS_LDK_TxInitRbf_set_funding_output_contribution(int64_t this_ptr, int64_t val) {
41085         LDKTxInitRbf this_ptr_conv;
41086         this_ptr_conv.inner = untag_ptr(this_ptr);
41087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41089         this_ptr_conv.is_owned = false;
41090         void* val_ptr = untag_ptr(val);
41091         CHECK_ACCESS(val_ptr);
41092         LDKCOption_i64Z val_conv = *(LDKCOption_i64Z*)(val_ptr);
41093         val_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(val));
41094         TxInitRbf_set_funding_output_contribution(&this_ptr_conv, val_conv);
41095 }
41096
41097 int64_t  CS_LDK_TxInitRbf_new(int8_tArray channel_id_arg, int32_t locktime_arg, int32_t feerate_sat_per_1000_weight_arg, int64_t funding_output_contribution_arg) {
41098         LDKThirtyTwoBytes channel_id_arg_ref;
41099         CHECK(channel_id_arg->arr_len == 32);
41100         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41101         void* funding_output_contribution_arg_ptr = untag_ptr(funding_output_contribution_arg);
41102         CHECK_ACCESS(funding_output_contribution_arg_ptr);
41103         LDKCOption_i64Z funding_output_contribution_arg_conv = *(LDKCOption_i64Z*)(funding_output_contribution_arg_ptr);
41104         funding_output_contribution_arg_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(funding_output_contribution_arg));
41105         LDKTxInitRbf ret_var = TxInitRbf_new(channel_id_arg_ref, locktime_arg, feerate_sat_per_1000_weight_arg, funding_output_contribution_arg_conv);
41106         int64_t ret_ref = 0;
41107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41108         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41109         return ret_ref;
41110 }
41111
41112 static inline uint64_t TxInitRbf_clone_ptr(LDKTxInitRbf *NONNULL_PTR arg) {
41113         LDKTxInitRbf ret_var = TxInitRbf_clone(arg);
41114         int64_t ret_ref = 0;
41115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41116         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41117         return ret_ref;
41118 }
41119 int64_t  CS_LDK_TxInitRbf_clone_ptr(int64_t arg) {
41120         LDKTxInitRbf arg_conv;
41121         arg_conv.inner = untag_ptr(arg);
41122         arg_conv.is_owned = ptr_is_owned(arg);
41123         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41124         arg_conv.is_owned = false;
41125         int64_t ret_conv = TxInitRbf_clone_ptr(&arg_conv);
41126         return ret_conv;
41127 }
41128
41129 int64_t  CS_LDK_TxInitRbf_clone(int64_t orig) {
41130         LDKTxInitRbf orig_conv;
41131         orig_conv.inner = untag_ptr(orig);
41132         orig_conv.is_owned = ptr_is_owned(orig);
41133         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41134         orig_conv.is_owned = false;
41135         LDKTxInitRbf ret_var = TxInitRbf_clone(&orig_conv);
41136         int64_t ret_ref = 0;
41137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41138         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41139         return ret_ref;
41140 }
41141
41142 jboolean  CS_LDK_TxInitRbf_eq(int64_t a, int64_t b) {
41143         LDKTxInitRbf a_conv;
41144         a_conv.inner = untag_ptr(a);
41145         a_conv.is_owned = ptr_is_owned(a);
41146         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41147         a_conv.is_owned = false;
41148         LDKTxInitRbf b_conv;
41149         b_conv.inner = untag_ptr(b);
41150         b_conv.is_owned = ptr_is_owned(b);
41151         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41152         b_conv.is_owned = false;
41153         jboolean ret_conv = TxInitRbf_eq(&a_conv, &b_conv);
41154         return ret_conv;
41155 }
41156
41157 void  CS_LDK_TxAckRbf_free(int64_t this_obj) {
41158         LDKTxAckRbf this_obj_conv;
41159         this_obj_conv.inner = untag_ptr(this_obj);
41160         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41162         TxAckRbf_free(this_obj_conv);
41163 }
41164
41165 int8_tArray  CS_LDK_TxAckRbf_get_channel_id(int64_t this_ptr) {
41166         LDKTxAckRbf this_ptr_conv;
41167         this_ptr_conv.inner = untag_ptr(this_ptr);
41168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41170         this_ptr_conv.is_owned = false;
41171         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41172         memcpy(ret_arr->elems, *TxAckRbf_get_channel_id(&this_ptr_conv), 32);
41173         return ret_arr;
41174 }
41175
41176 void  CS_LDK_TxAckRbf_set_channel_id(int64_t this_ptr, int8_tArray val) {
41177         LDKTxAckRbf this_ptr_conv;
41178         this_ptr_conv.inner = untag_ptr(this_ptr);
41179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41181         this_ptr_conv.is_owned = false;
41182         LDKThirtyTwoBytes val_ref;
41183         CHECK(val->arr_len == 32);
41184         memcpy(val_ref.data, val->elems, 32); FREE(val);
41185         TxAckRbf_set_channel_id(&this_ptr_conv, val_ref);
41186 }
41187
41188 int64_t  CS_LDK_TxAckRbf_get_funding_output_contribution(int64_t this_ptr) {
41189         LDKTxAckRbf this_ptr_conv;
41190         this_ptr_conv.inner = untag_ptr(this_ptr);
41191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41193         this_ptr_conv.is_owned = false;
41194         LDKCOption_i64Z *ret_copy = MALLOC(sizeof(LDKCOption_i64Z), "LDKCOption_i64Z");
41195         *ret_copy = TxAckRbf_get_funding_output_contribution(&this_ptr_conv);
41196         int64_t ret_ref = tag_ptr(ret_copy, true);
41197         return ret_ref;
41198 }
41199
41200 void  CS_LDK_TxAckRbf_set_funding_output_contribution(int64_t this_ptr, int64_t val) {
41201         LDKTxAckRbf this_ptr_conv;
41202         this_ptr_conv.inner = untag_ptr(this_ptr);
41203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41205         this_ptr_conv.is_owned = false;
41206         void* val_ptr = untag_ptr(val);
41207         CHECK_ACCESS(val_ptr);
41208         LDKCOption_i64Z val_conv = *(LDKCOption_i64Z*)(val_ptr);
41209         val_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(val));
41210         TxAckRbf_set_funding_output_contribution(&this_ptr_conv, val_conv);
41211 }
41212
41213 int64_t  CS_LDK_TxAckRbf_new(int8_tArray channel_id_arg, int64_t funding_output_contribution_arg) {
41214         LDKThirtyTwoBytes channel_id_arg_ref;
41215         CHECK(channel_id_arg->arr_len == 32);
41216         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41217         void* funding_output_contribution_arg_ptr = untag_ptr(funding_output_contribution_arg);
41218         CHECK_ACCESS(funding_output_contribution_arg_ptr);
41219         LDKCOption_i64Z funding_output_contribution_arg_conv = *(LDKCOption_i64Z*)(funding_output_contribution_arg_ptr);
41220         funding_output_contribution_arg_conv = COption_i64Z_clone((LDKCOption_i64Z*)untag_ptr(funding_output_contribution_arg));
41221         LDKTxAckRbf ret_var = TxAckRbf_new(channel_id_arg_ref, funding_output_contribution_arg_conv);
41222         int64_t ret_ref = 0;
41223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41225         return ret_ref;
41226 }
41227
41228 static inline uint64_t TxAckRbf_clone_ptr(LDKTxAckRbf *NONNULL_PTR arg) {
41229         LDKTxAckRbf ret_var = TxAckRbf_clone(arg);
41230         int64_t ret_ref = 0;
41231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41233         return ret_ref;
41234 }
41235 int64_t  CS_LDK_TxAckRbf_clone_ptr(int64_t arg) {
41236         LDKTxAckRbf arg_conv;
41237         arg_conv.inner = untag_ptr(arg);
41238         arg_conv.is_owned = ptr_is_owned(arg);
41239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41240         arg_conv.is_owned = false;
41241         int64_t ret_conv = TxAckRbf_clone_ptr(&arg_conv);
41242         return ret_conv;
41243 }
41244
41245 int64_t  CS_LDK_TxAckRbf_clone(int64_t orig) {
41246         LDKTxAckRbf orig_conv;
41247         orig_conv.inner = untag_ptr(orig);
41248         orig_conv.is_owned = ptr_is_owned(orig);
41249         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41250         orig_conv.is_owned = false;
41251         LDKTxAckRbf ret_var = TxAckRbf_clone(&orig_conv);
41252         int64_t ret_ref = 0;
41253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41255         return ret_ref;
41256 }
41257
41258 jboolean  CS_LDK_TxAckRbf_eq(int64_t a, int64_t b) {
41259         LDKTxAckRbf a_conv;
41260         a_conv.inner = untag_ptr(a);
41261         a_conv.is_owned = ptr_is_owned(a);
41262         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41263         a_conv.is_owned = false;
41264         LDKTxAckRbf b_conv;
41265         b_conv.inner = untag_ptr(b);
41266         b_conv.is_owned = ptr_is_owned(b);
41267         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41268         b_conv.is_owned = false;
41269         jboolean ret_conv = TxAckRbf_eq(&a_conv, &b_conv);
41270         return ret_conv;
41271 }
41272
41273 void  CS_LDK_TxAbort_free(int64_t this_obj) {
41274         LDKTxAbort this_obj_conv;
41275         this_obj_conv.inner = untag_ptr(this_obj);
41276         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41278         TxAbort_free(this_obj_conv);
41279 }
41280
41281 int8_tArray  CS_LDK_TxAbort_get_channel_id(int64_t this_ptr) {
41282         LDKTxAbort this_ptr_conv;
41283         this_ptr_conv.inner = untag_ptr(this_ptr);
41284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41286         this_ptr_conv.is_owned = false;
41287         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41288         memcpy(ret_arr->elems, *TxAbort_get_channel_id(&this_ptr_conv), 32);
41289         return ret_arr;
41290 }
41291
41292 void  CS_LDK_TxAbort_set_channel_id(int64_t this_ptr, int8_tArray val) {
41293         LDKTxAbort this_ptr_conv;
41294         this_ptr_conv.inner = untag_ptr(this_ptr);
41295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41297         this_ptr_conv.is_owned = false;
41298         LDKThirtyTwoBytes val_ref;
41299         CHECK(val->arr_len == 32);
41300         memcpy(val_ref.data, val->elems, 32); FREE(val);
41301         TxAbort_set_channel_id(&this_ptr_conv, val_ref);
41302 }
41303
41304 int8_tArray  CS_LDK_TxAbort_get_data(int64_t this_ptr) {
41305         LDKTxAbort this_ptr_conv;
41306         this_ptr_conv.inner = untag_ptr(this_ptr);
41307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41309         this_ptr_conv.is_owned = false;
41310         LDKCVec_u8Z ret_var = TxAbort_get_data(&this_ptr_conv);
41311         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41312         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41313         CVec_u8Z_free(ret_var);
41314         return ret_arr;
41315 }
41316
41317 void  CS_LDK_TxAbort_set_data(int64_t this_ptr, int8_tArray val) {
41318         LDKTxAbort this_ptr_conv;
41319         this_ptr_conv.inner = untag_ptr(this_ptr);
41320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41322         this_ptr_conv.is_owned = false;
41323         LDKCVec_u8Z val_ref;
41324         val_ref.datalen = val->arr_len;
41325         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
41326         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
41327         TxAbort_set_data(&this_ptr_conv, val_ref);
41328 }
41329
41330 int64_t  CS_LDK_TxAbort_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
41331         LDKThirtyTwoBytes channel_id_arg_ref;
41332         CHECK(channel_id_arg->arr_len == 32);
41333         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41334         LDKCVec_u8Z data_arg_ref;
41335         data_arg_ref.datalen = data_arg->arr_len;
41336         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
41337         memcpy(data_arg_ref.data, data_arg->elems, data_arg_ref.datalen); FREE(data_arg);
41338         LDKTxAbort ret_var = TxAbort_new(channel_id_arg_ref, data_arg_ref);
41339         int64_t ret_ref = 0;
41340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41342         return ret_ref;
41343 }
41344
41345 static inline uint64_t TxAbort_clone_ptr(LDKTxAbort *NONNULL_PTR arg) {
41346         LDKTxAbort ret_var = TxAbort_clone(arg);
41347         int64_t ret_ref = 0;
41348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41350         return ret_ref;
41351 }
41352 int64_t  CS_LDK_TxAbort_clone_ptr(int64_t arg) {
41353         LDKTxAbort arg_conv;
41354         arg_conv.inner = untag_ptr(arg);
41355         arg_conv.is_owned = ptr_is_owned(arg);
41356         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41357         arg_conv.is_owned = false;
41358         int64_t ret_conv = TxAbort_clone_ptr(&arg_conv);
41359         return ret_conv;
41360 }
41361
41362 int64_t  CS_LDK_TxAbort_clone(int64_t orig) {
41363         LDKTxAbort orig_conv;
41364         orig_conv.inner = untag_ptr(orig);
41365         orig_conv.is_owned = ptr_is_owned(orig);
41366         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41367         orig_conv.is_owned = false;
41368         LDKTxAbort ret_var = TxAbort_clone(&orig_conv);
41369         int64_t ret_ref = 0;
41370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41372         return ret_ref;
41373 }
41374
41375 jboolean  CS_LDK_TxAbort_eq(int64_t a, int64_t b) {
41376         LDKTxAbort a_conv;
41377         a_conv.inner = untag_ptr(a);
41378         a_conv.is_owned = ptr_is_owned(a);
41379         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41380         a_conv.is_owned = false;
41381         LDKTxAbort b_conv;
41382         b_conv.inner = untag_ptr(b);
41383         b_conv.is_owned = ptr_is_owned(b);
41384         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41385         b_conv.is_owned = false;
41386         jboolean ret_conv = TxAbort_eq(&a_conv, &b_conv);
41387         return ret_conv;
41388 }
41389
41390 void  CS_LDK_Shutdown_free(int64_t this_obj) {
41391         LDKShutdown this_obj_conv;
41392         this_obj_conv.inner = untag_ptr(this_obj);
41393         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41395         Shutdown_free(this_obj_conv);
41396 }
41397
41398 int8_tArray  CS_LDK_Shutdown_get_channel_id(int64_t this_ptr) {
41399         LDKShutdown this_ptr_conv;
41400         this_ptr_conv.inner = untag_ptr(this_ptr);
41401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41403         this_ptr_conv.is_owned = false;
41404         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41405         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
41406         return ret_arr;
41407 }
41408
41409 void  CS_LDK_Shutdown_set_channel_id(int64_t this_ptr, int8_tArray val) {
41410         LDKShutdown this_ptr_conv;
41411         this_ptr_conv.inner = untag_ptr(this_ptr);
41412         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41414         this_ptr_conv.is_owned = false;
41415         LDKThirtyTwoBytes val_ref;
41416         CHECK(val->arr_len == 32);
41417         memcpy(val_ref.data, val->elems, 32); FREE(val);
41418         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
41419 }
41420
41421 int8_tArray  CS_LDK_Shutdown_get_scriptpubkey(int64_t this_ptr) {
41422         LDKShutdown this_ptr_conv;
41423         this_ptr_conv.inner = untag_ptr(this_ptr);
41424         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41426         this_ptr_conv.is_owned = false;
41427         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
41428         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41429         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41430         return ret_arr;
41431 }
41432
41433 void  CS_LDK_Shutdown_set_scriptpubkey(int64_t this_ptr, int8_tArray val) {
41434         LDKShutdown this_ptr_conv;
41435         this_ptr_conv.inner = untag_ptr(this_ptr);
41436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41438         this_ptr_conv.is_owned = false;
41439         LDKCVec_u8Z val_ref;
41440         val_ref.datalen = val->arr_len;
41441         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
41442         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
41443         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
41444 }
41445
41446 int64_t  CS_LDK_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
41447         LDKThirtyTwoBytes channel_id_arg_ref;
41448         CHECK(channel_id_arg->arr_len == 32);
41449         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41450         LDKCVec_u8Z scriptpubkey_arg_ref;
41451         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
41452         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
41453         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
41454         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
41455         int64_t ret_ref = 0;
41456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41457         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41458         return ret_ref;
41459 }
41460
41461 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
41462         LDKShutdown ret_var = Shutdown_clone(arg);
41463         int64_t ret_ref = 0;
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41465         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41466         return ret_ref;
41467 }
41468 int64_t  CS_LDK_Shutdown_clone_ptr(int64_t arg) {
41469         LDKShutdown arg_conv;
41470         arg_conv.inner = untag_ptr(arg);
41471         arg_conv.is_owned = ptr_is_owned(arg);
41472         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41473         arg_conv.is_owned = false;
41474         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
41475         return ret_conv;
41476 }
41477
41478 int64_t  CS_LDK_Shutdown_clone(int64_t orig) {
41479         LDKShutdown orig_conv;
41480         orig_conv.inner = untag_ptr(orig);
41481         orig_conv.is_owned = ptr_is_owned(orig);
41482         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41483         orig_conv.is_owned = false;
41484         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
41485         int64_t ret_ref = 0;
41486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41487         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41488         return ret_ref;
41489 }
41490
41491 jboolean  CS_LDK_Shutdown_eq(int64_t a, int64_t b) {
41492         LDKShutdown a_conv;
41493         a_conv.inner = untag_ptr(a);
41494         a_conv.is_owned = ptr_is_owned(a);
41495         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41496         a_conv.is_owned = false;
41497         LDKShutdown b_conv;
41498         b_conv.inner = untag_ptr(b);
41499         b_conv.is_owned = ptr_is_owned(b);
41500         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41501         b_conv.is_owned = false;
41502         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
41503         return ret_conv;
41504 }
41505
41506 void  CS_LDK_ClosingSignedFeeRange_free(int64_t this_obj) {
41507         LDKClosingSignedFeeRange this_obj_conv;
41508         this_obj_conv.inner = untag_ptr(this_obj);
41509         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41511         ClosingSignedFeeRange_free(this_obj_conv);
41512 }
41513
41514 int64_t  CS_LDK_ClosingSignedFeeRange_get_min_fee_satoshis(int64_t this_ptr) {
41515         LDKClosingSignedFeeRange this_ptr_conv;
41516         this_ptr_conv.inner = untag_ptr(this_ptr);
41517         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41519         this_ptr_conv.is_owned = false;
41520         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
41521         return ret_conv;
41522 }
41523
41524 void  CS_LDK_ClosingSignedFeeRange_set_min_fee_satoshis(int64_t this_ptr, int64_t val) {
41525         LDKClosingSignedFeeRange this_ptr_conv;
41526         this_ptr_conv.inner = untag_ptr(this_ptr);
41527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41529         this_ptr_conv.is_owned = false;
41530         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
41531 }
41532
41533 int64_t  CS_LDK_ClosingSignedFeeRange_get_max_fee_satoshis(int64_t this_ptr) {
41534         LDKClosingSignedFeeRange this_ptr_conv;
41535         this_ptr_conv.inner = untag_ptr(this_ptr);
41536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41538         this_ptr_conv.is_owned = false;
41539         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
41540         return ret_conv;
41541 }
41542
41543 void  CS_LDK_ClosingSignedFeeRange_set_max_fee_satoshis(int64_t this_ptr, int64_t val) {
41544         LDKClosingSignedFeeRange this_ptr_conv;
41545         this_ptr_conv.inner = untag_ptr(this_ptr);
41546         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41548         this_ptr_conv.is_owned = false;
41549         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
41550 }
41551
41552 int64_t  CS_LDK_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
41553         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
41554         int64_t ret_ref = 0;
41555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41556         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41557         return ret_ref;
41558 }
41559
41560 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
41561         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
41562         int64_t ret_ref = 0;
41563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41564         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41565         return ret_ref;
41566 }
41567 int64_t  CS_LDK_ClosingSignedFeeRange_clone_ptr(int64_t arg) {
41568         LDKClosingSignedFeeRange arg_conv;
41569         arg_conv.inner = untag_ptr(arg);
41570         arg_conv.is_owned = ptr_is_owned(arg);
41571         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41572         arg_conv.is_owned = false;
41573         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
41574         return ret_conv;
41575 }
41576
41577 int64_t  CS_LDK_ClosingSignedFeeRange_clone(int64_t orig) {
41578         LDKClosingSignedFeeRange orig_conv;
41579         orig_conv.inner = untag_ptr(orig);
41580         orig_conv.is_owned = ptr_is_owned(orig);
41581         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41582         orig_conv.is_owned = false;
41583         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
41584         int64_t ret_ref = 0;
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41586         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41587         return ret_ref;
41588 }
41589
41590 jboolean  CS_LDK_ClosingSignedFeeRange_eq(int64_t a, int64_t b) {
41591         LDKClosingSignedFeeRange a_conv;
41592         a_conv.inner = untag_ptr(a);
41593         a_conv.is_owned = ptr_is_owned(a);
41594         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41595         a_conv.is_owned = false;
41596         LDKClosingSignedFeeRange b_conv;
41597         b_conv.inner = untag_ptr(b);
41598         b_conv.is_owned = ptr_is_owned(b);
41599         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41600         b_conv.is_owned = false;
41601         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
41602         return ret_conv;
41603 }
41604
41605 void  CS_LDK_ClosingSigned_free(int64_t this_obj) {
41606         LDKClosingSigned this_obj_conv;
41607         this_obj_conv.inner = untag_ptr(this_obj);
41608         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41610         ClosingSigned_free(this_obj_conv);
41611 }
41612
41613 int8_tArray  CS_LDK_ClosingSigned_get_channel_id(int64_t this_ptr) {
41614         LDKClosingSigned this_ptr_conv;
41615         this_ptr_conv.inner = untag_ptr(this_ptr);
41616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41618         this_ptr_conv.is_owned = false;
41619         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41620         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
41621         return ret_arr;
41622 }
41623
41624 void  CS_LDK_ClosingSigned_set_channel_id(int64_t this_ptr, int8_tArray val) {
41625         LDKClosingSigned this_ptr_conv;
41626         this_ptr_conv.inner = untag_ptr(this_ptr);
41627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41629         this_ptr_conv.is_owned = false;
41630         LDKThirtyTwoBytes val_ref;
41631         CHECK(val->arr_len == 32);
41632         memcpy(val_ref.data, val->elems, 32); FREE(val);
41633         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
41634 }
41635
41636 int64_t  CS_LDK_ClosingSigned_get_fee_satoshis(int64_t this_ptr) {
41637         LDKClosingSigned this_ptr_conv;
41638         this_ptr_conv.inner = untag_ptr(this_ptr);
41639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41641         this_ptr_conv.is_owned = false;
41642         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
41643         return ret_conv;
41644 }
41645
41646 void  CS_LDK_ClosingSigned_set_fee_satoshis(int64_t this_ptr, int64_t val) {
41647         LDKClosingSigned this_ptr_conv;
41648         this_ptr_conv.inner = untag_ptr(this_ptr);
41649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41651         this_ptr_conv.is_owned = false;
41652         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
41653 }
41654
41655 int8_tArray  CS_LDK_ClosingSigned_get_signature(int64_t this_ptr) {
41656         LDKClosingSigned this_ptr_conv;
41657         this_ptr_conv.inner = untag_ptr(this_ptr);
41658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41660         this_ptr_conv.is_owned = false;
41661         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
41662         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
41663         return ret_arr;
41664 }
41665
41666 void  CS_LDK_ClosingSigned_set_signature(int64_t this_ptr, int8_tArray val) {
41667         LDKClosingSigned this_ptr_conv;
41668         this_ptr_conv.inner = untag_ptr(this_ptr);
41669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41671         this_ptr_conv.is_owned = false;
41672         LDKECDSASignature val_ref;
41673         CHECK(val->arr_len == 64);
41674         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
41675         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
41676 }
41677
41678 int64_t  CS_LDK_ClosingSigned_get_fee_range(int64_t this_ptr) {
41679         LDKClosingSigned this_ptr_conv;
41680         this_ptr_conv.inner = untag_ptr(this_ptr);
41681         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41683         this_ptr_conv.is_owned = false;
41684         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
41685         int64_t ret_ref = 0;
41686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41687         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41688         return ret_ref;
41689 }
41690
41691 void  CS_LDK_ClosingSigned_set_fee_range(int64_t this_ptr, int64_t val) {
41692         LDKClosingSigned this_ptr_conv;
41693         this_ptr_conv.inner = untag_ptr(this_ptr);
41694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41696         this_ptr_conv.is_owned = false;
41697         LDKClosingSignedFeeRange val_conv;
41698         val_conv.inner = untag_ptr(val);
41699         val_conv.is_owned = ptr_is_owned(val);
41700         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41701         val_conv = ClosingSignedFeeRange_clone(&val_conv);
41702         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
41703 }
41704
41705 int64_t  CS_LDK_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, int64_t fee_range_arg) {
41706         LDKThirtyTwoBytes channel_id_arg_ref;
41707         CHECK(channel_id_arg->arr_len == 32);
41708         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
41709         LDKECDSASignature signature_arg_ref;
41710         CHECK(signature_arg->arr_len == 64);
41711         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
41712         LDKClosingSignedFeeRange fee_range_arg_conv;
41713         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
41714         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
41715         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
41716         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
41717         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
41718         int64_t ret_ref = 0;
41719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41720         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41721         return ret_ref;
41722 }
41723
41724 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
41725         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
41726         int64_t ret_ref = 0;
41727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41729         return ret_ref;
41730 }
41731 int64_t  CS_LDK_ClosingSigned_clone_ptr(int64_t arg) {
41732         LDKClosingSigned arg_conv;
41733         arg_conv.inner = untag_ptr(arg);
41734         arg_conv.is_owned = ptr_is_owned(arg);
41735         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41736         arg_conv.is_owned = false;
41737         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
41738         return ret_conv;
41739 }
41740
41741 int64_t  CS_LDK_ClosingSigned_clone(int64_t orig) {
41742         LDKClosingSigned orig_conv;
41743         orig_conv.inner = untag_ptr(orig);
41744         orig_conv.is_owned = ptr_is_owned(orig);
41745         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41746         orig_conv.is_owned = false;
41747         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
41748         int64_t ret_ref = 0;
41749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41751         return ret_ref;
41752 }
41753
41754 jboolean  CS_LDK_ClosingSigned_eq(int64_t a, int64_t b) {
41755         LDKClosingSigned a_conv;
41756         a_conv.inner = untag_ptr(a);
41757         a_conv.is_owned = ptr_is_owned(a);
41758         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41759         a_conv.is_owned = false;
41760         LDKClosingSigned b_conv;
41761         b_conv.inner = untag_ptr(b);
41762         b_conv.is_owned = ptr_is_owned(b);
41763         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41764         b_conv.is_owned = false;
41765         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
41766         return ret_conv;
41767 }
41768
41769 void  CS_LDK_UpdateAddHTLC_free(int64_t this_obj) {
41770         LDKUpdateAddHTLC this_obj_conv;
41771         this_obj_conv.inner = untag_ptr(this_obj);
41772         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41774         UpdateAddHTLC_free(this_obj_conv);
41775 }
41776
41777 int8_tArray  CS_LDK_UpdateAddHTLC_get_channel_id(int64_t this_ptr) {
41778         LDKUpdateAddHTLC this_ptr_conv;
41779         this_ptr_conv.inner = untag_ptr(this_ptr);
41780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41782         this_ptr_conv.is_owned = false;
41783         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41784         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
41785         return ret_arr;
41786 }
41787
41788 void  CS_LDK_UpdateAddHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
41789         LDKUpdateAddHTLC this_ptr_conv;
41790         this_ptr_conv.inner = untag_ptr(this_ptr);
41791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41793         this_ptr_conv.is_owned = false;
41794         LDKThirtyTwoBytes val_ref;
41795         CHECK(val->arr_len == 32);
41796         memcpy(val_ref.data, val->elems, 32); FREE(val);
41797         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
41798 }
41799
41800 int64_t  CS_LDK_UpdateAddHTLC_get_htlc_id(int64_t this_ptr) {
41801         LDKUpdateAddHTLC this_ptr_conv;
41802         this_ptr_conv.inner = untag_ptr(this_ptr);
41803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41805         this_ptr_conv.is_owned = false;
41806         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
41807         return ret_conv;
41808 }
41809
41810 void  CS_LDK_UpdateAddHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
41811         LDKUpdateAddHTLC this_ptr_conv;
41812         this_ptr_conv.inner = untag_ptr(this_ptr);
41813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41815         this_ptr_conv.is_owned = false;
41816         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
41817 }
41818
41819 int64_t  CS_LDK_UpdateAddHTLC_get_amount_msat(int64_t this_ptr) {
41820         LDKUpdateAddHTLC this_ptr_conv;
41821         this_ptr_conv.inner = untag_ptr(this_ptr);
41822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41824         this_ptr_conv.is_owned = false;
41825         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
41826         return ret_conv;
41827 }
41828
41829 void  CS_LDK_UpdateAddHTLC_set_amount_msat(int64_t this_ptr, int64_t val) {
41830         LDKUpdateAddHTLC this_ptr_conv;
41831         this_ptr_conv.inner = untag_ptr(this_ptr);
41832         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41834         this_ptr_conv.is_owned = false;
41835         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
41836 }
41837
41838 int8_tArray  CS_LDK_UpdateAddHTLC_get_payment_hash(int64_t this_ptr) {
41839         LDKUpdateAddHTLC this_ptr_conv;
41840         this_ptr_conv.inner = untag_ptr(this_ptr);
41841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41843         this_ptr_conv.is_owned = false;
41844         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41845         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
41846         return ret_arr;
41847 }
41848
41849 void  CS_LDK_UpdateAddHTLC_set_payment_hash(int64_t this_ptr, int8_tArray val) {
41850         LDKUpdateAddHTLC this_ptr_conv;
41851         this_ptr_conv.inner = untag_ptr(this_ptr);
41852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41854         this_ptr_conv.is_owned = false;
41855         LDKThirtyTwoBytes val_ref;
41856         CHECK(val->arr_len == 32);
41857         memcpy(val_ref.data, val->elems, 32); FREE(val);
41858         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
41859 }
41860
41861 int32_t  CS_LDK_UpdateAddHTLC_get_cltv_expiry(int64_t this_ptr) {
41862         LDKUpdateAddHTLC this_ptr_conv;
41863         this_ptr_conv.inner = untag_ptr(this_ptr);
41864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41866         this_ptr_conv.is_owned = false;
41867         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
41868         return ret_conv;
41869 }
41870
41871 void  CS_LDK_UpdateAddHTLC_set_cltv_expiry(int64_t this_ptr, int32_t val) {
41872         LDKUpdateAddHTLC this_ptr_conv;
41873         this_ptr_conv.inner = untag_ptr(this_ptr);
41874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41876         this_ptr_conv.is_owned = false;
41877         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
41878 }
41879
41880 int64_t  CS_LDK_UpdateAddHTLC_get_skimmed_fee_msat(int64_t this_ptr) {
41881         LDKUpdateAddHTLC this_ptr_conv;
41882         this_ptr_conv.inner = untag_ptr(this_ptr);
41883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41885         this_ptr_conv.is_owned = false;
41886         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41887         *ret_copy = UpdateAddHTLC_get_skimmed_fee_msat(&this_ptr_conv);
41888         int64_t ret_ref = tag_ptr(ret_copy, true);
41889         return ret_ref;
41890 }
41891
41892 void  CS_LDK_UpdateAddHTLC_set_skimmed_fee_msat(int64_t this_ptr, int64_t val) {
41893         LDKUpdateAddHTLC this_ptr_conv;
41894         this_ptr_conv.inner = untag_ptr(this_ptr);
41895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41897         this_ptr_conv.is_owned = false;
41898         void* val_ptr = untag_ptr(val);
41899         CHECK_ACCESS(val_ptr);
41900         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
41901         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
41902         UpdateAddHTLC_set_skimmed_fee_msat(&this_ptr_conv, val_conv);
41903 }
41904
41905 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
41906         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
41907         int64_t ret_ref = 0;
41908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41910         return ret_ref;
41911 }
41912 int64_t  CS_LDK_UpdateAddHTLC_clone_ptr(int64_t arg) {
41913         LDKUpdateAddHTLC arg_conv;
41914         arg_conv.inner = untag_ptr(arg);
41915         arg_conv.is_owned = ptr_is_owned(arg);
41916         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41917         arg_conv.is_owned = false;
41918         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
41919         return ret_conv;
41920 }
41921
41922 int64_t  CS_LDK_UpdateAddHTLC_clone(int64_t orig) {
41923         LDKUpdateAddHTLC orig_conv;
41924         orig_conv.inner = untag_ptr(orig);
41925         orig_conv.is_owned = ptr_is_owned(orig);
41926         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41927         orig_conv.is_owned = false;
41928         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
41929         int64_t ret_ref = 0;
41930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41932         return ret_ref;
41933 }
41934
41935 jboolean  CS_LDK_UpdateAddHTLC_eq(int64_t a, int64_t b) {
41936         LDKUpdateAddHTLC a_conv;
41937         a_conv.inner = untag_ptr(a);
41938         a_conv.is_owned = ptr_is_owned(a);
41939         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41940         a_conv.is_owned = false;
41941         LDKUpdateAddHTLC b_conv;
41942         b_conv.inner = untag_ptr(b);
41943         b_conv.is_owned = ptr_is_owned(b);
41944         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41945         b_conv.is_owned = false;
41946         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
41947         return ret_conv;
41948 }
41949
41950 void  CS_LDK_OnionMessage_free(int64_t this_obj) {
41951         LDKOnionMessage this_obj_conv;
41952         this_obj_conv.inner = untag_ptr(this_obj);
41953         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41955         OnionMessage_free(this_obj_conv);
41956 }
41957
41958 int8_tArray  CS_LDK_OnionMessage_get_blinding_point(int64_t this_ptr) {
41959         LDKOnionMessage this_ptr_conv;
41960         this_ptr_conv.inner = untag_ptr(this_ptr);
41961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41963         this_ptr_conv.is_owned = false;
41964         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41965         memcpy(ret_arr->elems, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form, 33);
41966         return ret_arr;
41967 }
41968
41969 void  CS_LDK_OnionMessage_set_blinding_point(int64_t this_ptr, int8_tArray val) {
41970         LDKOnionMessage this_ptr_conv;
41971         this_ptr_conv.inner = untag_ptr(this_ptr);
41972         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41974         this_ptr_conv.is_owned = false;
41975         LDKPublicKey val_ref;
41976         CHECK(val->arr_len == 33);
41977         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
41978         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
41979 }
41980
41981 int64_t  CS_LDK_OnionMessage_get_onion_routing_packet(int64_t this_ptr) {
41982         LDKOnionMessage this_ptr_conv;
41983         this_ptr_conv.inner = untag_ptr(this_ptr);
41984         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41986         this_ptr_conv.is_owned = false;
41987         LDKPacket ret_var = OnionMessage_get_onion_routing_packet(&this_ptr_conv);
41988         int64_t ret_ref = 0;
41989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41991         return ret_ref;
41992 }
41993
41994 void  CS_LDK_OnionMessage_set_onion_routing_packet(int64_t this_ptr, int64_t val) {
41995         LDKOnionMessage this_ptr_conv;
41996         this_ptr_conv.inner = untag_ptr(this_ptr);
41997         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41999         this_ptr_conv.is_owned = false;
42000         LDKPacket val_conv;
42001         val_conv.inner = untag_ptr(val);
42002         val_conv.is_owned = ptr_is_owned(val);
42003         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42004         val_conv = Packet_clone(&val_conv);
42005         OnionMessage_set_onion_routing_packet(&this_ptr_conv, val_conv);
42006 }
42007
42008 int64_t  CS_LDK_OnionMessage_new(int8_tArray blinding_point_arg, int64_t onion_routing_packet_arg) {
42009         LDKPublicKey blinding_point_arg_ref;
42010         CHECK(blinding_point_arg->arr_len == 33);
42011         memcpy(blinding_point_arg_ref.compressed_form, blinding_point_arg->elems, 33); FREE(blinding_point_arg);
42012         LDKPacket onion_routing_packet_arg_conv;
42013         onion_routing_packet_arg_conv.inner = untag_ptr(onion_routing_packet_arg);
42014         onion_routing_packet_arg_conv.is_owned = ptr_is_owned(onion_routing_packet_arg);
42015         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_routing_packet_arg_conv);
42016         onion_routing_packet_arg_conv = Packet_clone(&onion_routing_packet_arg_conv);
42017         LDKOnionMessage ret_var = OnionMessage_new(blinding_point_arg_ref, onion_routing_packet_arg_conv);
42018         int64_t ret_ref = 0;
42019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42021         return ret_ref;
42022 }
42023
42024 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
42025         LDKOnionMessage ret_var = OnionMessage_clone(arg);
42026         int64_t ret_ref = 0;
42027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42028         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42029         return ret_ref;
42030 }
42031 int64_t  CS_LDK_OnionMessage_clone_ptr(int64_t arg) {
42032         LDKOnionMessage arg_conv;
42033         arg_conv.inner = untag_ptr(arg);
42034         arg_conv.is_owned = ptr_is_owned(arg);
42035         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42036         arg_conv.is_owned = false;
42037         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
42038         return ret_conv;
42039 }
42040
42041 int64_t  CS_LDK_OnionMessage_clone(int64_t orig) {
42042         LDKOnionMessage orig_conv;
42043         orig_conv.inner = untag_ptr(orig);
42044         orig_conv.is_owned = ptr_is_owned(orig);
42045         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42046         orig_conv.is_owned = false;
42047         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
42048         int64_t ret_ref = 0;
42049         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42050         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42051         return ret_ref;
42052 }
42053
42054 jboolean  CS_LDK_OnionMessage_eq(int64_t a, int64_t b) {
42055         LDKOnionMessage a_conv;
42056         a_conv.inner = untag_ptr(a);
42057         a_conv.is_owned = ptr_is_owned(a);
42058         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42059         a_conv.is_owned = false;
42060         LDKOnionMessage b_conv;
42061         b_conv.inner = untag_ptr(b);
42062         b_conv.is_owned = ptr_is_owned(b);
42063         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42064         b_conv.is_owned = false;
42065         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
42066         return ret_conv;
42067 }
42068
42069 void  CS_LDK_UpdateFulfillHTLC_free(int64_t this_obj) {
42070         LDKUpdateFulfillHTLC this_obj_conv;
42071         this_obj_conv.inner = untag_ptr(this_obj);
42072         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42074         UpdateFulfillHTLC_free(this_obj_conv);
42075 }
42076
42077 int8_tArray  CS_LDK_UpdateFulfillHTLC_get_channel_id(int64_t this_ptr) {
42078         LDKUpdateFulfillHTLC this_ptr_conv;
42079         this_ptr_conv.inner = untag_ptr(this_ptr);
42080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42082         this_ptr_conv.is_owned = false;
42083         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42084         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
42085         return ret_arr;
42086 }
42087
42088 void  CS_LDK_UpdateFulfillHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
42089         LDKUpdateFulfillHTLC this_ptr_conv;
42090         this_ptr_conv.inner = untag_ptr(this_ptr);
42091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42093         this_ptr_conv.is_owned = false;
42094         LDKThirtyTwoBytes val_ref;
42095         CHECK(val->arr_len == 32);
42096         memcpy(val_ref.data, val->elems, 32); FREE(val);
42097         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
42098 }
42099
42100 int64_t  CS_LDK_UpdateFulfillHTLC_get_htlc_id(int64_t this_ptr) {
42101         LDKUpdateFulfillHTLC this_ptr_conv;
42102         this_ptr_conv.inner = untag_ptr(this_ptr);
42103         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42105         this_ptr_conv.is_owned = false;
42106         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
42107         return ret_conv;
42108 }
42109
42110 void  CS_LDK_UpdateFulfillHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
42111         LDKUpdateFulfillHTLC this_ptr_conv;
42112         this_ptr_conv.inner = untag_ptr(this_ptr);
42113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42115         this_ptr_conv.is_owned = false;
42116         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
42117 }
42118
42119 int8_tArray  CS_LDK_UpdateFulfillHTLC_get_payment_preimage(int64_t this_ptr) {
42120         LDKUpdateFulfillHTLC this_ptr_conv;
42121         this_ptr_conv.inner = untag_ptr(this_ptr);
42122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42124         this_ptr_conv.is_owned = false;
42125         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42126         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
42127         return ret_arr;
42128 }
42129
42130 void  CS_LDK_UpdateFulfillHTLC_set_payment_preimage(int64_t this_ptr, int8_tArray val) {
42131         LDKUpdateFulfillHTLC this_ptr_conv;
42132         this_ptr_conv.inner = untag_ptr(this_ptr);
42133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42135         this_ptr_conv.is_owned = false;
42136         LDKThirtyTwoBytes val_ref;
42137         CHECK(val->arr_len == 32);
42138         memcpy(val_ref.data, val->elems, 32); FREE(val);
42139         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
42140 }
42141
42142 int64_t  CS_LDK_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
42143         LDKThirtyTwoBytes channel_id_arg_ref;
42144         CHECK(channel_id_arg->arr_len == 32);
42145         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42146         LDKThirtyTwoBytes payment_preimage_arg_ref;
42147         CHECK(payment_preimage_arg->arr_len == 32);
42148         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
42149         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
42150         int64_t ret_ref = 0;
42151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42152         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42153         return ret_ref;
42154 }
42155
42156 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
42157         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
42158         int64_t ret_ref = 0;
42159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42160         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42161         return ret_ref;
42162 }
42163 int64_t  CS_LDK_UpdateFulfillHTLC_clone_ptr(int64_t arg) {
42164         LDKUpdateFulfillHTLC arg_conv;
42165         arg_conv.inner = untag_ptr(arg);
42166         arg_conv.is_owned = ptr_is_owned(arg);
42167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42168         arg_conv.is_owned = false;
42169         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
42170         return ret_conv;
42171 }
42172
42173 int64_t  CS_LDK_UpdateFulfillHTLC_clone(int64_t orig) {
42174         LDKUpdateFulfillHTLC orig_conv;
42175         orig_conv.inner = untag_ptr(orig);
42176         orig_conv.is_owned = ptr_is_owned(orig);
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42178         orig_conv.is_owned = false;
42179         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
42180         int64_t ret_ref = 0;
42181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42182         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42183         return ret_ref;
42184 }
42185
42186 jboolean  CS_LDK_UpdateFulfillHTLC_eq(int64_t a, int64_t b) {
42187         LDKUpdateFulfillHTLC a_conv;
42188         a_conv.inner = untag_ptr(a);
42189         a_conv.is_owned = ptr_is_owned(a);
42190         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42191         a_conv.is_owned = false;
42192         LDKUpdateFulfillHTLC b_conv;
42193         b_conv.inner = untag_ptr(b);
42194         b_conv.is_owned = ptr_is_owned(b);
42195         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42196         b_conv.is_owned = false;
42197         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
42198         return ret_conv;
42199 }
42200
42201 void  CS_LDK_UpdateFailHTLC_free(int64_t this_obj) {
42202         LDKUpdateFailHTLC this_obj_conv;
42203         this_obj_conv.inner = untag_ptr(this_obj);
42204         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42206         UpdateFailHTLC_free(this_obj_conv);
42207 }
42208
42209 int8_tArray  CS_LDK_UpdateFailHTLC_get_channel_id(int64_t this_ptr) {
42210         LDKUpdateFailHTLC this_ptr_conv;
42211         this_ptr_conv.inner = untag_ptr(this_ptr);
42212         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42214         this_ptr_conv.is_owned = false;
42215         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42216         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
42217         return ret_arr;
42218 }
42219
42220 void  CS_LDK_UpdateFailHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
42221         LDKUpdateFailHTLC this_ptr_conv;
42222         this_ptr_conv.inner = untag_ptr(this_ptr);
42223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42225         this_ptr_conv.is_owned = false;
42226         LDKThirtyTwoBytes val_ref;
42227         CHECK(val->arr_len == 32);
42228         memcpy(val_ref.data, val->elems, 32); FREE(val);
42229         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
42230 }
42231
42232 int64_t  CS_LDK_UpdateFailHTLC_get_htlc_id(int64_t this_ptr) {
42233         LDKUpdateFailHTLC this_ptr_conv;
42234         this_ptr_conv.inner = untag_ptr(this_ptr);
42235         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42237         this_ptr_conv.is_owned = false;
42238         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
42239         return ret_conv;
42240 }
42241
42242 void  CS_LDK_UpdateFailHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
42243         LDKUpdateFailHTLC this_ptr_conv;
42244         this_ptr_conv.inner = untag_ptr(this_ptr);
42245         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42247         this_ptr_conv.is_owned = false;
42248         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
42249 }
42250
42251 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
42252         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
42253         int64_t ret_ref = 0;
42254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42256         return ret_ref;
42257 }
42258 int64_t  CS_LDK_UpdateFailHTLC_clone_ptr(int64_t arg) {
42259         LDKUpdateFailHTLC arg_conv;
42260         arg_conv.inner = untag_ptr(arg);
42261         arg_conv.is_owned = ptr_is_owned(arg);
42262         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42263         arg_conv.is_owned = false;
42264         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
42265         return ret_conv;
42266 }
42267
42268 int64_t  CS_LDK_UpdateFailHTLC_clone(int64_t orig) {
42269         LDKUpdateFailHTLC orig_conv;
42270         orig_conv.inner = untag_ptr(orig);
42271         orig_conv.is_owned = ptr_is_owned(orig);
42272         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42273         orig_conv.is_owned = false;
42274         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
42275         int64_t ret_ref = 0;
42276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42278         return ret_ref;
42279 }
42280
42281 jboolean  CS_LDK_UpdateFailHTLC_eq(int64_t a, int64_t b) {
42282         LDKUpdateFailHTLC a_conv;
42283         a_conv.inner = untag_ptr(a);
42284         a_conv.is_owned = ptr_is_owned(a);
42285         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42286         a_conv.is_owned = false;
42287         LDKUpdateFailHTLC b_conv;
42288         b_conv.inner = untag_ptr(b);
42289         b_conv.is_owned = ptr_is_owned(b);
42290         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42291         b_conv.is_owned = false;
42292         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
42293         return ret_conv;
42294 }
42295
42296 void  CS_LDK_UpdateFailMalformedHTLC_free(int64_t this_obj) {
42297         LDKUpdateFailMalformedHTLC this_obj_conv;
42298         this_obj_conv.inner = untag_ptr(this_obj);
42299         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42301         UpdateFailMalformedHTLC_free(this_obj_conv);
42302 }
42303
42304 int8_tArray  CS_LDK_UpdateFailMalformedHTLC_get_channel_id(int64_t this_ptr) {
42305         LDKUpdateFailMalformedHTLC this_ptr_conv;
42306         this_ptr_conv.inner = untag_ptr(this_ptr);
42307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42309         this_ptr_conv.is_owned = false;
42310         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42311         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
42312         return ret_arr;
42313 }
42314
42315 void  CS_LDK_UpdateFailMalformedHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
42316         LDKUpdateFailMalformedHTLC this_ptr_conv;
42317         this_ptr_conv.inner = untag_ptr(this_ptr);
42318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42320         this_ptr_conv.is_owned = false;
42321         LDKThirtyTwoBytes val_ref;
42322         CHECK(val->arr_len == 32);
42323         memcpy(val_ref.data, val->elems, 32); FREE(val);
42324         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
42325 }
42326
42327 int64_t  CS_LDK_UpdateFailMalformedHTLC_get_htlc_id(int64_t this_ptr) {
42328         LDKUpdateFailMalformedHTLC this_ptr_conv;
42329         this_ptr_conv.inner = untag_ptr(this_ptr);
42330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42332         this_ptr_conv.is_owned = false;
42333         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
42334         return ret_conv;
42335 }
42336
42337 void  CS_LDK_UpdateFailMalformedHTLC_set_htlc_id(int64_t this_ptr, int64_t val) {
42338         LDKUpdateFailMalformedHTLC this_ptr_conv;
42339         this_ptr_conv.inner = untag_ptr(this_ptr);
42340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42342         this_ptr_conv.is_owned = false;
42343         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
42344 }
42345
42346 int16_t  CS_LDK_UpdateFailMalformedHTLC_get_failure_code(int64_t this_ptr) {
42347         LDKUpdateFailMalformedHTLC this_ptr_conv;
42348         this_ptr_conv.inner = untag_ptr(this_ptr);
42349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42351         this_ptr_conv.is_owned = false;
42352         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
42353         return ret_conv;
42354 }
42355
42356 void  CS_LDK_UpdateFailMalformedHTLC_set_failure_code(int64_t this_ptr, int16_t val) {
42357         LDKUpdateFailMalformedHTLC this_ptr_conv;
42358         this_ptr_conv.inner = untag_ptr(this_ptr);
42359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42361         this_ptr_conv.is_owned = false;
42362         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
42363 }
42364
42365 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
42366         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
42367         int64_t ret_ref = 0;
42368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42370         return ret_ref;
42371 }
42372 int64_t  CS_LDK_UpdateFailMalformedHTLC_clone_ptr(int64_t arg) {
42373         LDKUpdateFailMalformedHTLC arg_conv;
42374         arg_conv.inner = untag_ptr(arg);
42375         arg_conv.is_owned = ptr_is_owned(arg);
42376         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42377         arg_conv.is_owned = false;
42378         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
42379         return ret_conv;
42380 }
42381
42382 int64_t  CS_LDK_UpdateFailMalformedHTLC_clone(int64_t orig) {
42383         LDKUpdateFailMalformedHTLC orig_conv;
42384         orig_conv.inner = untag_ptr(orig);
42385         orig_conv.is_owned = ptr_is_owned(orig);
42386         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42387         orig_conv.is_owned = false;
42388         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
42389         int64_t ret_ref = 0;
42390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42391         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42392         return ret_ref;
42393 }
42394
42395 jboolean  CS_LDK_UpdateFailMalformedHTLC_eq(int64_t a, int64_t b) {
42396         LDKUpdateFailMalformedHTLC a_conv;
42397         a_conv.inner = untag_ptr(a);
42398         a_conv.is_owned = ptr_is_owned(a);
42399         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42400         a_conv.is_owned = false;
42401         LDKUpdateFailMalformedHTLC b_conv;
42402         b_conv.inner = untag_ptr(b);
42403         b_conv.is_owned = ptr_is_owned(b);
42404         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42405         b_conv.is_owned = false;
42406         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
42407         return ret_conv;
42408 }
42409
42410 void  CS_LDK_CommitmentSigned_free(int64_t this_obj) {
42411         LDKCommitmentSigned this_obj_conv;
42412         this_obj_conv.inner = untag_ptr(this_obj);
42413         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42415         CommitmentSigned_free(this_obj_conv);
42416 }
42417
42418 int8_tArray  CS_LDK_CommitmentSigned_get_channel_id(int64_t this_ptr) {
42419         LDKCommitmentSigned this_ptr_conv;
42420         this_ptr_conv.inner = untag_ptr(this_ptr);
42421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42423         this_ptr_conv.is_owned = false;
42424         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42425         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
42426         return ret_arr;
42427 }
42428
42429 void  CS_LDK_CommitmentSigned_set_channel_id(int64_t this_ptr, int8_tArray val) {
42430         LDKCommitmentSigned this_ptr_conv;
42431         this_ptr_conv.inner = untag_ptr(this_ptr);
42432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42434         this_ptr_conv.is_owned = false;
42435         LDKThirtyTwoBytes val_ref;
42436         CHECK(val->arr_len == 32);
42437         memcpy(val_ref.data, val->elems, 32); FREE(val);
42438         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
42439 }
42440
42441 int8_tArray  CS_LDK_CommitmentSigned_get_signature(int64_t this_ptr) {
42442         LDKCommitmentSigned this_ptr_conv;
42443         this_ptr_conv.inner = untag_ptr(this_ptr);
42444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42446         this_ptr_conv.is_owned = false;
42447         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
42448         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
42449         return ret_arr;
42450 }
42451
42452 void  CS_LDK_CommitmentSigned_set_signature(int64_t this_ptr, int8_tArray val) {
42453         LDKCommitmentSigned this_ptr_conv;
42454         this_ptr_conv.inner = untag_ptr(this_ptr);
42455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42457         this_ptr_conv.is_owned = false;
42458         LDKECDSASignature val_ref;
42459         CHECK(val->arr_len == 64);
42460         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
42461         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
42462 }
42463
42464 ptrArray  CS_LDK_CommitmentSigned_get_htlc_signatures(int64_t this_ptr) {
42465         LDKCommitmentSigned this_ptr_conv;
42466         this_ptr_conv.inner = untag_ptr(this_ptr);
42467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42469         this_ptr_conv.is_owned = false;
42470         LDKCVec_ECDSASignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
42471         ptrArray ret_arr = NULL;
42472         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
42473         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
42474         for (size_t i = 0; i < ret_var.datalen; i++) {
42475                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
42476                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
42477                 ret_arr_ptr[i] = ret_conv_8_arr;
42478         }
42479         
42480         FREE(ret_var.data);
42481         return ret_arr;
42482 }
42483
42484 void  CS_LDK_CommitmentSigned_set_htlc_signatures(int64_t this_ptr, ptrArray val) {
42485         LDKCommitmentSigned this_ptr_conv;
42486         this_ptr_conv.inner = untag_ptr(this_ptr);
42487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42489         this_ptr_conv.is_owned = false;
42490         LDKCVec_ECDSASignatureZ val_constr;
42491         val_constr.datalen = val->arr_len;
42492         if (val_constr.datalen > 0)
42493                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
42494         else
42495                 val_constr.data = NULL;
42496         int8_tArray* val_vals = (void*) val->elems;
42497         for (size_t i = 0; i < val_constr.datalen; i++) {
42498                 int8_tArray val_conv_8 = val_vals[i];
42499                 LDKECDSASignature val_conv_8_ref;
42500                 CHECK(val_conv_8->arr_len == 64);
42501                 memcpy(val_conv_8_ref.compact_form, val_conv_8->elems, 64); FREE(val_conv_8);
42502                 val_constr.data[i] = val_conv_8_ref;
42503         }
42504         FREE(val);
42505         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
42506 }
42507
42508 int64_t  CS_LDK_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
42509         LDKThirtyTwoBytes channel_id_arg_ref;
42510         CHECK(channel_id_arg->arr_len == 32);
42511         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42512         LDKECDSASignature signature_arg_ref;
42513         CHECK(signature_arg->arr_len == 64);
42514         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
42515         LDKCVec_ECDSASignatureZ htlc_signatures_arg_constr;
42516         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
42517         if (htlc_signatures_arg_constr.datalen > 0)
42518                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
42519         else
42520                 htlc_signatures_arg_constr.data = NULL;
42521         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems;
42522         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
42523                 int8_tArray htlc_signatures_arg_conv_8 = htlc_signatures_arg_vals[i];
42524                 LDKECDSASignature htlc_signatures_arg_conv_8_ref;
42525                 CHECK(htlc_signatures_arg_conv_8->arr_len == 64);
42526                 memcpy(htlc_signatures_arg_conv_8_ref.compact_form, htlc_signatures_arg_conv_8->elems, 64); FREE(htlc_signatures_arg_conv_8);
42527                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
42528         }
42529         FREE(htlc_signatures_arg);
42530         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
42531         int64_t ret_ref = 0;
42532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42534         return ret_ref;
42535 }
42536
42537 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
42538         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
42539         int64_t ret_ref = 0;
42540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42541         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42542         return ret_ref;
42543 }
42544 int64_t  CS_LDK_CommitmentSigned_clone_ptr(int64_t arg) {
42545         LDKCommitmentSigned arg_conv;
42546         arg_conv.inner = untag_ptr(arg);
42547         arg_conv.is_owned = ptr_is_owned(arg);
42548         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42549         arg_conv.is_owned = false;
42550         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
42551         return ret_conv;
42552 }
42553
42554 int64_t  CS_LDK_CommitmentSigned_clone(int64_t orig) {
42555         LDKCommitmentSigned orig_conv;
42556         orig_conv.inner = untag_ptr(orig);
42557         orig_conv.is_owned = ptr_is_owned(orig);
42558         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42559         orig_conv.is_owned = false;
42560         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
42561         int64_t ret_ref = 0;
42562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42563         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42564         return ret_ref;
42565 }
42566
42567 jboolean  CS_LDK_CommitmentSigned_eq(int64_t a, int64_t b) {
42568         LDKCommitmentSigned a_conv;
42569         a_conv.inner = untag_ptr(a);
42570         a_conv.is_owned = ptr_is_owned(a);
42571         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42572         a_conv.is_owned = false;
42573         LDKCommitmentSigned b_conv;
42574         b_conv.inner = untag_ptr(b);
42575         b_conv.is_owned = ptr_is_owned(b);
42576         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42577         b_conv.is_owned = false;
42578         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
42579         return ret_conv;
42580 }
42581
42582 void  CS_LDK_RevokeAndACK_free(int64_t this_obj) {
42583         LDKRevokeAndACK this_obj_conv;
42584         this_obj_conv.inner = untag_ptr(this_obj);
42585         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42587         RevokeAndACK_free(this_obj_conv);
42588 }
42589
42590 int8_tArray  CS_LDK_RevokeAndACK_get_channel_id(int64_t this_ptr) {
42591         LDKRevokeAndACK this_ptr_conv;
42592         this_ptr_conv.inner = untag_ptr(this_ptr);
42593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42595         this_ptr_conv.is_owned = false;
42596         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42597         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
42598         return ret_arr;
42599 }
42600
42601 void  CS_LDK_RevokeAndACK_set_channel_id(int64_t this_ptr, int8_tArray val) {
42602         LDKRevokeAndACK this_ptr_conv;
42603         this_ptr_conv.inner = untag_ptr(this_ptr);
42604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42606         this_ptr_conv.is_owned = false;
42607         LDKThirtyTwoBytes val_ref;
42608         CHECK(val->arr_len == 32);
42609         memcpy(val_ref.data, val->elems, 32); FREE(val);
42610         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
42611 }
42612
42613 int8_tArray  CS_LDK_RevokeAndACK_get_per_commitment_secret(int64_t this_ptr) {
42614         LDKRevokeAndACK this_ptr_conv;
42615         this_ptr_conv.inner = untag_ptr(this_ptr);
42616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42618         this_ptr_conv.is_owned = false;
42619         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42620         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
42621         return ret_arr;
42622 }
42623
42624 void  CS_LDK_RevokeAndACK_set_per_commitment_secret(int64_t this_ptr, int8_tArray val) {
42625         LDKRevokeAndACK this_ptr_conv;
42626         this_ptr_conv.inner = untag_ptr(this_ptr);
42627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42629         this_ptr_conv.is_owned = false;
42630         LDKThirtyTwoBytes val_ref;
42631         CHECK(val->arr_len == 32);
42632         memcpy(val_ref.data, val->elems, 32); FREE(val);
42633         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
42634 }
42635
42636 int8_tArray  CS_LDK_RevokeAndACK_get_next_per_commitment_point(int64_t this_ptr) {
42637         LDKRevokeAndACK this_ptr_conv;
42638         this_ptr_conv.inner = untag_ptr(this_ptr);
42639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42641         this_ptr_conv.is_owned = false;
42642         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42643         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
42644         return ret_arr;
42645 }
42646
42647 void  CS_LDK_RevokeAndACK_set_next_per_commitment_point(int64_t this_ptr, int8_tArray val) {
42648         LDKRevokeAndACK this_ptr_conv;
42649         this_ptr_conv.inner = untag_ptr(this_ptr);
42650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42652         this_ptr_conv.is_owned = false;
42653         LDKPublicKey val_ref;
42654         CHECK(val->arr_len == 33);
42655         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42656         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
42657 }
42658
42659 int64_t  CS_LDK_RevokeAndACK_new(int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
42660         LDKThirtyTwoBytes channel_id_arg_ref;
42661         CHECK(channel_id_arg->arr_len == 32);
42662         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42663         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
42664         CHECK(per_commitment_secret_arg->arr_len == 32);
42665         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
42666         LDKPublicKey next_per_commitment_point_arg_ref;
42667         CHECK(next_per_commitment_point_arg->arr_len == 33);
42668         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
42669         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
42670         int64_t ret_ref = 0;
42671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42673         return ret_ref;
42674 }
42675
42676 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
42677         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
42678         int64_t ret_ref = 0;
42679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42680         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42681         return ret_ref;
42682 }
42683 int64_t  CS_LDK_RevokeAndACK_clone_ptr(int64_t arg) {
42684         LDKRevokeAndACK arg_conv;
42685         arg_conv.inner = untag_ptr(arg);
42686         arg_conv.is_owned = ptr_is_owned(arg);
42687         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42688         arg_conv.is_owned = false;
42689         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
42690         return ret_conv;
42691 }
42692
42693 int64_t  CS_LDK_RevokeAndACK_clone(int64_t orig) {
42694         LDKRevokeAndACK orig_conv;
42695         orig_conv.inner = untag_ptr(orig);
42696         orig_conv.is_owned = ptr_is_owned(orig);
42697         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42698         orig_conv.is_owned = false;
42699         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
42700         int64_t ret_ref = 0;
42701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42702         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42703         return ret_ref;
42704 }
42705
42706 jboolean  CS_LDK_RevokeAndACK_eq(int64_t a, int64_t b) {
42707         LDKRevokeAndACK a_conv;
42708         a_conv.inner = untag_ptr(a);
42709         a_conv.is_owned = ptr_is_owned(a);
42710         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42711         a_conv.is_owned = false;
42712         LDKRevokeAndACK b_conv;
42713         b_conv.inner = untag_ptr(b);
42714         b_conv.is_owned = ptr_is_owned(b);
42715         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42716         b_conv.is_owned = false;
42717         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
42718         return ret_conv;
42719 }
42720
42721 void  CS_LDK_UpdateFee_free(int64_t this_obj) {
42722         LDKUpdateFee this_obj_conv;
42723         this_obj_conv.inner = untag_ptr(this_obj);
42724         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42726         UpdateFee_free(this_obj_conv);
42727 }
42728
42729 int8_tArray  CS_LDK_UpdateFee_get_channel_id(int64_t this_ptr) {
42730         LDKUpdateFee this_ptr_conv;
42731         this_ptr_conv.inner = untag_ptr(this_ptr);
42732         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42734         this_ptr_conv.is_owned = false;
42735         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42736         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
42737         return ret_arr;
42738 }
42739
42740 void  CS_LDK_UpdateFee_set_channel_id(int64_t this_ptr, int8_tArray val) {
42741         LDKUpdateFee this_ptr_conv;
42742         this_ptr_conv.inner = untag_ptr(this_ptr);
42743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42745         this_ptr_conv.is_owned = false;
42746         LDKThirtyTwoBytes val_ref;
42747         CHECK(val->arr_len == 32);
42748         memcpy(val_ref.data, val->elems, 32); FREE(val);
42749         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
42750 }
42751
42752 int32_t  CS_LDK_UpdateFee_get_feerate_per_kw(int64_t this_ptr) {
42753         LDKUpdateFee this_ptr_conv;
42754         this_ptr_conv.inner = untag_ptr(this_ptr);
42755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42757         this_ptr_conv.is_owned = false;
42758         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
42759         return ret_conv;
42760 }
42761
42762 void  CS_LDK_UpdateFee_set_feerate_per_kw(int64_t this_ptr, int32_t val) {
42763         LDKUpdateFee this_ptr_conv;
42764         this_ptr_conv.inner = untag_ptr(this_ptr);
42765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42767         this_ptr_conv.is_owned = false;
42768         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
42769 }
42770
42771 int64_t  CS_LDK_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
42772         LDKThirtyTwoBytes channel_id_arg_ref;
42773         CHECK(channel_id_arg->arr_len == 32);
42774         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42775         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
42776         int64_t ret_ref = 0;
42777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42779         return ret_ref;
42780 }
42781
42782 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
42783         LDKUpdateFee ret_var = UpdateFee_clone(arg);
42784         int64_t ret_ref = 0;
42785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42787         return ret_ref;
42788 }
42789 int64_t  CS_LDK_UpdateFee_clone_ptr(int64_t arg) {
42790         LDKUpdateFee arg_conv;
42791         arg_conv.inner = untag_ptr(arg);
42792         arg_conv.is_owned = ptr_is_owned(arg);
42793         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42794         arg_conv.is_owned = false;
42795         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
42796         return ret_conv;
42797 }
42798
42799 int64_t  CS_LDK_UpdateFee_clone(int64_t orig) {
42800         LDKUpdateFee orig_conv;
42801         orig_conv.inner = untag_ptr(orig);
42802         orig_conv.is_owned = ptr_is_owned(orig);
42803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42804         orig_conv.is_owned = false;
42805         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
42806         int64_t ret_ref = 0;
42807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42809         return ret_ref;
42810 }
42811
42812 jboolean  CS_LDK_UpdateFee_eq(int64_t a, int64_t b) {
42813         LDKUpdateFee a_conv;
42814         a_conv.inner = untag_ptr(a);
42815         a_conv.is_owned = ptr_is_owned(a);
42816         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42817         a_conv.is_owned = false;
42818         LDKUpdateFee b_conv;
42819         b_conv.inner = untag_ptr(b);
42820         b_conv.is_owned = ptr_is_owned(b);
42821         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42822         b_conv.is_owned = false;
42823         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
42824         return ret_conv;
42825 }
42826
42827 void  CS_LDK_ChannelReestablish_free(int64_t this_obj) {
42828         LDKChannelReestablish this_obj_conv;
42829         this_obj_conv.inner = untag_ptr(this_obj);
42830         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42832         ChannelReestablish_free(this_obj_conv);
42833 }
42834
42835 int8_tArray  CS_LDK_ChannelReestablish_get_channel_id(int64_t this_ptr) {
42836         LDKChannelReestablish this_ptr_conv;
42837         this_ptr_conv.inner = untag_ptr(this_ptr);
42838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42840         this_ptr_conv.is_owned = false;
42841         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42842         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
42843         return ret_arr;
42844 }
42845
42846 void  CS_LDK_ChannelReestablish_set_channel_id(int64_t this_ptr, int8_tArray val) {
42847         LDKChannelReestablish this_ptr_conv;
42848         this_ptr_conv.inner = untag_ptr(this_ptr);
42849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42851         this_ptr_conv.is_owned = false;
42852         LDKThirtyTwoBytes val_ref;
42853         CHECK(val->arr_len == 32);
42854         memcpy(val_ref.data, val->elems, 32); FREE(val);
42855         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
42856 }
42857
42858 int64_t  CS_LDK_ChannelReestablish_get_next_local_commitment_number(int64_t this_ptr) {
42859         LDKChannelReestablish this_ptr_conv;
42860         this_ptr_conv.inner = untag_ptr(this_ptr);
42861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42863         this_ptr_conv.is_owned = false;
42864         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
42865         return ret_conv;
42866 }
42867
42868 void  CS_LDK_ChannelReestablish_set_next_local_commitment_number(int64_t this_ptr, int64_t val) {
42869         LDKChannelReestablish this_ptr_conv;
42870         this_ptr_conv.inner = untag_ptr(this_ptr);
42871         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42873         this_ptr_conv.is_owned = false;
42874         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
42875 }
42876
42877 int64_t  CS_LDK_ChannelReestablish_get_next_remote_commitment_number(int64_t this_ptr) {
42878         LDKChannelReestablish this_ptr_conv;
42879         this_ptr_conv.inner = untag_ptr(this_ptr);
42880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42882         this_ptr_conv.is_owned = false;
42883         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
42884         return ret_conv;
42885 }
42886
42887 void  CS_LDK_ChannelReestablish_set_next_remote_commitment_number(int64_t this_ptr, int64_t val) {
42888         LDKChannelReestablish this_ptr_conv;
42889         this_ptr_conv.inner = untag_ptr(this_ptr);
42890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42892         this_ptr_conv.is_owned = false;
42893         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
42894 }
42895
42896 int8_tArray  CS_LDK_ChannelReestablish_get_your_last_per_commitment_secret(int64_t this_ptr) {
42897         LDKChannelReestablish this_ptr_conv;
42898         this_ptr_conv.inner = untag_ptr(this_ptr);
42899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42901         this_ptr_conv.is_owned = false;
42902         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42903         memcpy(ret_arr->elems, *ChannelReestablish_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
42904         return ret_arr;
42905 }
42906
42907 void  CS_LDK_ChannelReestablish_set_your_last_per_commitment_secret(int64_t this_ptr, int8_tArray val) {
42908         LDKChannelReestablish this_ptr_conv;
42909         this_ptr_conv.inner = untag_ptr(this_ptr);
42910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42912         this_ptr_conv.is_owned = false;
42913         LDKThirtyTwoBytes val_ref;
42914         CHECK(val->arr_len == 32);
42915         memcpy(val_ref.data, val->elems, 32); FREE(val);
42916         ChannelReestablish_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
42917 }
42918
42919 int8_tArray  CS_LDK_ChannelReestablish_get_my_current_per_commitment_point(int64_t this_ptr) {
42920         LDKChannelReestablish this_ptr_conv;
42921         this_ptr_conv.inner = untag_ptr(this_ptr);
42922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42924         this_ptr_conv.is_owned = false;
42925         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42926         memcpy(ret_arr->elems, ChannelReestablish_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
42927         return ret_arr;
42928 }
42929
42930 void  CS_LDK_ChannelReestablish_set_my_current_per_commitment_point(int64_t this_ptr, int8_tArray val) {
42931         LDKChannelReestablish this_ptr_conv;
42932         this_ptr_conv.inner = untag_ptr(this_ptr);
42933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42935         this_ptr_conv.is_owned = false;
42936         LDKPublicKey val_ref;
42937         CHECK(val->arr_len == 33);
42938         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42939         ChannelReestablish_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
42940 }
42941
42942 int64_t  CS_LDK_ChannelReestablish_get_next_funding_txid(int64_t this_ptr) {
42943         LDKChannelReestablish this_ptr_conv;
42944         this_ptr_conv.inner = untag_ptr(this_ptr);
42945         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42947         this_ptr_conv.is_owned = false;
42948         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
42949         *ret_copy = ChannelReestablish_get_next_funding_txid(&this_ptr_conv);
42950         int64_t ret_ref = tag_ptr(ret_copy, true);
42951         return ret_ref;
42952 }
42953
42954 void  CS_LDK_ChannelReestablish_set_next_funding_txid(int64_t this_ptr, int64_t val) {
42955         LDKChannelReestablish this_ptr_conv;
42956         this_ptr_conv.inner = untag_ptr(this_ptr);
42957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42959         this_ptr_conv.is_owned = false;
42960         void* val_ptr = untag_ptr(val);
42961         CHECK_ACCESS(val_ptr);
42962         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
42963         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
42964         ChannelReestablish_set_next_funding_txid(&this_ptr_conv, val_conv);
42965 }
42966
42967 int64_t  CS_LDK_ChannelReestablish_new(int8_tArray channel_id_arg, int64_t next_local_commitment_number_arg, int64_t next_remote_commitment_number_arg, int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg, int64_t next_funding_txid_arg) {
42968         LDKThirtyTwoBytes channel_id_arg_ref;
42969         CHECK(channel_id_arg->arr_len == 32);
42970         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
42971         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
42972         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
42973         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
42974         LDKPublicKey my_current_per_commitment_point_arg_ref;
42975         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
42976         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, my_current_per_commitment_point_arg->elems, 33); FREE(my_current_per_commitment_point_arg);
42977         void* next_funding_txid_arg_ptr = untag_ptr(next_funding_txid_arg);
42978         CHECK_ACCESS(next_funding_txid_arg_ptr);
42979         LDKCOption_ThirtyTwoBytesZ next_funding_txid_arg_conv = *(LDKCOption_ThirtyTwoBytesZ*)(next_funding_txid_arg_ptr);
42980         next_funding_txid_arg_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(next_funding_txid_arg));
42981         LDKChannelReestablish ret_var = ChannelReestablish_new(channel_id_arg_ref, next_local_commitment_number_arg, next_remote_commitment_number_arg, your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref, next_funding_txid_arg_conv);
42982         int64_t ret_ref = 0;
42983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42984         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42985         return ret_ref;
42986 }
42987
42988 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
42989         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
42990         int64_t ret_ref = 0;
42991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42992         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42993         return ret_ref;
42994 }
42995 int64_t  CS_LDK_ChannelReestablish_clone_ptr(int64_t arg) {
42996         LDKChannelReestablish arg_conv;
42997         arg_conv.inner = untag_ptr(arg);
42998         arg_conv.is_owned = ptr_is_owned(arg);
42999         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43000         arg_conv.is_owned = false;
43001         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
43002         return ret_conv;
43003 }
43004
43005 int64_t  CS_LDK_ChannelReestablish_clone(int64_t orig) {
43006         LDKChannelReestablish orig_conv;
43007         orig_conv.inner = untag_ptr(orig);
43008         orig_conv.is_owned = ptr_is_owned(orig);
43009         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43010         orig_conv.is_owned = false;
43011         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
43012         int64_t ret_ref = 0;
43013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43015         return ret_ref;
43016 }
43017
43018 jboolean  CS_LDK_ChannelReestablish_eq(int64_t a, int64_t b) {
43019         LDKChannelReestablish a_conv;
43020         a_conv.inner = untag_ptr(a);
43021         a_conv.is_owned = ptr_is_owned(a);
43022         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43023         a_conv.is_owned = false;
43024         LDKChannelReestablish b_conv;
43025         b_conv.inner = untag_ptr(b);
43026         b_conv.is_owned = ptr_is_owned(b);
43027         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43028         b_conv.is_owned = false;
43029         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
43030         return ret_conv;
43031 }
43032
43033 void  CS_LDK_AnnouncementSignatures_free(int64_t this_obj) {
43034         LDKAnnouncementSignatures this_obj_conv;
43035         this_obj_conv.inner = untag_ptr(this_obj);
43036         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43038         AnnouncementSignatures_free(this_obj_conv);
43039 }
43040
43041 int8_tArray  CS_LDK_AnnouncementSignatures_get_channel_id(int64_t this_ptr) {
43042         LDKAnnouncementSignatures this_ptr_conv;
43043         this_ptr_conv.inner = untag_ptr(this_ptr);
43044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43046         this_ptr_conv.is_owned = false;
43047         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43048         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
43049         return ret_arr;
43050 }
43051
43052 void  CS_LDK_AnnouncementSignatures_set_channel_id(int64_t this_ptr, int8_tArray val) {
43053         LDKAnnouncementSignatures this_ptr_conv;
43054         this_ptr_conv.inner = untag_ptr(this_ptr);
43055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43057         this_ptr_conv.is_owned = false;
43058         LDKThirtyTwoBytes val_ref;
43059         CHECK(val->arr_len == 32);
43060         memcpy(val_ref.data, val->elems, 32); FREE(val);
43061         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
43062 }
43063
43064 int64_t  CS_LDK_AnnouncementSignatures_get_short_channel_id(int64_t this_ptr) {
43065         LDKAnnouncementSignatures this_ptr_conv;
43066         this_ptr_conv.inner = untag_ptr(this_ptr);
43067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43069         this_ptr_conv.is_owned = false;
43070         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
43071         return ret_conv;
43072 }
43073
43074 void  CS_LDK_AnnouncementSignatures_set_short_channel_id(int64_t this_ptr, int64_t val) {
43075         LDKAnnouncementSignatures this_ptr_conv;
43076         this_ptr_conv.inner = untag_ptr(this_ptr);
43077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43079         this_ptr_conv.is_owned = false;
43080         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
43081 }
43082
43083 int8_tArray  CS_LDK_AnnouncementSignatures_get_node_signature(int64_t this_ptr) {
43084         LDKAnnouncementSignatures this_ptr_conv;
43085         this_ptr_conv.inner = untag_ptr(this_ptr);
43086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43088         this_ptr_conv.is_owned = false;
43089         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
43090         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
43091         return ret_arr;
43092 }
43093
43094 void  CS_LDK_AnnouncementSignatures_set_node_signature(int64_t this_ptr, int8_tArray val) {
43095         LDKAnnouncementSignatures this_ptr_conv;
43096         this_ptr_conv.inner = untag_ptr(this_ptr);
43097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43099         this_ptr_conv.is_owned = false;
43100         LDKECDSASignature val_ref;
43101         CHECK(val->arr_len == 64);
43102         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
43103         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
43104 }
43105
43106 int8_tArray  CS_LDK_AnnouncementSignatures_get_bitcoin_signature(int64_t this_ptr) {
43107         LDKAnnouncementSignatures this_ptr_conv;
43108         this_ptr_conv.inner = untag_ptr(this_ptr);
43109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43111         this_ptr_conv.is_owned = false;
43112         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
43113         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
43114         return ret_arr;
43115 }
43116
43117 void  CS_LDK_AnnouncementSignatures_set_bitcoin_signature(int64_t this_ptr, int8_tArray val) {
43118         LDKAnnouncementSignatures this_ptr_conv;
43119         this_ptr_conv.inner = untag_ptr(this_ptr);
43120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43122         this_ptr_conv.is_owned = false;
43123         LDKECDSASignature val_ref;
43124         CHECK(val->arr_len == 64);
43125         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
43126         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
43127 }
43128
43129 int64_t  CS_LDK_AnnouncementSignatures_new(int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
43130         LDKThirtyTwoBytes channel_id_arg_ref;
43131         CHECK(channel_id_arg->arr_len == 32);
43132         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
43133         LDKECDSASignature node_signature_arg_ref;
43134         CHECK(node_signature_arg->arr_len == 64);
43135         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
43136         LDKECDSASignature bitcoin_signature_arg_ref;
43137         CHECK(bitcoin_signature_arg->arr_len == 64);
43138         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
43139         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
43140         int64_t ret_ref = 0;
43141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43142         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43143         return ret_ref;
43144 }
43145
43146 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
43147         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
43148         int64_t ret_ref = 0;
43149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43151         return ret_ref;
43152 }
43153 int64_t  CS_LDK_AnnouncementSignatures_clone_ptr(int64_t arg) {
43154         LDKAnnouncementSignatures arg_conv;
43155         arg_conv.inner = untag_ptr(arg);
43156         arg_conv.is_owned = ptr_is_owned(arg);
43157         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43158         arg_conv.is_owned = false;
43159         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
43160         return ret_conv;
43161 }
43162
43163 int64_t  CS_LDK_AnnouncementSignatures_clone(int64_t orig) {
43164         LDKAnnouncementSignatures orig_conv;
43165         orig_conv.inner = untag_ptr(orig);
43166         orig_conv.is_owned = ptr_is_owned(orig);
43167         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43168         orig_conv.is_owned = false;
43169         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
43170         int64_t ret_ref = 0;
43171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43173         return ret_ref;
43174 }
43175
43176 jboolean  CS_LDK_AnnouncementSignatures_eq(int64_t a, int64_t b) {
43177         LDKAnnouncementSignatures a_conv;
43178         a_conv.inner = untag_ptr(a);
43179         a_conv.is_owned = ptr_is_owned(a);
43180         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43181         a_conv.is_owned = false;
43182         LDKAnnouncementSignatures b_conv;
43183         b_conv.inner = untag_ptr(b);
43184         b_conv.is_owned = ptr_is_owned(b);
43185         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43186         b_conv.is_owned = false;
43187         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
43188         return ret_conv;
43189 }
43190
43191 void  CS_LDK_SocketAddress_free(int64_t this_ptr) {
43192         if (!ptr_is_owned(this_ptr)) return;
43193         void* this_ptr_ptr = untag_ptr(this_ptr);
43194         CHECK_ACCESS(this_ptr_ptr);
43195         LDKSocketAddress this_ptr_conv = *(LDKSocketAddress*)(this_ptr_ptr);
43196         FREE(untag_ptr(this_ptr));
43197         SocketAddress_free(this_ptr_conv);
43198 }
43199
43200 static inline uint64_t SocketAddress_clone_ptr(LDKSocketAddress *NONNULL_PTR arg) {
43201         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43202         *ret_copy = SocketAddress_clone(arg);
43203         int64_t ret_ref = tag_ptr(ret_copy, true);
43204         return ret_ref;
43205 }
43206 int64_t  CS_LDK_SocketAddress_clone_ptr(int64_t arg) {
43207         LDKSocketAddress* arg_conv = (LDKSocketAddress*)untag_ptr(arg);
43208         int64_t ret_conv = SocketAddress_clone_ptr(arg_conv);
43209         return ret_conv;
43210 }
43211
43212 int64_t  CS_LDK_SocketAddress_clone(int64_t orig) {
43213         LDKSocketAddress* orig_conv = (LDKSocketAddress*)untag_ptr(orig);
43214         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43215         *ret_copy = SocketAddress_clone(orig_conv);
43216         int64_t ret_ref = tag_ptr(ret_copy, true);
43217         return ret_ref;
43218 }
43219
43220 int64_t  CS_LDK_SocketAddress_tcp_ip_v4(int8_tArray addr, int16_t port) {
43221         LDKFourBytes addr_ref;
43222         CHECK(addr->arr_len == 4);
43223         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
43224         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43225         *ret_copy = SocketAddress_tcp_ip_v4(addr_ref, port);
43226         int64_t ret_ref = tag_ptr(ret_copy, true);
43227         return ret_ref;
43228 }
43229
43230 int64_t  CS_LDK_SocketAddress_tcp_ip_v6(int8_tArray addr, int16_t port) {
43231         LDKSixteenBytes addr_ref;
43232         CHECK(addr->arr_len == 16);
43233         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
43234         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43235         *ret_copy = SocketAddress_tcp_ip_v6(addr_ref, port);
43236         int64_t ret_ref = tag_ptr(ret_copy, true);
43237         return ret_ref;
43238 }
43239
43240 int64_t  CS_LDK_SocketAddress_onion_v2(int8_tArray a) {
43241         LDKTwelveBytes a_ref;
43242         CHECK(a->arr_len == 12);
43243         memcpy(a_ref.data, a->elems, 12); FREE(a);
43244         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43245         *ret_copy = SocketAddress_onion_v2(a_ref);
43246         int64_t ret_ref = tag_ptr(ret_copy, true);
43247         return ret_ref;
43248 }
43249
43250 int64_t  CS_LDK_SocketAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
43251         LDKThirtyTwoBytes ed25519_pubkey_ref;
43252         CHECK(ed25519_pubkey->arr_len == 32);
43253         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
43254         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43255         *ret_copy = SocketAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
43256         int64_t ret_ref = tag_ptr(ret_copy, true);
43257         return ret_ref;
43258 }
43259
43260 int64_t  CS_LDK_SocketAddress_hostname(int64_t hostname, int16_t port) {
43261         LDKHostname hostname_conv;
43262         hostname_conv.inner = untag_ptr(hostname);
43263         hostname_conv.is_owned = ptr_is_owned(hostname);
43264         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
43265         hostname_conv = Hostname_clone(&hostname_conv);
43266         LDKSocketAddress *ret_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43267         *ret_copy = SocketAddress_hostname(hostname_conv, port);
43268         int64_t ret_ref = tag_ptr(ret_copy, true);
43269         return ret_ref;
43270 }
43271
43272 jboolean  CS_LDK_SocketAddress_eq(int64_t a, int64_t b) {
43273         LDKSocketAddress* a_conv = (LDKSocketAddress*)untag_ptr(a);
43274         LDKSocketAddress* b_conv = (LDKSocketAddress*)untag_ptr(b);
43275         jboolean ret_conv = SocketAddress_eq(a_conv, b_conv);
43276         return ret_conv;
43277 }
43278
43279 int8_tArray  CS_LDK_SocketAddress_write(int64_t obj) {
43280         LDKSocketAddress* obj_conv = (LDKSocketAddress*)untag_ptr(obj);
43281         LDKCVec_u8Z ret_var = SocketAddress_write(obj_conv);
43282         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43283         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43284         CVec_u8Z_free(ret_var);
43285         return ret_arr;
43286 }
43287
43288 int64_t  CS_LDK_SocketAddress_read(int8_tArray ser) {
43289         LDKu8slice ser_ref;
43290         ser_ref.datalen = ser->arr_len;
43291         ser_ref.data = ser->elems;
43292         LDKCResult_SocketAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressDecodeErrorZ), "LDKCResult_SocketAddressDecodeErrorZ");
43293         *ret_conv = SocketAddress_read(ser_ref);
43294         FREE(ser);
43295         return tag_ptr(ret_conv, true);
43296 }
43297
43298 int32_t  CS_LDK_SocketAddressParseError_clone(int64_t orig) {
43299         LDKSocketAddressParseError* orig_conv = (LDKSocketAddressParseError*)untag_ptr(orig);
43300         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_clone(orig_conv));
43301         return ret_conv;
43302 }
43303
43304 int32_t  CS_LDK_SocketAddressParseError_socket_addr_parse() {
43305         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_socket_addr_parse());
43306         return ret_conv;
43307 }
43308
43309 int32_t  CS_LDK_SocketAddressParseError_invalid_input() {
43310         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_invalid_input());
43311         return ret_conv;
43312 }
43313
43314 int32_t  CS_LDK_SocketAddressParseError_invalid_port() {
43315         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_invalid_port());
43316         return ret_conv;
43317 }
43318
43319 int32_t  CS_LDK_SocketAddressParseError_invalid_onion_v3() {
43320         int32_t ret_conv = LDKSocketAddressParseError_to_cs(SocketAddressParseError_invalid_onion_v3());
43321         return ret_conv;
43322 }
43323
43324 jboolean  CS_LDK_SocketAddressParseError_eq(int64_t a, int64_t b) {
43325         LDKSocketAddressParseError* a_conv = (LDKSocketAddressParseError*)untag_ptr(a);
43326         LDKSocketAddressParseError* b_conv = (LDKSocketAddressParseError*)untag_ptr(b);
43327         jboolean ret_conv = SocketAddressParseError_eq(a_conv, b_conv);
43328         return ret_conv;
43329 }
43330
43331 int64_t  CS_LDK_parse_onion_address(jstring host, int16_t port) {
43332         LDKStr host_conv = str_ref_to_owned_c(host);
43333         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
43334         *ret_conv = parse_onion_address(host_conv, port);
43335         return tag_ptr(ret_conv, true);
43336 }
43337
43338 jstring  CS_LDK_SocketAddress_to_str(int64_t o) {
43339         LDKSocketAddress* o_conv = (LDKSocketAddress*)untag_ptr(o);
43340         LDKStr ret_str = SocketAddress_to_str(o_conv);
43341         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
43342         Str_free(ret_str);
43343         return ret_conv;
43344 }
43345
43346 int64_t  CS_LDK_SocketAddress_from_str(jstring s) {
43347         LDKStr s_conv = str_ref_to_owned_c(s);
43348         LDKCResult_SocketAddressSocketAddressParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SocketAddressSocketAddressParseErrorZ), "LDKCResult_SocketAddressSocketAddressParseErrorZ");
43349         *ret_conv = SocketAddress_from_str(s_conv);
43350         return tag_ptr(ret_conv, true);
43351 }
43352
43353 void  CS_LDK_UnsignedGossipMessage_free(int64_t this_ptr) {
43354         if (!ptr_is_owned(this_ptr)) return;
43355         void* this_ptr_ptr = untag_ptr(this_ptr);
43356         CHECK_ACCESS(this_ptr_ptr);
43357         LDKUnsignedGossipMessage this_ptr_conv = *(LDKUnsignedGossipMessage*)(this_ptr_ptr);
43358         FREE(untag_ptr(this_ptr));
43359         UnsignedGossipMessage_free(this_ptr_conv);
43360 }
43361
43362 static inline uint64_t UnsignedGossipMessage_clone_ptr(LDKUnsignedGossipMessage *NONNULL_PTR arg) {
43363         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43364         *ret_copy = UnsignedGossipMessage_clone(arg);
43365         int64_t ret_ref = tag_ptr(ret_copy, true);
43366         return ret_ref;
43367 }
43368 int64_t  CS_LDK_UnsignedGossipMessage_clone_ptr(int64_t arg) {
43369         LDKUnsignedGossipMessage* arg_conv = (LDKUnsignedGossipMessage*)untag_ptr(arg);
43370         int64_t ret_conv = UnsignedGossipMessage_clone_ptr(arg_conv);
43371         return ret_conv;
43372 }
43373
43374 int64_t  CS_LDK_UnsignedGossipMessage_clone(int64_t orig) {
43375         LDKUnsignedGossipMessage* orig_conv = (LDKUnsignedGossipMessage*)untag_ptr(orig);
43376         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43377         *ret_copy = UnsignedGossipMessage_clone(orig_conv);
43378         int64_t ret_ref = tag_ptr(ret_copy, true);
43379         return ret_ref;
43380 }
43381
43382 int64_t  CS_LDK_UnsignedGossipMessage_channel_announcement(int64_t a) {
43383         LDKUnsignedChannelAnnouncement a_conv;
43384         a_conv.inner = untag_ptr(a);
43385         a_conv.is_owned = ptr_is_owned(a);
43386         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43387         a_conv = UnsignedChannelAnnouncement_clone(&a_conv);
43388         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43389         *ret_copy = UnsignedGossipMessage_channel_announcement(a_conv);
43390         int64_t ret_ref = tag_ptr(ret_copy, true);
43391         return ret_ref;
43392 }
43393
43394 int64_t  CS_LDK_UnsignedGossipMessage_channel_update(int64_t a) {
43395         LDKUnsignedChannelUpdate a_conv;
43396         a_conv.inner = untag_ptr(a);
43397         a_conv.is_owned = ptr_is_owned(a);
43398         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43399         a_conv = UnsignedChannelUpdate_clone(&a_conv);
43400         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43401         *ret_copy = UnsignedGossipMessage_channel_update(a_conv);
43402         int64_t ret_ref = tag_ptr(ret_copy, true);
43403         return ret_ref;
43404 }
43405
43406 int64_t  CS_LDK_UnsignedGossipMessage_node_announcement(int64_t a) {
43407         LDKUnsignedNodeAnnouncement a_conv;
43408         a_conv.inner = untag_ptr(a);
43409         a_conv.is_owned = ptr_is_owned(a);
43410         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43411         a_conv = UnsignedNodeAnnouncement_clone(&a_conv);
43412         LDKUnsignedGossipMessage *ret_copy = MALLOC(sizeof(LDKUnsignedGossipMessage), "LDKUnsignedGossipMessage");
43413         *ret_copy = UnsignedGossipMessage_node_announcement(a_conv);
43414         int64_t ret_ref = tag_ptr(ret_copy, true);
43415         return ret_ref;
43416 }
43417
43418 int8_tArray  CS_LDK_UnsignedGossipMessage_write(int64_t obj) {
43419         LDKUnsignedGossipMessage* obj_conv = (LDKUnsignedGossipMessage*)untag_ptr(obj);
43420         LDKCVec_u8Z ret_var = UnsignedGossipMessage_write(obj_conv);
43421         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43422         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43423         CVec_u8Z_free(ret_var);
43424         return ret_arr;
43425 }
43426
43427 void  CS_LDK_UnsignedNodeAnnouncement_free(int64_t this_obj) {
43428         LDKUnsignedNodeAnnouncement this_obj_conv;
43429         this_obj_conv.inner = untag_ptr(this_obj);
43430         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43432         UnsignedNodeAnnouncement_free(this_obj_conv);
43433 }
43434
43435 int64_t  CS_LDK_UnsignedNodeAnnouncement_get_features(int64_t this_ptr) {
43436         LDKUnsignedNodeAnnouncement this_ptr_conv;
43437         this_ptr_conv.inner = untag_ptr(this_ptr);
43438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43440         this_ptr_conv.is_owned = false;
43441         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
43442         int64_t ret_ref = 0;
43443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43445         return ret_ref;
43446 }
43447
43448 void  CS_LDK_UnsignedNodeAnnouncement_set_features(int64_t this_ptr, int64_t val) {
43449         LDKUnsignedNodeAnnouncement this_ptr_conv;
43450         this_ptr_conv.inner = untag_ptr(this_ptr);
43451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43453         this_ptr_conv.is_owned = false;
43454         LDKNodeFeatures val_conv;
43455         val_conv.inner = untag_ptr(val);
43456         val_conv.is_owned = ptr_is_owned(val);
43457         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43458         val_conv = NodeFeatures_clone(&val_conv);
43459         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
43460 }
43461
43462 int32_t  CS_LDK_UnsignedNodeAnnouncement_get_timestamp(int64_t this_ptr) {
43463         LDKUnsignedNodeAnnouncement this_ptr_conv;
43464         this_ptr_conv.inner = untag_ptr(this_ptr);
43465         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43467         this_ptr_conv.is_owned = false;
43468         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
43469         return ret_conv;
43470 }
43471
43472 void  CS_LDK_UnsignedNodeAnnouncement_set_timestamp(int64_t this_ptr, int32_t val) {
43473         LDKUnsignedNodeAnnouncement this_ptr_conv;
43474         this_ptr_conv.inner = untag_ptr(this_ptr);
43475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43477         this_ptr_conv.is_owned = false;
43478         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
43479 }
43480
43481 int64_t  CS_LDK_UnsignedNodeAnnouncement_get_node_id(int64_t this_ptr) {
43482         LDKUnsignedNodeAnnouncement this_ptr_conv;
43483         this_ptr_conv.inner = untag_ptr(this_ptr);
43484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43486         this_ptr_conv.is_owned = false;
43487         LDKNodeId ret_var = UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv);
43488         int64_t ret_ref = 0;
43489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43491         return ret_ref;
43492 }
43493
43494 void  CS_LDK_UnsignedNodeAnnouncement_set_node_id(int64_t this_ptr, int64_t val) {
43495         LDKUnsignedNodeAnnouncement this_ptr_conv;
43496         this_ptr_conv.inner = untag_ptr(this_ptr);
43497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43499         this_ptr_conv.is_owned = false;
43500         LDKNodeId val_conv;
43501         val_conv.inner = untag_ptr(val);
43502         val_conv.is_owned = ptr_is_owned(val);
43503         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43504         val_conv = NodeId_clone(&val_conv);
43505         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_conv);
43506 }
43507
43508 int8_tArray  CS_LDK_UnsignedNodeAnnouncement_get_rgb(int64_t this_ptr) {
43509         LDKUnsignedNodeAnnouncement this_ptr_conv;
43510         this_ptr_conv.inner = untag_ptr(this_ptr);
43511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43513         this_ptr_conv.is_owned = false;
43514         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
43515         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
43516         return ret_arr;
43517 }
43518
43519 void  CS_LDK_UnsignedNodeAnnouncement_set_rgb(int64_t this_ptr, int8_tArray val) {
43520         LDKUnsignedNodeAnnouncement this_ptr_conv;
43521         this_ptr_conv.inner = untag_ptr(this_ptr);
43522         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43524         this_ptr_conv.is_owned = false;
43525         LDKThreeBytes val_ref;
43526         CHECK(val->arr_len == 3);
43527         memcpy(val_ref.data, val->elems, 3); FREE(val);
43528         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
43529 }
43530
43531 int64_t  CS_LDK_UnsignedNodeAnnouncement_get_alias(int64_t this_ptr) {
43532         LDKUnsignedNodeAnnouncement this_ptr_conv;
43533         this_ptr_conv.inner = untag_ptr(this_ptr);
43534         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43536         this_ptr_conv.is_owned = false;
43537         LDKNodeAlias ret_var = UnsignedNodeAnnouncement_get_alias(&this_ptr_conv);
43538         int64_t ret_ref = 0;
43539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43541         return ret_ref;
43542 }
43543
43544 void  CS_LDK_UnsignedNodeAnnouncement_set_alias(int64_t this_ptr, int64_t val) {
43545         LDKUnsignedNodeAnnouncement this_ptr_conv;
43546         this_ptr_conv.inner = untag_ptr(this_ptr);
43547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43549         this_ptr_conv.is_owned = false;
43550         LDKNodeAlias val_conv;
43551         val_conv.inner = untag_ptr(val);
43552         val_conv.is_owned = ptr_is_owned(val);
43553         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43554         val_conv = NodeAlias_clone(&val_conv);
43555         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_conv);
43556 }
43557
43558 int64_tArray  CS_LDK_UnsignedNodeAnnouncement_get_addresses(int64_t this_ptr) {
43559         LDKUnsignedNodeAnnouncement this_ptr_conv;
43560         this_ptr_conv.inner = untag_ptr(this_ptr);
43561         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43563         this_ptr_conv.is_owned = false;
43564         LDKCVec_SocketAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
43565         int64_tArray ret_arr = NULL;
43566         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
43567         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
43568         for (size_t p = 0; p < ret_var.datalen; p++) {
43569                 LDKSocketAddress *ret_conv_15_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
43570                 *ret_conv_15_copy = ret_var.data[p];
43571                 int64_t ret_conv_15_ref = tag_ptr(ret_conv_15_copy, true);
43572                 ret_arr_ptr[p] = ret_conv_15_ref;
43573         }
43574         
43575         FREE(ret_var.data);
43576         return ret_arr;
43577 }
43578
43579 void  CS_LDK_UnsignedNodeAnnouncement_set_addresses(int64_t this_ptr, int64_tArray val) {
43580         LDKUnsignedNodeAnnouncement this_ptr_conv;
43581         this_ptr_conv.inner = untag_ptr(this_ptr);
43582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43584         this_ptr_conv.is_owned = false;
43585         LDKCVec_SocketAddressZ val_constr;
43586         val_constr.datalen = val->arr_len;
43587         if (val_constr.datalen > 0)
43588                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
43589         else
43590                 val_constr.data = NULL;
43591         int64_t* val_vals = val->elems;
43592         for (size_t p = 0; p < val_constr.datalen; p++) {
43593                 int64_t val_conv_15 = val_vals[p];
43594                 void* val_conv_15_ptr = untag_ptr(val_conv_15);
43595                 CHECK_ACCESS(val_conv_15_ptr);
43596                 LDKSocketAddress val_conv_15_conv = *(LDKSocketAddress*)(val_conv_15_ptr);
43597                 val_conv_15_conv = SocketAddress_clone((LDKSocketAddress*)untag_ptr(val_conv_15));
43598                 val_constr.data[p] = val_conv_15_conv;
43599         }
43600         FREE(val);
43601         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
43602 }
43603
43604 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
43605         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
43606         int64_t ret_ref = 0;
43607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43609         return ret_ref;
43610 }
43611 int64_t  CS_LDK_UnsignedNodeAnnouncement_clone_ptr(int64_t arg) {
43612         LDKUnsignedNodeAnnouncement arg_conv;
43613         arg_conv.inner = untag_ptr(arg);
43614         arg_conv.is_owned = ptr_is_owned(arg);
43615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43616         arg_conv.is_owned = false;
43617         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
43618         return ret_conv;
43619 }
43620
43621 int64_t  CS_LDK_UnsignedNodeAnnouncement_clone(int64_t orig) {
43622         LDKUnsignedNodeAnnouncement orig_conv;
43623         orig_conv.inner = untag_ptr(orig);
43624         orig_conv.is_owned = ptr_is_owned(orig);
43625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43626         orig_conv.is_owned = false;
43627         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
43628         int64_t ret_ref = 0;
43629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43631         return ret_ref;
43632 }
43633
43634 jboolean  CS_LDK_UnsignedNodeAnnouncement_eq(int64_t a, int64_t b) {
43635         LDKUnsignedNodeAnnouncement a_conv;
43636         a_conv.inner = untag_ptr(a);
43637         a_conv.is_owned = ptr_is_owned(a);
43638         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43639         a_conv.is_owned = false;
43640         LDKUnsignedNodeAnnouncement b_conv;
43641         b_conv.inner = untag_ptr(b);
43642         b_conv.is_owned = ptr_is_owned(b);
43643         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43644         b_conv.is_owned = false;
43645         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
43646         return ret_conv;
43647 }
43648
43649 void  CS_LDK_NodeAnnouncement_free(int64_t this_obj) {
43650         LDKNodeAnnouncement this_obj_conv;
43651         this_obj_conv.inner = untag_ptr(this_obj);
43652         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43654         NodeAnnouncement_free(this_obj_conv);
43655 }
43656
43657 int8_tArray  CS_LDK_NodeAnnouncement_get_signature(int64_t this_ptr) {
43658         LDKNodeAnnouncement this_ptr_conv;
43659         this_ptr_conv.inner = untag_ptr(this_ptr);
43660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43662         this_ptr_conv.is_owned = false;
43663         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
43664         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
43665         return ret_arr;
43666 }
43667
43668 void  CS_LDK_NodeAnnouncement_set_signature(int64_t this_ptr, int8_tArray val) {
43669         LDKNodeAnnouncement this_ptr_conv;
43670         this_ptr_conv.inner = untag_ptr(this_ptr);
43671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43673         this_ptr_conv.is_owned = false;
43674         LDKECDSASignature val_ref;
43675         CHECK(val->arr_len == 64);
43676         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
43677         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
43678 }
43679
43680 int64_t  CS_LDK_NodeAnnouncement_get_contents(int64_t this_ptr) {
43681         LDKNodeAnnouncement this_ptr_conv;
43682         this_ptr_conv.inner = untag_ptr(this_ptr);
43683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43685         this_ptr_conv.is_owned = false;
43686         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
43687         int64_t ret_ref = 0;
43688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43690         return ret_ref;
43691 }
43692
43693 void  CS_LDK_NodeAnnouncement_set_contents(int64_t this_ptr, int64_t val) {
43694         LDKNodeAnnouncement this_ptr_conv;
43695         this_ptr_conv.inner = untag_ptr(this_ptr);
43696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43698         this_ptr_conv.is_owned = false;
43699         LDKUnsignedNodeAnnouncement val_conv;
43700         val_conv.inner = untag_ptr(val);
43701         val_conv.is_owned = ptr_is_owned(val);
43702         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43703         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
43704         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
43705 }
43706
43707 int64_t  CS_LDK_NodeAnnouncement_new(int8_tArray signature_arg, int64_t contents_arg) {
43708         LDKECDSASignature signature_arg_ref;
43709         CHECK(signature_arg->arr_len == 64);
43710         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
43711         LDKUnsignedNodeAnnouncement contents_arg_conv;
43712         contents_arg_conv.inner = untag_ptr(contents_arg);
43713         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
43714         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
43715         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
43716         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
43717         int64_t ret_ref = 0;
43718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43720         return ret_ref;
43721 }
43722
43723 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
43724         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
43725         int64_t ret_ref = 0;
43726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43728         return ret_ref;
43729 }
43730 int64_t  CS_LDK_NodeAnnouncement_clone_ptr(int64_t arg) {
43731         LDKNodeAnnouncement arg_conv;
43732         arg_conv.inner = untag_ptr(arg);
43733         arg_conv.is_owned = ptr_is_owned(arg);
43734         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43735         arg_conv.is_owned = false;
43736         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
43737         return ret_conv;
43738 }
43739
43740 int64_t  CS_LDK_NodeAnnouncement_clone(int64_t orig) {
43741         LDKNodeAnnouncement orig_conv;
43742         orig_conv.inner = untag_ptr(orig);
43743         orig_conv.is_owned = ptr_is_owned(orig);
43744         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43745         orig_conv.is_owned = false;
43746         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
43747         int64_t ret_ref = 0;
43748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43749         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43750         return ret_ref;
43751 }
43752
43753 jboolean  CS_LDK_NodeAnnouncement_eq(int64_t a, int64_t b) {
43754         LDKNodeAnnouncement a_conv;
43755         a_conv.inner = untag_ptr(a);
43756         a_conv.is_owned = ptr_is_owned(a);
43757         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43758         a_conv.is_owned = false;
43759         LDKNodeAnnouncement b_conv;
43760         b_conv.inner = untag_ptr(b);
43761         b_conv.is_owned = ptr_is_owned(b);
43762         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43763         b_conv.is_owned = false;
43764         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
43765         return ret_conv;
43766 }
43767
43768 void  CS_LDK_UnsignedChannelAnnouncement_free(int64_t this_obj) {
43769         LDKUnsignedChannelAnnouncement this_obj_conv;
43770         this_obj_conv.inner = untag_ptr(this_obj);
43771         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43773         UnsignedChannelAnnouncement_free(this_obj_conv);
43774 }
43775
43776 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_features(int64_t this_ptr) {
43777         LDKUnsignedChannelAnnouncement this_ptr_conv;
43778         this_ptr_conv.inner = untag_ptr(this_ptr);
43779         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43781         this_ptr_conv.is_owned = false;
43782         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
43783         int64_t ret_ref = 0;
43784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43786         return ret_ref;
43787 }
43788
43789 void  CS_LDK_UnsignedChannelAnnouncement_set_features(int64_t this_ptr, int64_t val) {
43790         LDKUnsignedChannelAnnouncement this_ptr_conv;
43791         this_ptr_conv.inner = untag_ptr(this_ptr);
43792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43794         this_ptr_conv.is_owned = false;
43795         LDKChannelFeatures val_conv;
43796         val_conv.inner = untag_ptr(val);
43797         val_conv.is_owned = ptr_is_owned(val);
43798         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43799         val_conv = ChannelFeatures_clone(&val_conv);
43800         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
43801 }
43802
43803 int8_tArray  CS_LDK_UnsignedChannelAnnouncement_get_chain_hash(int64_t this_ptr) {
43804         LDKUnsignedChannelAnnouncement this_ptr_conv;
43805         this_ptr_conv.inner = untag_ptr(this_ptr);
43806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43808         this_ptr_conv.is_owned = false;
43809         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43810         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
43811         return ret_arr;
43812 }
43813
43814 void  CS_LDK_UnsignedChannelAnnouncement_set_chain_hash(int64_t this_ptr, int8_tArray val) {
43815         LDKUnsignedChannelAnnouncement this_ptr_conv;
43816         this_ptr_conv.inner = untag_ptr(this_ptr);
43817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43819         this_ptr_conv.is_owned = false;
43820         LDKThirtyTwoBytes val_ref;
43821         CHECK(val->arr_len == 32);
43822         memcpy(val_ref.data, val->elems, 32); FREE(val);
43823         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
43824 }
43825
43826 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_short_channel_id(int64_t this_ptr) {
43827         LDKUnsignedChannelAnnouncement this_ptr_conv;
43828         this_ptr_conv.inner = untag_ptr(this_ptr);
43829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43831         this_ptr_conv.is_owned = false;
43832         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
43833         return ret_conv;
43834 }
43835
43836 void  CS_LDK_UnsignedChannelAnnouncement_set_short_channel_id(int64_t this_ptr, int64_t val) {
43837         LDKUnsignedChannelAnnouncement this_ptr_conv;
43838         this_ptr_conv.inner = untag_ptr(this_ptr);
43839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43841         this_ptr_conv.is_owned = false;
43842         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
43843 }
43844
43845 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_node_id_1(int64_t this_ptr) {
43846         LDKUnsignedChannelAnnouncement this_ptr_conv;
43847         this_ptr_conv.inner = untag_ptr(this_ptr);
43848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43850         this_ptr_conv.is_owned = false;
43851         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv);
43852         int64_t ret_ref = 0;
43853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43855         return ret_ref;
43856 }
43857
43858 void  CS_LDK_UnsignedChannelAnnouncement_set_node_id_1(int64_t this_ptr, int64_t val) {
43859         LDKUnsignedChannelAnnouncement this_ptr_conv;
43860         this_ptr_conv.inner = untag_ptr(this_ptr);
43861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43863         this_ptr_conv.is_owned = false;
43864         LDKNodeId val_conv;
43865         val_conv.inner = untag_ptr(val);
43866         val_conv.is_owned = ptr_is_owned(val);
43867         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43868         val_conv = NodeId_clone(&val_conv);
43869         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_conv);
43870 }
43871
43872 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_node_id_2(int64_t this_ptr) {
43873         LDKUnsignedChannelAnnouncement this_ptr_conv;
43874         this_ptr_conv.inner = untag_ptr(this_ptr);
43875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43877         this_ptr_conv.is_owned = false;
43878         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv);
43879         int64_t ret_ref = 0;
43880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43881         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43882         return ret_ref;
43883 }
43884
43885 void  CS_LDK_UnsignedChannelAnnouncement_set_node_id_2(int64_t this_ptr, int64_t val) {
43886         LDKUnsignedChannelAnnouncement this_ptr_conv;
43887         this_ptr_conv.inner = untag_ptr(this_ptr);
43888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43890         this_ptr_conv.is_owned = false;
43891         LDKNodeId val_conv;
43892         val_conv.inner = untag_ptr(val);
43893         val_conv.is_owned = ptr_is_owned(val);
43894         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43895         val_conv = NodeId_clone(&val_conv);
43896         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_conv);
43897 }
43898
43899 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_bitcoin_key_1(int64_t this_ptr) {
43900         LDKUnsignedChannelAnnouncement this_ptr_conv;
43901         this_ptr_conv.inner = untag_ptr(this_ptr);
43902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43904         this_ptr_conv.is_owned = false;
43905         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv);
43906         int64_t ret_ref = 0;
43907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43908         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43909         return ret_ref;
43910 }
43911
43912 void  CS_LDK_UnsignedChannelAnnouncement_set_bitcoin_key_1(int64_t this_ptr, int64_t val) {
43913         LDKUnsignedChannelAnnouncement this_ptr_conv;
43914         this_ptr_conv.inner = untag_ptr(this_ptr);
43915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43917         this_ptr_conv.is_owned = false;
43918         LDKNodeId val_conv;
43919         val_conv.inner = untag_ptr(val);
43920         val_conv.is_owned = ptr_is_owned(val);
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43922         val_conv = NodeId_clone(&val_conv);
43923         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_conv);
43924 }
43925
43926 int64_t  CS_LDK_UnsignedChannelAnnouncement_get_bitcoin_key_2(int64_t this_ptr) {
43927         LDKUnsignedChannelAnnouncement this_ptr_conv;
43928         this_ptr_conv.inner = untag_ptr(this_ptr);
43929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43931         this_ptr_conv.is_owned = false;
43932         LDKNodeId ret_var = UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv);
43933         int64_t ret_ref = 0;
43934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43936         return ret_ref;
43937 }
43938
43939 void  CS_LDK_UnsignedChannelAnnouncement_set_bitcoin_key_2(int64_t this_ptr, int64_t val) {
43940         LDKUnsignedChannelAnnouncement this_ptr_conv;
43941         this_ptr_conv.inner = untag_ptr(this_ptr);
43942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43944         this_ptr_conv.is_owned = false;
43945         LDKNodeId val_conv;
43946         val_conv.inner = untag_ptr(val);
43947         val_conv.is_owned = ptr_is_owned(val);
43948         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43949         val_conv = NodeId_clone(&val_conv);
43950         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_conv);
43951 }
43952
43953 int8_tArray  CS_LDK_UnsignedChannelAnnouncement_get_excess_data(int64_t this_ptr) {
43954         LDKUnsignedChannelAnnouncement this_ptr_conv;
43955         this_ptr_conv.inner = untag_ptr(this_ptr);
43956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43958         this_ptr_conv.is_owned = false;
43959         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_get_excess_data(&this_ptr_conv);
43960         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
43961         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
43962         CVec_u8Z_free(ret_var);
43963         return ret_arr;
43964 }
43965
43966 void  CS_LDK_UnsignedChannelAnnouncement_set_excess_data(int64_t this_ptr, int8_tArray val) {
43967         LDKUnsignedChannelAnnouncement this_ptr_conv;
43968         this_ptr_conv.inner = untag_ptr(this_ptr);
43969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43971         this_ptr_conv.is_owned = false;
43972         LDKCVec_u8Z val_ref;
43973         val_ref.datalen = val->arr_len;
43974         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
43975         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
43976         UnsignedChannelAnnouncement_set_excess_data(&this_ptr_conv, val_ref);
43977 }
43978
43979 int64_t  CS_LDK_UnsignedChannelAnnouncement_new(int64_t features_arg, int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int64_t node_id_1_arg, int64_t node_id_2_arg, int64_t bitcoin_key_1_arg, int64_t bitcoin_key_2_arg, int8_tArray excess_data_arg) {
43980         LDKChannelFeatures features_arg_conv;
43981         features_arg_conv.inner = untag_ptr(features_arg);
43982         features_arg_conv.is_owned = ptr_is_owned(features_arg);
43983         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
43984         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
43985         LDKThirtyTwoBytes chain_hash_arg_ref;
43986         CHECK(chain_hash_arg->arr_len == 32);
43987         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
43988         LDKNodeId node_id_1_arg_conv;
43989         node_id_1_arg_conv.inner = untag_ptr(node_id_1_arg);
43990         node_id_1_arg_conv.is_owned = ptr_is_owned(node_id_1_arg);
43991         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_1_arg_conv);
43992         node_id_1_arg_conv = NodeId_clone(&node_id_1_arg_conv);
43993         LDKNodeId node_id_2_arg_conv;
43994         node_id_2_arg_conv.inner = untag_ptr(node_id_2_arg);
43995         node_id_2_arg_conv.is_owned = ptr_is_owned(node_id_2_arg);
43996         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_2_arg_conv);
43997         node_id_2_arg_conv = NodeId_clone(&node_id_2_arg_conv);
43998         LDKNodeId bitcoin_key_1_arg_conv;
43999         bitcoin_key_1_arg_conv.inner = untag_ptr(bitcoin_key_1_arg);
44000         bitcoin_key_1_arg_conv.is_owned = ptr_is_owned(bitcoin_key_1_arg);
44001         CHECK_INNER_FIELD_ACCESS_OR_NULL(bitcoin_key_1_arg_conv);
44002         bitcoin_key_1_arg_conv = NodeId_clone(&bitcoin_key_1_arg_conv);
44003         LDKNodeId bitcoin_key_2_arg_conv;
44004         bitcoin_key_2_arg_conv.inner = untag_ptr(bitcoin_key_2_arg);
44005         bitcoin_key_2_arg_conv.is_owned = ptr_is_owned(bitcoin_key_2_arg);
44006         CHECK_INNER_FIELD_ACCESS_OR_NULL(bitcoin_key_2_arg_conv);
44007         bitcoin_key_2_arg_conv = NodeId_clone(&bitcoin_key_2_arg_conv);
44008         LDKCVec_u8Z excess_data_arg_ref;
44009         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
44010         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
44011         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
44012         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_new(features_arg_conv, chain_hash_arg_ref, short_channel_id_arg, node_id_1_arg_conv, node_id_2_arg_conv, bitcoin_key_1_arg_conv, bitcoin_key_2_arg_conv, excess_data_arg_ref);
44013         int64_t ret_ref = 0;
44014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44016         return ret_ref;
44017 }
44018
44019 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
44020         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
44021         int64_t ret_ref = 0;
44022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44023         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44024         return ret_ref;
44025 }
44026 int64_t  CS_LDK_UnsignedChannelAnnouncement_clone_ptr(int64_t arg) {
44027         LDKUnsignedChannelAnnouncement arg_conv;
44028         arg_conv.inner = untag_ptr(arg);
44029         arg_conv.is_owned = ptr_is_owned(arg);
44030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44031         arg_conv.is_owned = false;
44032         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
44033         return ret_conv;
44034 }
44035
44036 int64_t  CS_LDK_UnsignedChannelAnnouncement_clone(int64_t orig) {
44037         LDKUnsignedChannelAnnouncement orig_conv;
44038         orig_conv.inner = untag_ptr(orig);
44039         orig_conv.is_owned = ptr_is_owned(orig);
44040         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44041         orig_conv.is_owned = false;
44042         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
44043         int64_t ret_ref = 0;
44044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44045         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44046         return ret_ref;
44047 }
44048
44049 jboolean  CS_LDK_UnsignedChannelAnnouncement_eq(int64_t a, int64_t b) {
44050         LDKUnsignedChannelAnnouncement a_conv;
44051         a_conv.inner = untag_ptr(a);
44052         a_conv.is_owned = ptr_is_owned(a);
44053         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44054         a_conv.is_owned = false;
44055         LDKUnsignedChannelAnnouncement b_conv;
44056         b_conv.inner = untag_ptr(b);
44057         b_conv.is_owned = ptr_is_owned(b);
44058         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44059         b_conv.is_owned = false;
44060         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
44061         return ret_conv;
44062 }
44063
44064 void  CS_LDK_ChannelAnnouncement_free(int64_t this_obj) {
44065         LDKChannelAnnouncement this_obj_conv;
44066         this_obj_conv.inner = untag_ptr(this_obj);
44067         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44069         ChannelAnnouncement_free(this_obj_conv);
44070 }
44071
44072 int8_tArray  CS_LDK_ChannelAnnouncement_get_node_signature_1(int64_t this_ptr) {
44073         LDKChannelAnnouncement this_ptr_conv;
44074         this_ptr_conv.inner = untag_ptr(this_ptr);
44075         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44077         this_ptr_conv.is_owned = false;
44078         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44079         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
44080         return ret_arr;
44081 }
44082
44083 void  CS_LDK_ChannelAnnouncement_set_node_signature_1(int64_t this_ptr, int8_tArray val) {
44084         LDKChannelAnnouncement this_ptr_conv;
44085         this_ptr_conv.inner = untag_ptr(this_ptr);
44086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44088         this_ptr_conv.is_owned = false;
44089         LDKECDSASignature val_ref;
44090         CHECK(val->arr_len == 64);
44091         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44092         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
44093 }
44094
44095 int8_tArray  CS_LDK_ChannelAnnouncement_get_node_signature_2(int64_t this_ptr) {
44096         LDKChannelAnnouncement this_ptr_conv;
44097         this_ptr_conv.inner = untag_ptr(this_ptr);
44098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44100         this_ptr_conv.is_owned = false;
44101         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44102         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
44103         return ret_arr;
44104 }
44105
44106 void  CS_LDK_ChannelAnnouncement_set_node_signature_2(int64_t this_ptr, int8_tArray val) {
44107         LDKChannelAnnouncement this_ptr_conv;
44108         this_ptr_conv.inner = untag_ptr(this_ptr);
44109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44111         this_ptr_conv.is_owned = false;
44112         LDKECDSASignature val_ref;
44113         CHECK(val->arr_len == 64);
44114         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44115         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
44116 }
44117
44118 int8_tArray  CS_LDK_ChannelAnnouncement_get_bitcoin_signature_1(int64_t this_ptr) {
44119         LDKChannelAnnouncement this_ptr_conv;
44120         this_ptr_conv.inner = untag_ptr(this_ptr);
44121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44123         this_ptr_conv.is_owned = false;
44124         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44125         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
44126         return ret_arr;
44127 }
44128
44129 void  CS_LDK_ChannelAnnouncement_set_bitcoin_signature_1(int64_t this_ptr, int8_tArray val) {
44130         LDKChannelAnnouncement this_ptr_conv;
44131         this_ptr_conv.inner = untag_ptr(this_ptr);
44132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44134         this_ptr_conv.is_owned = false;
44135         LDKECDSASignature val_ref;
44136         CHECK(val->arr_len == 64);
44137         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44138         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
44139 }
44140
44141 int8_tArray  CS_LDK_ChannelAnnouncement_get_bitcoin_signature_2(int64_t this_ptr) {
44142         LDKChannelAnnouncement this_ptr_conv;
44143         this_ptr_conv.inner = untag_ptr(this_ptr);
44144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44146         this_ptr_conv.is_owned = false;
44147         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44148         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
44149         return ret_arr;
44150 }
44151
44152 void  CS_LDK_ChannelAnnouncement_set_bitcoin_signature_2(int64_t this_ptr, int8_tArray val) {
44153         LDKChannelAnnouncement this_ptr_conv;
44154         this_ptr_conv.inner = untag_ptr(this_ptr);
44155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44157         this_ptr_conv.is_owned = false;
44158         LDKECDSASignature val_ref;
44159         CHECK(val->arr_len == 64);
44160         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44161         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
44162 }
44163
44164 int64_t  CS_LDK_ChannelAnnouncement_get_contents(int64_t this_ptr) {
44165         LDKChannelAnnouncement this_ptr_conv;
44166         this_ptr_conv.inner = untag_ptr(this_ptr);
44167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44169         this_ptr_conv.is_owned = false;
44170         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
44171         int64_t ret_ref = 0;
44172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44173         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44174         return ret_ref;
44175 }
44176
44177 void  CS_LDK_ChannelAnnouncement_set_contents(int64_t this_ptr, int64_t val) {
44178         LDKChannelAnnouncement this_ptr_conv;
44179         this_ptr_conv.inner = untag_ptr(this_ptr);
44180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44182         this_ptr_conv.is_owned = false;
44183         LDKUnsignedChannelAnnouncement val_conv;
44184         val_conv.inner = untag_ptr(val);
44185         val_conv.is_owned = ptr_is_owned(val);
44186         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44187         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
44188         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
44189 }
44190
44191 int64_t  CS_LDK_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, int64_t contents_arg) {
44192         LDKECDSASignature node_signature_1_arg_ref;
44193         CHECK(node_signature_1_arg->arr_len == 64);
44194         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
44195         LDKECDSASignature node_signature_2_arg_ref;
44196         CHECK(node_signature_2_arg->arr_len == 64);
44197         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
44198         LDKECDSASignature bitcoin_signature_1_arg_ref;
44199         CHECK(bitcoin_signature_1_arg->arr_len == 64);
44200         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
44201         LDKECDSASignature bitcoin_signature_2_arg_ref;
44202         CHECK(bitcoin_signature_2_arg->arr_len == 64);
44203         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
44204         LDKUnsignedChannelAnnouncement contents_arg_conv;
44205         contents_arg_conv.inner = untag_ptr(contents_arg);
44206         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
44207         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
44208         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
44209         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);
44210         int64_t ret_ref = 0;
44211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44212         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44213         return ret_ref;
44214 }
44215
44216 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
44217         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
44218         int64_t ret_ref = 0;
44219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44220         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44221         return ret_ref;
44222 }
44223 int64_t  CS_LDK_ChannelAnnouncement_clone_ptr(int64_t arg) {
44224         LDKChannelAnnouncement arg_conv;
44225         arg_conv.inner = untag_ptr(arg);
44226         arg_conv.is_owned = ptr_is_owned(arg);
44227         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44228         arg_conv.is_owned = false;
44229         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
44230         return ret_conv;
44231 }
44232
44233 int64_t  CS_LDK_ChannelAnnouncement_clone(int64_t orig) {
44234         LDKChannelAnnouncement orig_conv;
44235         orig_conv.inner = untag_ptr(orig);
44236         orig_conv.is_owned = ptr_is_owned(orig);
44237         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44238         orig_conv.is_owned = false;
44239         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
44240         int64_t ret_ref = 0;
44241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44243         return ret_ref;
44244 }
44245
44246 jboolean  CS_LDK_ChannelAnnouncement_eq(int64_t a, int64_t b) {
44247         LDKChannelAnnouncement a_conv;
44248         a_conv.inner = untag_ptr(a);
44249         a_conv.is_owned = ptr_is_owned(a);
44250         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44251         a_conv.is_owned = false;
44252         LDKChannelAnnouncement b_conv;
44253         b_conv.inner = untag_ptr(b);
44254         b_conv.is_owned = ptr_is_owned(b);
44255         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44256         b_conv.is_owned = false;
44257         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
44258         return ret_conv;
44259 }
44260
44261 void  CS_LDK_UnsignedChannelUpdate_free(int64_t this_obj) {
44262         LDKUnsignedChannelUpdate this_obj_conv;
44263         this_obj_conv.inner = untag_ptr(this_obj);
44264         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44266         UnsignedChannelUpdate_free(this_obj_conv);
44267 }
44268
44269 int8_tArray  CS_LDK_UnsignedChannelUpdate_get_chain_hash(int64_t this_ptr) {
44270         LDKUnsignedChannelUpdate this_ptr_conv;
44271         this_ptr_conv.inner = untag_ptr(this_ptr);
44272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44274         this_ptr_conv.is_owned = false;
44275         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44276         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
44277         return ret_arr;
44278 }
44279
44280 void  CS_LDK_UnsignedChannelUpdate_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44281         LDKUnsignedChannelUpdate this_ptr_conv;
44282         this_ptr_conv.inner = untag_ptr(this_ptr);
44283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44285         this_ptr_conv.is_owned = false;
44286         LDKThirtyTwoBytes val_ref;
44287         CHECK(val->arr_len == 32);
44288         memcpy(val_ref.data, val->elems, 32); FREE(val);
44289         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
44290 }
44291
44292 int64_t  CS_LDK_UnsignedChannelUpdate_get_short_channel_id(int64_t this_ptr) {
44293         LDKUnsignedChannelUpdate this_ptr_conv;
44294         this_ptr_conv.inner = untag_ptr(this_ptr);
44295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44297         this_ptr_conv.is_owned = false;
44298         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
44299         return ret_conv;
44300 }
44301
44302 void  CS_LDK_UnsignedChannelUpdate_set_short_channel_id(int64_t this_ptr, int64_t val) {
44303         LDKUnsignedChannelUpdate this_ptr_conv;
44304         this_ptr_conv.inner = untag_ptr(this_ptr);
44305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44307         this_ptr_conv.is_owned = false;
44308         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
44309 }
44310
44311 int32_t  CS_LDK_UnsignedChannelUpdate_get_timestamp(int64_t this_ptr) {
44312         LDKUnsignedChannelUpdate this_ptr_conv;
44313         this_ptr_conv.inner = untag_ptr(this_ptr);
44314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44316         this_ptr_conv.is_owned = false;
44317         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
44318         return ret_conv;
44319 }
44320
44321 void  CS_LDK_UnsignedChannelUpdate_set_timestamp(int64_t this_ptr, int32_t val) {
44322         LDKUnsignedChannelUpdate this_ptr_conv;
44323         this_ptr_conv.inner = untag_ptr(this_ptr);
44324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44326         this_ptr_conv.is_owned = false;
44327         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
44328 }
44329
44330 int8_t  CS_LDK_UnsignedChannelUpdate_get_flags(int64_t this_ptr) {
44331         LDKUnsignedChannelUpdate this_ptr_conv;
44332         this_ptr_conv.inner = untag_ptr(this_ptr);
44333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44335         this_ptr_conv.is_owned = false;
44336         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
44337         return ret_conv;
44338 }
44339
44340 void  CS_LDK_UnsignedChannelUpdate_set_flags(int64_t this_ptr, int8_t val) {
44341         LDKUnsignedChannelUpdate this_ptr_conv;
44342         this_ptr_conv.inner = untag_ptr(this_ptr);
44343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44345         this_ptr_conv.is_owned = false;
44346         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
44347 }
44348
44349 int16_t  CS_LDK_UnsignedChannelUpdate_get_cltv_expiry_delta(int64_t this_ptr) {
44350         LDKUnsignedChannelUpdate this_ptr_conv;
44351         this_ptr_conv.inner = untag_ptr(this_ptr);
44352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44354         this_ptr_conv.is_owned = false;
44355         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
44356         return ret_conv;
44357 }
44358
44359 void  CS_LDK_UnsignedChannelUpdate_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
44360         LDKUnsignedChannelUpdate this_ptr_conv;
44361         this_ptr_conv.inner = untag_ptr(this_ptr);
44362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44364         this_ptr_conv.is_owned = false;
44365         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
44366 }
44367
44368 int64_t  CS_LDK_UnsignedChannelUpdate_get_htlc_minimum_msat(int64_t this_ptr) {
44369         LDKUnsignedChannelUpdate this_ptr_conv;
44370         this_ptr_conv.inner = untag_ptr(this_ptr);
44371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44373         this_ptr_conv.is_owned = false;
44374         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
44375         return ret_conv;
44376 }
44377
44378 void  CS_LDK_UnsignedChannelUpdate_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
44379         LDKUnsignedChannelUpdate this_ptr_conv;
44380         this_ptr_conv.inner = untag_ptr(this_ptr);
44381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44383         this_ptr_conv.is_owned = false;
44384         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
44385 }
44386
44387 int64_t  CS_LDK_UnsignedChannelUpdate_get_htlc_maximum_msat(int64_t this_ptr) {
44388         LDKUnsignedChannelUpdate this_ptr_conv;
44389         this_ptr_conv.inner = untag_ptr(this_ptr);
44390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44392         this_ptr_conv.is_owned = false;
44393         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
44394         return ret_conv;
44395 }
44396
44397 void  CS_LDK_UnsignedChannelUpdate_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
44398         LDKUnsignedChannelUpdate this_ptr_conv;
44399         this_ptr_conv.inner = untag_ptr(this_ptr);
44400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44402         this_ptr_conv.is_owned = false;
44403         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
44404 }
44405
44406 int32_t  CS_LDK_UnsignedChannelUpdate_get_fee_base_msat(int64_t this_ptr) {
44407         LDKUnsignedChannelUpdate this_ptr_conv;
44408         this_ptr_conv.inner = untag_ptr(this_ptr);
44409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44411         this_ptr_conv.is_owned = false;
44412         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
44413         return ret_conv;
44414 }
44415
44416 void  CS_LDK_UnsignedChannelUpdate_set_fee_base_msat(int64_t this_ptr, int32_t val) {
44417         LDKUnsignedChannelUpdate this_ptr_conv;
44418         this_ptr_conv.inner = untag_ptr(this_ptr);
44419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44421         this_ptr_conv.is_owned = false;
44422         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
44423 }
44424
44425 int32_t  CS_LDK_UnsignedChannelUpdate_get_fee_proportional_millionths(int64_t this_ptr) {
44426         LDKUnsignedChannelUpdate this_ptr_conv;
44427         this_ptr_conv.inner = untag_ptr(this_ptr);
44428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44430         this_ptr_conv.is_owned = false;
44431         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
44432         return ret_conv;
44433 }
44434
44435 void  CS_LDK_UnsignedChannelUpdate_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
44436         LDKUnsignedChannelUpdate this_ptr_conv;
44437         this_ptr_conv.inner = untag_ptr(this_ptr);
44438         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44440         this_ptr_conv.is_owned = false;
44441         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
44442 }
44443
44444 int8_tArray  CS_LDK_UnsignedChannelUpdate_get_excess_data(int64_t this_ptr) {
44445         LDKUnsignedChannelUpdate this_ptr_conv;
44446         this_ptr_conv.inner = untag_ptr(this_ptr);
44447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44449         this_ptr_conv.is_owned = false;
44450         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
44451         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
44452         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
44453         CVec_u8Z_free(ret_var);
44454         return ret_arr;
44455 }
44456
44457 void  CS_LDK_UnsignedChannelUpdate_set_excess_data(int64_t this_ptr, int8_tArray val) {
44458         LDKUnsignedChannelUpdate this_ptr_conv;
44459         this_ptr_conv.inner = untag_ptr(this_ptr);
44460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44462         this_ptr_conv.is_owned = false;
44463         LDKCVec_u8Z val_ref;
44464         val_ref.datalen = val->arr_len;
44465         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
44466         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
44467         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
44468 }
44469
44470 int64_t  CS_LDK_UnsignedChannelUpdate_new(int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
44471         LDKThirtyTwoBytes chain_hash_arg_ref;
44472         CHECK(chain_hash_arg->arr_len == 32);
44473         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
44474         LDKCVec_u8Z excess_data_arg_ref;
44475         excess_data_arg_ref.datalen = excess_data_arg->arr_len;
44476         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
44477         memcpy(excess_data_arg_ref.data, excess_data_arg->elems, excess_data_arg_ref.datalen); FREE(excess_data_arg);
44478         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
44479         int64_t ret_ref = 0;
44480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44481         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44482         return ret_ref;
44483 }
44484
44485 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
44486         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
44487         int64_t ret_ref = 0;
44488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44489         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44490         return ret_ref;
44491 }
44492 int64_t  CS_LDK_UnsignedChannelUpdate_clone_ptr(int64_t arg) {
44493         LDKUnsignedChannelUpdate arg_conv;
44494         arg_conv.inner = untag_ptr(arg);
44495         arg_conv.is_owned = ptr_is_owned(arg);
44496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44497         arg_conv.is_owned = false;
44498         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
44499         return ret_conv;
44500 }
44501
44502 int64_t  CS_LDK_UnsignedChannelUpdate_clone(int64_t orig) {
44503         LDKUnsignedChannelUpdate orig_conv;
44504         orig_conv.inner = untag_ptr(orig);
44505         orig_conv.is_owned = ptr_is_owned(orig);
44506         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44507         orig_conv.is_owned = false;
44508         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
44509         int64_t ret_ref = 0;
44510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44512         return ret_ref;
44513 }
44514
44515 jboolean  CS_LDK_UnsignedChannelUpdate_eq(int64_t a, int64_t b) {
44516         LDKUnsignedChannelUpdate a_conv;
44517         a_conv.inner = untag_ptr(a);
44518         a_conv.is_owned = ptr_is_owned(a);
44519         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44520         a_conv.is_owned = false;
44521         LDKUnsignedChannelUpdate b_conv;
44522         b_conv.inner = untag_ptr(b);
44523         b_conv.is_owned = ptr_is_owned(b);
44524         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44525         b_conv.is_owned = false;
44526         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
44527         return ret_conv;
44528 }
44529
44530 void  CS_LDK_ChannelUpdate_free(int64_t this_obj) {
44531         LDKChannelUpdate this_obj_conv;
44532         this_obj_conv.inner = untag_ptr(this_obj);
44533         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44535         ChannelUpdate_free(this_obj_conv);
44536 }
44537
44538 int8_tArray  CS_LDK_ChannelUpdate_get_signature(int64_t this_ptr) {
44539         LDKChannelUpdate this_ptr_conv;
44540         this_ptr_conv.inner = untag_ptr(this_ptr);
44541         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44543         this_ptr_conv.is_owned = false;
44544         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
44545         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
44546         return ret_arr;
44547 }
44548
44549 void  CS_LDK_ChannelUpdate_set_signature(int64_t this_ptr, int8_tArray val) {
44550         LDKChannelUpdate this_ptr_conv;
44551         this_ptr_conv.inner = untag_ptr(this_ptr);
44552         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44554         this_ptr_conv.is_owned = false;
44555         LDKECDSASignature val_ref;
44556         CHECK(val->arr_len == 64);
44557         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
44558         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
44559 }
44560
44561 int64_t  CS_LDK_ChannelUpdate_get_contents(int64_t this_ptr) {
44562         LDKChannelUpdate this_ptr_conv;
44563         this_ptr_conv.inner = untag_ptr(this_ptr);
44564         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44566         this_ptr_conv.is_owned = false;
44567         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
44568         int64_t ret_ref = 0;
44569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44570         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44571         return ret_ref;
44572 }
44573
44574 void  CS_LDK_ChannelUpdate_set_contents(int64_t this_ptr, int64_t val) {
44575         LDKChannelUpdate this_ptr_conv;
44576         this_ptr_conv.inner = untag_ptr(this_ptr);
44577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44579         this_ptr_conv.is_owned = false;
44580         LDKUnsignedChannelUpdate val_conv;
44581         val_conv.inner = untag_ptr(val);
44582         val_conv.is_owned = ptr_is_owned(val);
44583         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44584         val_conv = UnsignedChannelUpdate_clone(&val_conv);
44585         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
44586 }
44587
44588 int64_t  CS_LDK_ChannelUpdate_new(int8_tArray signature_arg, int64_t contents_arg) {
44589         LDKECDSASignature signature_arg_ref;
44590         CHECK(signature_arg->arr_len == 64);
44591         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
44592         LDKUnsignedChannelUpdate contents_arg_conv;
44593         contents_arg_conv.inner = untag_ptr(contents_arg);
44594         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
44595         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
44596         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
44597         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
44598         int64_t ret_ref = 0;
44599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44601         return ret_ref;
44602 }
44603
44604 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
44605         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
44606         int64_t ret_ref = 0;
44607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44609         return ret_ref;
44610 }
44611 int64_t  CS_LDK_ChannelUpdate_clone_ptr(int64_t arg) {
44612         LDKChannelUpdate arg_conv;
44613         arg_conv.inner = untag_ptr(arg);
44614         arg_conv.is_owned = ptr_is_owned(arg);
44615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44616         arg_conv.is_owned = false;
44617         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
44618         return ret_conv;
44619 }
44620
44621 int64_t  CS_LDK_ChannelUpdate_clone(int64_t orig) {
44622         LDKChannelUpdate orig_conv;
44623         orig_conv.inner = untag_ptr(orig);
44624         orig_conv.is_owned = ptr_is_owned(orig);
44625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44626         orig_conv.is_owned = false;
44627         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
44628         int64_t ret_ref = 0;
44629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44631         return ret_ref;
44632 }
44633
44634 jboolean  CS_LDK_ChannelUpdate_eq(int64_t a, int64_t b) {
44635         LDKChannelUpdate a_conv;
44636         a_conv.inner = untag_ptr(a);
44637         a_conv.is_owned = ptr_is_owned(a);
44638         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44639         a_conv.is_owned = false;
44640         LDKChannelUpdate b_conv;
44641         b_conv.inner = untag_ptr(b);
44642         b_conv.is_owned = ptr_is_owned(b);
44643         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44644         b_conv.is_owned = false;
44645         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
44646         return ret_conv;
44647 }
44648
44649 void  CS_LDK_QueryChannelRange_free(int64_t this_obj) {
44650         LDKQueryChannelRange this_obj_conv;
44651         this_obj_conv.inner = untag_ptr(this_obj);
44652         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44654         QueryChannelRange_free(this_obj_conv);
44655 }
44656
44657 int8_tArray  CS_LDK_QueryChannelRange_get_chain_hash(int64_t this_ptr) {
44658         LDKQueryChannelRange this_ptr_conv;
44659         this_ptr_conv.inner = untag_ptr(this_ptr);
44660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44662         this_ptr_conv.is_owned = false;
44663         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44664         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
44665         return ret_arr;
44666 }
44667
44668 void  CS_LDK_QueryChannelRange_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44669         LDKQueryChannelRange this_ptr_conv;
44670         this_ptr_conv.inner = untag_ptr(this_ptr);
44671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44673         this_ptr_conv.is_owned = false;
44674         LDKThirtyTwoBytes val_ref;
44675         CHECK(val->arr_len == 32);
44676         memcpy(val_ref.data, val->elems, 32); FREE(val);
44677         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
44678 }
44679
44680 int32_t  CS_LDK_QueryChannelRange_get_first_blocknum(int64_t this_ptr) {
44681         LDKQueryChannelRange this_ptr_conv;
44682         this_ptr_conv.inner = untag_ptr(this_ptr);
44683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44685         this_ptr_conv.is_owned = false;
44686         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
44687         return ret_conv;
44688 }
44689
44690 void  CS_LDK_QueryChannelRange_set_first_blocknum(int64_t this_ptr, int32_t val) {
44691         LDKQueryChannelRange this_ptr_conv;
44692         this_ptr_conv.inner = untag_ptr(this_ptr);
44693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44695         this_ptr_conv.is_owned = false;
44696         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
44697 }
44698
44699 int32_t  CS_LDK_QueryChannelRange_get_number_of_blocks(int64_t this_ptr) {
44700         LDKQueryChannelRange this_ptr_conv;
44701         this_ptr_conv.inner = untag_ptr(this_ptr);
44702         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44704         this_ptr_conv.is_owned = false;
44705         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
44706         return ret_conv;
44707 }
44708
44709 void  CS_LDK_QueryChannelRange_set_number_of_blocks(int64_t this_ptr, int32_t val) {
44710         LDKQueryChannelRange this_ptr_conv;
44711         this_ptr_conv.inner = untag_ptr(this_ptr);
44712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44714         this_ptr_conv.is_owned = false;
44715         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
44716 }
44717
44718 int64_t  CS_LDK_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
44719         LDKThirtyTwoBytes chain_hash_arg_ref;
44720         CHECK(chain_hash_arg->arr_len == 32);
44721         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
44722         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
44723         int64_t ret_ref = 0;
44724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44726         return ret_ref;
44727 }
44728
44729 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
44730         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
44731         int64_t ret_ref = 0;
44732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44733         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44734         return ret_ref;
44735 }
44736 int64_t  CS_LDK_QueryChannelRange_clone_ptr(int64_t arg) {
44737         LDKQueryChannelRange arg_conv;
44738         arg_conv.inner = untag_ptr(arg);
44739         arg_conv.is_owned = ptr_is_owned(arg);
44740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44741         arg_conv.is_owned = false;
44742         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
44743         return ret_conv;
44744 }
44745
44746 int64_t  CS_LDK_QueryChannelRange_clone(int64_t orig) {
44747         LDKQueryChannelRange orig_conv;
44748         orig_conv.inner = untag_ptr(orig);
44749         orig_conv.is_owned = ptr_is_owned(orig);
44750         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44751         orig_conv.is_owned = false;
44752         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
44753         int64_t ret_ref = 0;
44754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44755         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44756         return ret_ref;
44757 }
44758
44759 jboolean  CS_LDK_QueryChannelRange_eq(int64_t a, int64_t b) {
44760         LDKQueryChannelRange a_conv;
44761         a_conv.inner = untag_ptr(a);
44762         a_conv.is_owned = ptr_is_owned(a);
44763         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44764         a_conv.is_owned = false;
44765         LDKQueryChannelRange b_conv;
44766         b_conv.inner = untag_ptr(b);
44767         b_conv.is_owned = ptr_is_owned(b);
44768         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44769         b_conv.is_owned = false;
44770         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
44771         return ret_conv;
44772 }
44773
44774 void  CS_LDK_ReplyChannelRange_free(int64_t this_obj) {
44775         LDKReplyChannelRange this_obj_conv;
44776         this_obj_conv.inner = untag_ptr(this_obj);
44777         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44779         ReplyChannelRange_free(this_obj_conv);
44780 }
44781
44782 int8_tArray  CS_LDK_ReplyChannelRange_get_chain_hash(int64_t this_ptr) {
44783         LDKReplyChannelRange this_ptr_conv;
44784         this_ptr_conv.inner = untag_ptr(this_ptr);
44785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44787         this_ptr_conv.is_owned = false;
44788         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44789         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
44790         return ret_arr;
44791 }
44792
44793 void  CS_LDK_ReplyChannelRange_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44794         LDKReplyChannelRange this_ptr_conv;
44795         this_ptr_conv.inner = untag_ptr(this_ptr);
44796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44798         this_ptr_conv.is_owned = false;
44799         LDKThirtyTwoBytes val_ref;
44800         CHECK(val->arr_len == 32);
44801         memcpy(val_ref.data, val->elems, 32); FREE(val);
44802         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
44803 }
44804
44805 int32_t  CS_LDK_ReplyChannelRange_get_first_blocknum(int64_t this_ptr) {
44806         LDKReplyChannelRange this_ptr_conv;
44807         this_ptr_conv.inner = untag_ptr(this_ptr);
44808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44810         this_ptr_conv.is_owned = false;
44811         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
44812         return ret_conv;
44813 }
44814
44815 void  CS_LDK_ReplyChannelRange_set_first_blocknum(int64_t this_ptr, int32_t val) {
44816         LDKReplyChannelRange this_ptr_conv;
44817         this_ptr_conv.inner = untag_ptr(this_ptr);
44818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44820         this_ptr_conv.is_owned = false;
44821         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
44822 }
44823
44824 int32_t  CS_LDK_ReplyChannelRange_get_number_of_blocks(int64_t this_ptr) {
44825         LDKReplyChannelRange this_ptr_conv;
44826         this_ptr_conv.inner = untag_ptr(this_ptr);
44827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44829         this_ptr_conv.is_owned = false;
44830         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
44831         return ret_conv;
44832 }
44833
44834 void  CS_LDK_ReplyChannelRange_set_number_of_blocks(int64_t this_ptr, int32_t val) {
44835         LDKReplyChannelRange this_ptr_conv;
44836         this_ptr_conv.inner = untag_ptr(this_ptr);
44837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44839         this_ptr_conv.is_owned = false;
44840         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
44841 }
44842
44843 jboolean  CS_LDK_ReplyChannelRange_get_sync_complete(int64_t this_ptr) {
44844         LDKReplyChannelRange this_ptr_conv;
44845         this_ptr_conv.inner = untag_ptr(this_ptr);
44846         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44848         this_ptr_conv.is_owned = false;
44849         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
44850         return ret_conv;
44851 }
44852
44853 void  CS_LDK_ReplyChannelRange_set_sync_complete(int64_t this_ptr, jboolean val) {
44854         LDKReplyChannelRange this_ptr_conv;
44855         this_ptr_conv.inner = untag_ptr(this_ptr);
44856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44858         this_ptr_conv.is_owned = false;
44859         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
44860 }
44861
44862 int64_tArray  CS_LDK_ReplyChannelRange_get_short_channel_ids(int64_t this_ptr) {
44863         LDKReplyChannelRange this_ptr_conv;
44864         this_ptr_conv.inner = untag_ptr(this_ptr);
44865         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44867         this_ptr_conv.is_owned = false;
44868         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
44869         int64_tArray ret_arr = NULL;
44870         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
44871         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
44872         for (size_t g = 0; g < ret_var.datalen; g++) {
44873                 int64_t ret_conv_6_conv = ret_var.data[g];
44874                 ret_arr_ptr[g] = ret_conv_6_conv;
44875         }
44876         
44877         FREE(ret_var.data);
44878         return ret_arr;
44879 }
44880
44881 void  CS_LDK_ReplyChannelRange_set_short_channel_ids(int64_t this_ptr, int64_tArray val) {
44882         LDKReplyChannelRange this_ptr_conv;
44883         this_ptr_conv.inner = untag_ptr(this_ptr);
44884         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44886         this_ptr_conv.is_owned = false;
44887         LDKCVec_u64Z val_constr;
44888         val_constr.datalen = val->arr_len;
44889         if (val_constr.datalen > 0)
44890                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44891         else
44892                 val_constr.data = NULL;
44893         int64_t* val_vals = val->elems;
44894         for (size_t g = 0; g < val_constr.datalen; g++) {
44895                 int64_t val_conv_6 = val_vals[g];
44896                 val_constr.data[g] = val_conv_6;
44897         }
44898         FREE(val);
44899         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
44900 }
44901
44902 int64_t  CS_LDK_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) {
44903         LDKThirtyTwoBytes chain_hash_arg_ref;
44904         CHECK(chain_hash_arg->arr_len == 32);
44905         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
44906         LDKCVec_u64Z short_channel_ids_arg_constr;
44907         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
44908         if (short_channel_ids_arg_constr.datalen > 0)
44909                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44910         else
44911                 short_channel_ids_arg_constr.data = NULL;
44912         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
44913         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
44914                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
44915                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
44916         }
44917         FREE(short_channel_ids_arg);
44918         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
44919         int64_t ret_ref = 0;
44920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44922         return ret_ref;
44923 }
44924
44925 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
44926         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
44927         int64_t ret_ref = 0;
44928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44930         return ret_ref;
44931 }
44932 int64_t  CS_LDK_ReplyChannelRange_clone_ptr(int64_t arg) {
44933         LDKReplyChannelRange arg_conv;
44934         arg_conv.inner = untag_ptr(arg);
44935         arg_conv.is_owned = ptr_is_owned(arg);
44936         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44937         arg_conv.is_owned = false;
44938         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
44939         return ret_conv;
44940 }
44941
44942 int64_t  CS_LDK_ReplyChannelRange_clone(int64_t orig) {
44943         LDKReplyChannelRange orig_conv;
44944         orig_conv.inner = untag_ptr(orig);
44945         orig_conv.is_owned = ptr_is_owned(orig);
44946         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44947         orig_conv.is_owned = false;
44948         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
44949         int64_t ret_ref = 0;
44950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44952         return ret_ref;
44953 }
44954
44955 jboolean  CS_LDK_ReplyChannelRange_eq(int64_t a, int64_t b) {
44956         LDKReplyChannelRange a_conv;
44957         a_conv.inner = untag_ptr(a);
44958         a_conv.is_owned = ptr_is_owned(a);
44959         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44960         a_conv.is_owned = false;
44961         LDKReplyChannelRange b_conv;
44962         b_conv.inner = untag_ptr(b);
44963         b_conv.is_owned = ptr_is_owned(b);
44964         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44965         b_conv.is_owned = false;
44966         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
44967         return ret_conv;
44968 }
44969
44970 void  CS_LDK_QueryShortChannelIds_free(int64_t this_obj) {
44971         LDKQueryShortChannelIds this_obj_conv;
44972         this_obj_conv.inner = untag_ptr(this_obj);
44973         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44975         QueryShortChannelIds_free(this_obj_conv);
44976 }
44977
44978 int8_tArray  CS_LDK_QueryShortChannelIds_get_chain_hash(int64_t this_ptr) {
44979         LDKQueryShortChannelIds this_ptr_conv;
44980         this_ptr_conv.inner = untag_ptr(this_ptr);
44981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44983         this_ptr_conv.is_owned = false;
44984         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
44985         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
44986         return ret_arr;
44987 }
44988
44989 void  CS_LDK_QueryShortChannelIds_set_chain_hash(int64_t this_ptr, int8_tArray val) {
44990         LDKQueryShortChannelIds this_ptr_conv;
44991         this_ptr_conv.inner = untag_ptr(this_ptr);
44992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44994         this_ptr_conv.is_owned = false;
44995         LDKThirtyTwoBytes val_ref;
44996         CHECK(val->arr_len == 32);
44997         memcpy(val_ref.data, val->elems, 32); FREE(val);
44998         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
44999 }
45000
45001 int64_tArray  CS_LDK_QueryShortChannelIds_get_short_channel_ids(int64_t this_ptr) {
45002         LDKQueryShortChannelIds this_ptr_conv;
45003         this_ptr_conv.inner = untag_ptr(this_ptr);
45004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45006         this_ptr_conv.is_owned = false;
45007         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
45008         int64_tArray ret_arr = NULL;
45009         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45010         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45011         for (size_t g = 0; g < ret_var.datalen; g++) {
45012                 int64_t ret_conv_6_conv = ret_var.data[g];
45013                 ret_arr_ptr[g] = ret_conv_6_conv;
45014         }
45015         
45016         FREE(ret_var.data);
45017         return ret_arr;
45018 }
45019
45020 void  CS_LDK_QueryShortChannelIds_set_short_channel_ids(int64_t this_ptr, int64_tArray val) {
45021         LDKQueryShortChannelIds this_ptr_conv;
45022         this_ptr_conv.inner = untag_ptr(this_ptr);
45023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45025         this_ptr_conv.is_owned = false;
45026         LDKCVec_u64Z val_constr;
45027         val_constr.datalen = val->arr_len;
45028         if (val_constr.datalen > 0)
45029                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45030         else
45031                 val_constr.data = NULL;
45032         int64_t* val_vals = val->elems;
45033         for (size_t g = 0; g < val_constr.datalen; g++) {
45034                 int64_t val_conv_6 = val_vals[g];
45035                 val_constr.data[g] = val_conv_6;
45036         }
45037         FREE(val);
45038         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
45039 }
45040
45041 int64_t  CS_LDK_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
45042         LDKThirtyTwoBytes chain_hash_arg_ref;
45043         CHECK(chain_hash_arg->arr_len == 32);
45044         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
45045         LDKCVec_u64Z short_channel_ids_arg_constr;
45046         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
45047         if (short_channel_ids_arg_constr.datalen > 0)
45048                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
45049         else
45050                 short_channel_ids_arg_constr.data = NULL;
45051         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems;
45052         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
45053                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
45054                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
45055         }
45056         FREE(short_channel_ids_arg);
45057         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
45058         int64_t ret_ref = 0;
45059         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45060         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45061         return ret_ref;
45062 }
45063
45064 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
45065         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
45066         int64_t ret_ref = 0;
45067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45069         return ret_ref;
45070 }
45071 int64_t  CS_LDK_QueryShortChannelIds_clone_ptr(int64_t arg) {
45072         LDKQueryShortChannelIds arg_conv;
45073         arg_conv.inner = untag_ptr(arg);
45074         arg_conv.is_owned = ptr_is_owned(arg);
45075         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45076         arg_conv.is_owned = false;
45077         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
45078         return ret_conv;
45079 }
45080
45081 int64_t  CS_LDK_QueryShortChannelIds_clone(int64_t orig) {
45082         LDKQueryShortChannelIds orig_conv;
45083         orig_conv.inner = untag_ptr(orig);
45084         orig_conv.is_owned = ptr_is_owned(orig);
45085         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45086         orig_conv.is_owned = false;
45087         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
45088         int64_t ret_ref = 0;
45089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45091         return ret_ref;
45092 }
45093
45094 jboolean  CS_LDK_QueryShortChannelIds_eq(int64_t a, int64_t b) {
45095         LDKQueryShortChannelIds a_conv;
45096         a_conv.inner = untag_ptr(a);
45097         a_conv.is_owned = ptr_is_owned(a);
45098         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45099         a_conv.is_owned = false;
45100         LDKQueryShortChannelIds b_conv;
45101         b_conv.inner = untag_ptr(b);
45102         b_conv.is_owned = ptr_is_owned(b);
45103         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45104         b_conv.is_owned = false;
45105         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
45106         return ret_conv;
45107 }
45108
45109 void  CS_LDK_ReplyShortChannelIdsEnd_free(int64_t this_obj) {
45110         LDKReplyShortChannelIdsEnd this_obj_conv;
45111         this_obj_conv.inner = untag_ptr(this_obj);
45112         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45114         ReplyShortChannelIdsEnd_free(this_obj_conv);
45115 }
45116
45117 int8_tArray  CS_LDK_ReplyShortChannelIdsEnd_get_chain_hash(int64_t this_ptr) {
45118         LDKReplyShortChannelIdsEnd this_ptr_conv;
45119         this_ptr_conv.inner = untag_ptr(this_ptr);
45120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45122         this_ptr_conv.is_owned = false;
45123         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45124         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
45125         return ret_arr;
45126 }
45127
45128 void  CS_LDK_ReplyShortChannelIdsEnd_set_chain_hash(int64_t this_ptr, int8_tArray val) {
45129         LDKReplyShortChannelIdsEnd this_ptr_conv;
45130         this_ptr_conv.inner = untag_ptr(this_ptr);
45131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45133         this_ptr_conv.is_owned = false;
45134         LDKThirtyTwoBytes val_ref;
45135         CHECK(val->arr_len == 32);
45136         memcpy(val_ref.data, val->elems, 32); FREE(val);
45137         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
45138 }
45139
45140 jboolean  CS_LDK_ReplyShortChannelIdsEnd_get_full_information(int64_t this_ptr) {
45141         LDKReplyShortChannelIdsEnd this_ptr_conv;
45142         this_ptr_conv.inner = untag_ptr(this_ptr);
45143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45145         this_ptr_conv.is_owned = false;
45146         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
45147         return ret_conv;
45148 }
45149
45150 void  CS_LDK_ReplyShortChannelIdsEnd_set_full_information(int64_t this_ptr, jboolean val) {
45151         LDKReplyShortChannelIdsEnd this_ptr_conv;
45152         this_ptr_conv.inner = untag_ptr(this_ptr);
45153         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45155         this_ptr_conv.is_owned = false;
45156         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
45157 }
45158
45159 int64_t  CS_LDK_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
45160         LDKThirtyTwoBytes chain_hash_arg_ref;
45161         CHECK(chain_hash_arg->arr_len == 32);
45162         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
45163         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
45164         int64_t ret_ref = 0;
45165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45166         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45167         return ret_ref;
45168 }
45169
45170 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
45171         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
45172         int64_t ret_ref = 0;
45173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45175         return ret_ref;
45176 }
45177 int64_t  CS_LDK_ReplyShortChannelIdsEnd_clone_ptr(int64_t arg) {
45178         LDKReplyShortChannelIdsEnd arg_conv;
45179         arg_conv.inner = untag_ptr(arg);
45180         arg_conv.is_owned = ptr_is_owned(arg);
45181         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45182         arg_conv.is_owned = false;
45183         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
45184         return ret_conv;
45185 }
45186
45187 int64_t  CS_LDK_ReplyShortChannelIdsEnd_clone(int64_t orig) {
45188         LDKReplyShortChannelIdsEnd orig_conv;
45189         orig_conv.inner = untag_ptr(orig);
45190         orig_conv.is_owned = ptr_is_owned(orig);
45191         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45192         orig_conv.is_owned = false;
45193         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
45194         int64_t ret_ref = 0;
45195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45197         return ret_ref;
45198 }
45199
45200 jboolean  CS_LDK_ReplyShortChannelIdsEnd_eq(int64_t a, int64_t b) {
45201         LDKReplyShortChannelIdsEnd a_conv;
45202         a_conv.inner = untag_ptr(a);
45203         a_conv.is_owned = ptr_is_owned(a);
45204         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45205         a_conv.is_owned = false;
45206         LDKReplyShortChannelIdsEnd b_conv;
45207         b_conv.inner = untag_ptr(b);
45208         b_conv.is_owned = ptr_is_owned(b);
45209         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45210         b_conv.is_owned = false;
45211         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
45212         return ret_conv;
45213 }
45214
45215 void  CS_LDK_GossipTimestampFilter_free(int64_t this_obj) {
45216         LDKGossipTimestampFilter this_obj_conv;
45217         this_obj_conv.inner = untag_ptr(this_obj);
45218         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45220         GossipTimestampFilter_free(this_obj_conv);
45221 }
45222
45223 int8_tArray  CS_LDK_GossipTimestampFilter_get_chain_hash(int64_t this_ptr) {
45224         LDKGossipTimestampFilter this_ptr_conv;
45225         this_ptr_conv.inner = untag_ptr(this_ptr);
45226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45228         this_ptr_conv.is_owned = false;
45229         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
45230         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
45231         return ret_arr;
45232 }
45233
45234 void  CS_LDK_GossipTimestampFilter_set_chain_hash(int64_t this_ptr, int8_tArray val) {
45235         LDKGossipTimestampFilter this_ptr_conv;
45236         this_ptr_conv.inner = untag_ptr(this_ptr);
45237         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45239         this_ptr_conv.is_owned = false;
45240         LDKThirtyTwoBytes val_ref;
45241         CHECK(val->arr_len == 32);
45242         memcpy(val_ref.data, val->elems, 32); FREE(val);
45243         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
45244 }
45245
45246 int32_t  CS_LDK_GossipTimestampFilter_get_first_timestamp(int64_t this_ptr) {
45247         LDKGossipTimestampFilter this_ptr_conv;
45248         this_ptr_conv.inner = untag_ptr(this_ptr);
45249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45251         this_ptr_conv.is_owned = false;
45252         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
45253         return ret_conv;
45254 }
45255
45256 void  CS_LDK_GossipTimestampFilter_set_first_timestamp(int64_t this_ptr, int32_t val) {
45257         LDKGossipTimestampFilter this_ptr_conv;
45258         this_ptr_conv.inner = untag_ptr(this_ptr);
45259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45261         this_ptr_conv.is_owned = false;
45262         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
45263 }
45264
45265 int32_t  CS_LDK_GossipTimestampFilter_get_timestamp_range(int64_t this_ptr) {
45266         LDKGossipTimestampFilter this_ptr_conv;
45267         this_ptr_conv.inner = untag_ptr(this_ptr);
45268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45270         this_ptr_conv.is_owned = false;
45271         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
45272         return ret_conv;
45273 }
45274
45275 void  CS_LDK_GossipTimestampFilter_set_timestamp_range(int64_t this_ptr, int32_t val) {
45276         LDKGossipTimestampFilter this_ptr_conv;
45277         this_ptr_conv.inner = untag_ptr(this_ptr);
45278         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45280         this_ptr_conv.is_owned = false;
45281         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
45282 }
45283
45284 int64_t  CS_LDK_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
45285         LDKThirtyTwoBytes chain_hash_arg_ref;
45286         CHECK(chain_hash_arg->arr_len == 32);
45287         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
45288         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
45289         int64_t ret_ref = 0;
45290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45292         return ret_ref;
45293 }
45294
45295 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
45296         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
45297         int64_t ret_ref = 0;
45298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45299         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45300         return ret_ref;
45301 }
45302 int64_t  CS_LDK_GossipTimestampFilter_clone_ptr(int64_t arg) {
45303         LDKGossipTimestampFilter arg_conv;
45304         arg_conv.inner = untag_ptr(arg);
45305         arg_conv.is_owned = ptr_is_owned(arg);
45306         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45307         arg_conv.is_owned = false;
45308         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
45309         return ret_conv;
45310 }
45311
45312 int64_t  CS_LDK_GossipTimestampFilter_clone(int64_t orig) {
45313         LDKGossipTimestampFilter orig_conv;
45314         orig_conv.inner = untag_ptr(orig);
45315         orig_conv.is_owned = ptr_is_owned(orig);
45316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45317         orig_conv.is_owned = false;
45318         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
45319         int64_t ret_ref = 0;
45320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45322         return ret_ref;
45323 }
45324
45325 jboolean  CS_LDK_GossipTimestampFilter_eq(int64_t a, int64_t b) {
45326         LDKGossipTimestampFilter a_conv;
45327         a_conv.inner = untag_ptr(a);
45328         a_conv.is_owned = ptr_is_owned(a);
45329         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45330         a_conv.is_owned = false;
45331         LDKGossipTimestampFilter b_conv;
45332         b_conv.inner = untag_ptr(b);
45333         b_conv.is_owned = ptr_is_owned(b);
45334         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45335         b_conv.is_owned = false;
45336         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
45337         return ret_conv;
45338 }
45339
45340 void  CS_LDK_ErrorAction_free(int64_t this_ptr) {
45341         if (!ptr_is_owned(this_ptr)) return;
45342         void* this_ptr_ptr = untag_ptr(this_ptr);
45343         CHECK_ACCESS(this_ptr_ptr);
45344         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
45345         FREE(untag_ptr(this_ptr));
45346         ErrorAction_free(this_ptr_conv);
45347 }
45348
45349 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
45350         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45351         *ret_copy = ErrorAction_clone(arg);
45352         int64_t ret_ref = tag_ptr(ret_copy, true);
45353         return ret_ref;
45354 }
45355 int64_t  CS_LDK_ErrorAction_clone_ptr(int64_t arg) {
45356         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
45357         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
45358         return ret_conv;
45359 }
45360
45361 int64_t  CS_LDK_ErrorAction_clone(int64_t orig) {
45362         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
45363         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45364         *ret_copy = ErrorAction_clone(orig_conv);
45365         int64_t ret_ref = tag_ptr(ret_copy, true);
45366         return ret_ref;
45367 }
45368
45369 int64_t  CS_LDK_ErrorAction_disconnect_peer(int64_t msg) {
45370         LDKErrorMessage msg_conv;
45371         msg_conv.inner = untag_ptr(msg);
45372         msg_conv.is_owned = ptr_is_owned(msg);
45373         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45374         msg_conv = ErrorMessage_clone(&msg_conv);
45375         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45376         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
45377         int64_t ret_ref = tag_ptr(ret_copy, true);
45378         return ret_ref;
45379 }
45380
45381 int64_t  CS_LDK_ErrorAction_disconnect_peer_with_warning(int64_t msg) {
45382         LDKWarningMessage msg_conv;
45383         msg_conv.inner = untag_ptr(msg);
45384         msg_conv.is_owned = ptr_is_owned(msg);
45385         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45386         msg_conv = WarningMessage_clone(&msg_conv);
45387         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45388         *ret_copy = ErrorAction_disconnect_peer_with_warning(msg_conv);
45389         int64_t ret_ref = tag_ptr(ret_copy, true);
45390         return ret_ref;
45391 }
45392
45393 int64_t  CS_LDK_ErrorAction_ignore_error() {
45394         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45395         *ret_copy = ErrorAction_ignore_error();
45396         int64_t ret_ref = tag_ptr(ret_copy, true);
45397         return ret_ref;
45398 }
45399
45400 int64_t  CS_LDK_ErrorAction_ignore_and_log(int32_t a) {
45401         LDKLevel a_conv = LDKLevel_from_cs(a);
45402         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45403         *ret_copy = ErrorAction_ignore_and_log(a_conv);
45404         int64_t ret_ref = tag_ptr(ret_copy, true);
45405         return ret_ref;
45406 }
45407
45408 int64_t  CS_LDK_ErrorAction_ignore_duplicate_gossip() {
45409         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45410         *ret_copy = ErrorAction_ignore_duplicate_gossip();
45411         int64_t ret_ref = tag_ptr(ret_copy, true);
45412         return ret_ref;
45413 }
45414
45415 int64_t  CS_LDK_ErrorAction_send_error_message(int64_t msg) {
45416         LDKErrorMessage msg_conv;
45417         msg_conv.inner = untag_ptr(msg);
45418         msg_conv.is_owned = ptr_is_owned(msg);
45419         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45420         msg_conv = ErrorMessage_clone(&msg_conv);
45421         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45422         *ret_copy = ErrorAction_send_error_message(msg_conv);
45423         int64_t ret_ref = tag_ptr(ret_copy, true);
45424         return ret_ref;
45425 }
45426
45427 int64_t  CS_LDK_ErrorAction_send_warning_message(int64_t msg, int32_t log_level) {
45428         LDKWarningMessage msg_conv;
45429         msg_conv.inner = untag_ptr(msg);
45430         msg_conv.is_owned = ptr_is_owned(msg);
45431         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45432         msg_conv = WarningMessage_clone(&msg_conv);
45433         LDKLevel log_level_conv = LDKLevel_from_cs(log_level);
45434         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45435         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
45436         int64_t ret_ref = tag_ptr(ret_copy, true);
45437         return ret_ref;
45438 }
45439
45440 void  CS_LDK_LightningError_free(int64_t this_obj) {
45441         LDKLightningError this_obj_conv;
45442         this_obj_conv.inner = untag_ptr(this_obj);
45443         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45445         LightningError_free(this_obj_conv);
45446 }
45447
45448 jstring  CS_LDK_LightningError_get_err(int64_t this_ptr) {
45449         LDKLightningError this_ptr_conv;
45450         this_ptr_conv.inner = untag_ptr(this_ptr);
45451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45453         this_ptr_conv.is_owned = false;
45454         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
45455         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
45456         Str_free(ret_str);
45457         return ret_conv;
45458 }
45459
45460 void  CS_LDK_LightningError_set_err(int64_t this_ptr, jstring val) {
45461         LDKLightningError this_ptr_conv;
45462         this_ptr_conv.inner = untag_ptr(this_ptr);
45463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45465         this_ptr_conv.is_owned = false;
45466         LDKStr val_conv = str_ref_to_owned_c(val);
45467         LightningError_set_err(&this_ptr_conv, val_conv);
45468 }
45469
45470 int64_t  CS_LDK_LightningError_get_action(int64_t this_ptr) {
45471         LDKLightningError this_ptr_conv;
45472         this_ptr_conv.inner = untag_ptr(this_ptr);
45473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45475         this_ptr_conv.is_owned = false;
45476         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
45477         *ret_copy = LightningError_get_action(&this_ptr_conv);
45478         int64_t ret_ref = tag_ptr(ret_copy, true);
45479         return ret_ref;
45480 }
45481
45482 void  CS_LDK_LightningError_set_action(int64_t this_ptr, int64_t val) {
45483         LDKLightningError this_ptr_conv;
45484         this_ptr_conv.inner = untag_ptr(this_ptr);
45485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45487         this_ptr_conv.is_owned = false;
45488         void* val_ptr = untag_ptr(val);
45489         CHECK_ACCESS(val_ptr);
45490         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
45491         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
45492         LightningError_set_action(&this_ptr_conv, val_conv);
45493 }
45494
45495 int64_t  CS_LDK_LightningError_new(jstring err_arg, int64_t action_arg) {
45496         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
45497         void* action_arg_ptr = untag_ptr(action_arg);
45498         CHECK_ACCESS(action_arg_ptr);
45499         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
45500         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
45501         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
45502         int64_t ret_ref = 0;
45503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45505         return ret_ref;
45506 }
45507
45508 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
45509         LDKLightningError ret_var = LightningError_clone(arg);
45510         int64_t ret_ref = 0;
45511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45513         return ret_ref;
45514 }
45515 int64_t  CS_LDK_LightningError_clone_ptr(int64_t arg) {
45516         LDKLightningError arg_conv;
45517         arg_conv.inner = untag_ptr(arg);
45518         arg_conv.is_owned = ptr_is_owned(arg);
45519         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45520         arg_conv.is_owned = false;
45521         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
45522         return ret_conv;
45523 }
45524
45525 int64_t  CS_LDK_LightningError_clone(int64_t orig) {
45526         LDKLightningError orig_conv;
45527         orig_conv.inner = untag_ptr(orig);
45528         orig_conv.is_owned = ptr_is_owned(orig);
45529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45530         orig_conv.is_owned = false;
45531         LDKLightningError ret_var = LightningError_clone(&orig_conv);
45532         int64_t ret_ref = 0;
45533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45535         return ret_ref;
45536 }
45537
45538 void  CS_LDK_CommitmentUpdate_free(int64_t this_obj) {
45539         LDKCommitmentUpdate this_obj_conv;
45540         this_obj_conv.inner = untag_ptr(this_obj);
45541         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45543         CommitmentUpdate_free(this_obj_conv);
45544 }
45545
45546 int64_tArray  CS_LDK_CommitmentUpdate_get_update_add_htlcs(int64_t this_ptr) {
45547         LDKCommitmentUpdate this_ptr_conv;
45548         this_ptr_conv.inner = untag_ptr(this_ptr);
45549         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45551         this_ptr_conv.is_owned = false;
45552         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
45553         int64_tArray ret_arr = NULL;
45554         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45555         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45556         for (size_t p = 0; p < ret_var.datalen; p++) {
45557                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
45558                 int64_t ret_conv_15_ref = 0;
45559                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
45560                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
45561                 ret_arr_ptr[p] = ret_conv_15_ref;
45562         }
45563         
45564         FREE(ret_var.data);
45565         return ret_arr;
45566 }
45567
45568 void  CS_LDK_CommitmentUpdate_set_update_add_htlcs(int64_t this_ptr, int64_tArray val) {
45569         LDKCommitmentUpdate this_ptr_conv;
45570         this_ptr_conv.inner = untag_ptr(this_ptr);
45571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45573         this_ptr_conv.is_owned = false;
45574         LDKCVec_UpdateAddHTLCZ val_constr;
45575         val_constr.datalen = val->arr_len;
45576         if (val_constr.datalen > 0)
45577                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
45578         else
45579                 val_constr.data = NULL;
45580         int64_t* val_vals = val->elems;
45581         for (size_t p = 0; p < val_constr.datalen; p++) {
45582                 int64_t val_conv_15 = val_vals[p];
45583                 LDKUpdateAddHTLC val_conv_15_conv;
45584                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
45585                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
45586                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
45587                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
45588                 val_constr.data[p] = val_conv_15_conv;
45589         }
45590         FREE(val);
45591         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
45592 }
45593
45594 int64_tArray  CS_LDK_CommitmentUpdate_get_update_fulfill_htlcs(int64_t this_ptr) {
45595         LDKCommitmentUpdate this_ptr_conv;
45596         this_ptr_conv.inner = untag_ptr(this_ptr);
45597         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45599         this_ptr_conv.is_owned = false;
45600         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
45601         int64_tArray ret_arr = NULL;
45602         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45603         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45604         for (size_t t = 0; t < ret_var.datalen; t++) {
45605                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
45606                 int64_t ret_conv_19_ref = 0;
45607                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
45608                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
45609                 ret_arr_ptr[t] = ret_conv_19_ref;
45610         }
45611         
45612         FREE(ret_var.data);
45613         return ret_arr;
45614 }
45615
45616 void  CS_LDK_CommitmentUpdate_set_update_fulfill_htlcs(int64_t this_ptr, int64_tArray val) {
45617         LDKCommitmentUpdate this_ptr_conv;
45618         this_ptr_conv.inner = untag_ptr(this_ptr);
45619         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45621         this_ptr_conv.is_owned = false;
45622         LDKCVec_UpdateFulfillHTLCZ val_constr;
45623         val_constr.datalen = val->arr_len;
45624         if (val_constr.datalen > 0)
45625                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
45626         else
45627                 val_constr.data = NULL;
45628         int64_t* val_vals = val->elems;
45629         for (size_t t = 0; t < val_constr.datalen; t++) {
45630                 int64_t val_conv_19 = val_vals[t];
45631                 LDKUpdateFulfillHTLC val_conv_19_conv;
45632                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
45633                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
45634                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
45635                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
45636                 val_constr.data[t] = val_conv_19_conv;
45637         }
45638         FREE(val);
45639         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
45640 }
45641
45642 int64_tArray  CS_LDK_CommitmentUpdate_get_update_fail_htlcs(int64_t this_ptr) {
45643         LDKCommitmentUpdate this_ptr_conv;
45644         this_ptr_conv.inner = untag_ptr(this_ptr);
45645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45647         this_ptr_conv.is_owned = false;
45648         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
45649         int64_tArray ret_arr = NULL;
45650         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45651         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45652         for (size_t q = 0; q < ret_var.datalen; q++) {
45653                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
45654                 int64_t ret_conv_16_ref = 0;
45655                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
45656                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
45657                 ret_arr_ptr[q] = ret_conv_16_ref;
45658         }
45659         
45660         FREE(ret_var.data);
45661         return ret_arr;
45662 }
45663
45664 void  CS_LDK_CommitmentUpdate_set_update_fail_htlcs(int64_t this_ptr, int64_tArray val) {
45665         LDKCommitmentUpdate this_ptr_conv;
45666         this_ptr_conv.inner = untag_ptr(this_ptr);
45667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45669         this_ptr_conv.is_owned = false;
45670         LDKCVec_UpdateFailHTLCZ val_constr;
45671         val_constr.datalen = val->arr_len;
45672         if (val_constr.datalen > 0)
45673                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
45674         else
45675                 val_constr.data = NULL;
45676         int64_t* val_vals = val->elems;
45677         for (size_t q = 0; q < val_constr.datalen; q++) {
45678                 int64_t val_conv_16 = val_vals[q];
45679                 LDKUpdateFailHTLC val_conv_16_conv;
45680                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
45681                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
45682                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
45683                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
45684                 val_constr.data[q] = val_conv_16_conv;
45685         }
45686         FREE(val);
45687         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
45688 }
45689
45690 int64_tArray  CS_LDK_CommitmentUpdate_get_update_fail_malformed_htlcs(int64_t this_ptr) {
45691         LDKCommitmentUpdate this_ptr_conv;
45692         this_ptr_conv.inner = untag_ptr(this_ptr);
45693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45695         this_ptr_conv.is_owned = false;
45696         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
45697         int64_tArray ret_arr = NULL;
45698         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
45699         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
45700         for (size_t z = 0; z < ret_var.datalen; z++) {
45701                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
45702                 int64_t ret_conv_25_ref = 0;
45703                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
45704                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
45705                 ret_arr_ptr[z] = ret_conv_25_ref;
45706         }
45707         
45708         FREE(ret_var.data);
45709         return ret_arr;
45710 }
45711
45712 void  CS_LDK_CommitmentUpdate_set_update_fail_malformed_htlcs(int64_t this_ptr, int64_tArray val) {
45713         LDKCommitmentUpdate this_ptr_conv;
45714         this_ptr_conv.inner = untag_ptr(this_ptr);
45715         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45717         this_ptr_conv.is_owned = false;
45718         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
45719         val_constr.datalen = val->arr_len;
45720         if (val_constr.datalen > 0)
45721                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
45722         else
45723                 val_constr.data = NULL;
45724         int64_t* val_vals = val->elems;
45725         for (size_t z = 0; z < val_constr.datalen; z++) {
45726                 int64_t val_conv_25 = val_vals[z];
45727                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
45728                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
45729                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
45730                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
45731                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
45732                 val_constr.data[z] = val_conv_25_conv;
45733         }
45734         FREE(val);
45735         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
45736 }
45737
45738 int64_t  CS_LDK_CommitmentUpdate_get_update_fee(int64_t this_ptr) {
45739         LDKCommitmentUpdate this_ptr_conv;
45740         this_ptr_conv.inner = untag_ptr(this_ptr);
45741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45743         this_ptr_conv.is_owned = false;
45744         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
45745         int64_t ret_ref = 0;
45746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45748         return ret_ref;
45749 }
45750
45751 void  CS_LDK_CommitmentUpdate_set_update_fee(int64_t this_ptr, int64_t val) {
45752         LDKCommitmentUpdate this_ptr_conv;
45753         this_ptr_conv.inner = untag_ptr(this_ptr);
45754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45756         this_ptr_conv.is_owned = false;
45757         LDKUpdateFee val_conv;
45758         val_conv.inner = untag_ptr(val);
45759         val_conv.is_owned = ptr_is_owned(val);
45760         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45761         val_conv = UpdateFee_clone(&val_conv);
45762         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
45763 }
45764
45765 int64_t  CS_LDK_CommitmentUpdate_get_commitment_signed(int64_t this_ptr) {
45766         LDKCommitmentUpdate this_ptr_conv;
45767         this_ptr_conv.inner = untag_ptr(this_ptr);
45768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45770         this_ptr_conv.is_owned = false;
45771         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
45772         int64_t ret_ref = 0;
45773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45775         return ret_ref;
45776 }
45777
45778 void  CS_LDK_CommitmentUpdate_set_commitment_signed(int64_t this_ptr, int64_t val) {
45779         LDKCommitmentUpdate this_ptr_conv;
45780         this_ptr_conv.inner = untag_ptr(this_ptr);
45781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45783         this_ptr_conv.is_owned = false;
45784         LDKCommitmentSigned val_conv;
45785         val_conv.inner = untag_ptr(val);
45786         val_conv.is_owned = ptr_is_owned(val);
45787         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45788         val_conv = CommitmentSigned_clone(&val_conv);
45789         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
45790 }
45791
45792 int64_t  CS_LDK_CommitmentUpdate_new(int64_tArray update_add_htlcs_arg, int64_tArray update_fulfill_htlcs_arg, int64_tArray update_fail_htlcs_arg, int64_tArray update_fail_malformed_htlcs_arg, int64_t update_fee_arg, int64_t commitment_signed_arg) {
45793         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
45794         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
45795         if (update_add_htlcs_arg_constr.datalen > 0)
45796                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
45797         else
45798                 update_add_htlcs_arg_constr.data = NULL;
45799         int64_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems;
45800         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
45801                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
45802                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
45803                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
45804                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
45805                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
45806                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
45807                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
45808         }
45809         FREE(update_add_htlcs_arg);
45810         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
45811         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
45812         if (update_fulfill_htlcs_arg_constr.datalen > 0)
45813                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
45814         else
45815                 update_fulfill_htlcs_arg_constr.data = NULL;
45816         int64_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems;
45817         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
45818                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
45819                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
45820                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
45821                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
45822                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
45823                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
45824                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
45825         }
45826         FREE(update_fulfill_htlcs_arg);
45827         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
45828         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
45829         if (update_fail_htlcs_arg_constr.datalen > 0)
45830                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
45831         else
45832                 update_fail_htlcs_arg_constr.data = NULL;
45833         int64_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems;
45834         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
45835                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
45836                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
45837                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
45838                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
45839                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
45840                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
45841                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
45842         }
45843         FREE(update_fail_htlcs_arg);
45844         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
45845         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
45846         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
45847                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
45848         else
45849                 update_fail_malformed_htlcs_arg_constr.data = NULL;
45850         int64_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems;
45851         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
45852                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
45853                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
45854                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
45855                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
45856                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
45857                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
45858                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
45859         }
45860         FREE(update_fail_malformed_htlcs_arg);
45861         LDKUpdateFee update_fee_arg_conv;
45862         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
45863         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
45864         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
45865         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
45866         LDKCommitmentSigned commitment_signed_arg_conv;
45867         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
45868         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
45869         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
45870         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
45871         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);
45872         int64_t ret_ref = 0;
45873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45874         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45875         return ret_ref;
45876 }
45877
45878 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
45879         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
45880         int64_t ret_ref = 0;
45881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45883         return ret_ref;
45884 }
45885 int64_t  CS_LDK_CommitmentUpdate_clone_ptr(int64_t arg) {
45886         LDKCommitmentUpdate arg_conv;
45887         arg_conv.inner = untag_ptr(arg);
45888         arg_conv.is_owned = ptr_is_owned(arg);
45889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45890         arg_conv.is_owned = false;
45891         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
45892         return ret_conv;
45893 }
45894
45895 int64_t  CS_LDK_CommitmentUpdate_clone(int64_t orig) {
45896         LDKCommitmentUpdate orig_conv;
45897         orig_conv.inner = untag_ptr(orig);
45898         orig_conv.is_owned = ptr_is_owned(orig);
45899         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45900         orig_conv.is_owned = false;
45901         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
45902         int64_t ret_ref = 0;
45903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45905         return ret_ref;
45906 }
45907
45908 jboolean  CS_LDK_CommitmentUpdate_eq(int64_t a, int64_t b) {
45909         LDKCommitmentUpdate a_conv;
45910         a_conv.inner = untag_ptr(a);
45911         a_conv.is_owned = ptr_is_owned(a);
45912         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45913         a_conv.is_owned = false;
45914         LDKCommitmentUpdate b_conv;
45915         b_conv.inner = untag_ptr(b);
45916         b_conv.is_owned = ptr_is_owned(b);
45917         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45918         b_conv.is_owned = false;
45919         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
45920         return ret_conv;
45921 }
45922
45923 void  CS_LDK_ChannelMessageHandler_free(int64_t this_ptr) {
45924         if (!ptr_is_owned(this_ptr)) return;
45925         void* this_ptr_ptr = untag_ptr(this_ptr);
45926         CHECK_ACCESS(this_ptr_ptr);
45927         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
45928         FREE(untag_ptr(this_ptr));
45929         ChannelMessageHandler_free(this_ptr_conv);
45930 }
45931
45932 void  CS_LDK_RoutingMessageHandler_free(int64_t this_ptr) {
45933         if (!ptr_is_owned(this_ptr)) return;
45934         void* this_ptr_ptr = untag_ptr(this_ptr);
45935         CHECK_ACCESS(this_ptr_ptr);
45936         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
45937         FREE(untag_ptr(this_ptr));
45938         RoutingMessageHandler_free(this_ptr_conv);
45939 }
45940
45941 void  CS_LDK_OnionMessageHandler_free(int64_t this_ptr) {
45942         if (!ptr_is_owned(this_ptr)) return;
45943         void* this_ptr_ptr = untag_ptr(this_ptr);
45944         CHECK_ACCESS(this_ptr_ptr);
45945         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
45946         FREE(untag_ptr(this_ptr));
45947         OnionMessageHandler_free(this_ptr_conv);
45948 }
45949
45950 int8_tArray  CS_LDK_AcceptChannel_write(int64_t obj) {
45951         LDKAcceptChannel obj_conv;
45952         obj_conv.inner = untag_ptr(obj);
45953         obj_conv.is_owned = ptr_is_owned(obj);
45954         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45955         obj_conv.is_owned = false;
45956         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
45957         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
45958         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
45959         CVec_u8Z_free(ret_var);
45960         return ret_arr;
45961 }
45962
45963 int64_t  CS_LDK_AcceptChannel_read(int8_tArray ser) {
45964         LDKu8slice ser_ref;
45965         ser_ref.datalen = ser->arr_len;
45966         ser_ref.data = ser->elems;
45967         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
45968         *ret_conv = AcceptChannel_read(ser_ref);
45969         FREE(ser);
45970         return tag_ptr(ret_conv, true);
45971 }
45972
45973 int8_tArray  CS_LDK_AcceptChannelV2_write(int64_t obj) {
45974         LDKAcceptChannelV2 obj_conv;
45975         obj_conv.inner = untag_ptr(obj);
45976         obj_conv.is_owned = ptr_is_owned(obj);
45977         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45978         obj_conv.is_owned = false;
45979         LDKCVec_u8Z ret_var = AcceptChannelV2_write(&obj_conv);
45980         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
45981         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
45982         CVec_u8Z_free(ret_var);
45983         return ret_arr;
45984 }
45985
45986 int64_t  CS_LDK_AcceptChannelV2_read(int8_tArray ser) {
45987         LDKu8slice ser_ref;
45988         ser_ref.datalen = ser->arr_len;
45989         ser_ref.data = ser->elems;
45990         LDKCResult_AcceptChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelV2DecodeErrorZ), "LDKCResult_AcceptChannelV2DecodeErrorZ");
45991         *ret_conv = AcceptChannelV2_read(ser_ref);
45992         FREE(ser);
45993         return tag_ptr(ret_conv, true);
45994 }
45995
45996 int8_tArray  CS_LDK_TxAddInput_write(int64_t obj) {
45997         LDKTxAddInput obj_conv;
45998         obj_conv.inner = untag_ptr(obj);
45999         obj_conv.is_owned = ptr_is_owned(obj);
46000         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46001         obj_conv.is_owned = false;
46002         LDKCVec_u8Z ret_var = TxAddInput_write(&obj_conv);
46003         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46004         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46005         CVec_u8Z_free(ret_var);
46006         return ret_arr;
46007 }
46008
46009 int64_t  CS_LDK_TxAddInput_read(int8_tArray ser) {
46010         LDKu8slice ser_ref;
46011         ser_ref.datalen = ser->arr_len;
46012         ser_ref.data = ser->elems;
46013         LDKCResult_TxAddInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddInputDecodeErrorZ), "LDKCResult_TxAddInputDecodeErrorZ");
46014         *ret_conv = TxAddInput_read(ser_ref);
46015         FREE(ser);
46016         return tag_ptr(ret_conv, true);
46017 }
46018
46019 int8_tArray  CS_LDK_TxAddOutput_write(int64_t obj) {
46020         LDKTxAddOutput obj_conv;
46021         obj_conv.inner = untag_ptr(obj);
46022         obj_conv.is_owned = ptr_is_owned(obj);
46023         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46024         obj_conv.is_owned = false;
46025         LDKCVec_u8Z ret_var = TxAddOutput_write(&obj_conv);
46026         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46027         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46028         CVec_u8Z_free(ret_var);
46029         return ret_arr;
46030 }
46031
46032 int64_t  CS_LDK_TxAddOutput_read(int8_tArray ser) {
46033         LDKu8slice ser_ref;
46034         ser_ref.datalen = ser->arr_len;
46035         ser_ref.data = ser->elems;
46036         LDKCResult_TxAddOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAddOutputDecodeErrorZ), "LDKCResult_TxAddOutputDecodeErrorZ");
46037         *ret_conv = TxAddOutput_read(ser_ref);
46038         FREE(ser);
46039         return tag_ptr(ret_conv, true);
46040 }
46041
46042 int8_tArray  CS_LDK_TxRemoveInput_write(int64_t obj) {
46043         LDKTxRemoveInput obj_conv;
46044         obj_conv.inner = untag_ptr(obj);
46045         obj_conv.is_owned = ptr_is_owned(obj);
46046         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46047         obj_conv.is_owned = false;
46048         LDKCVec_u8Z ret_var = TxRemoveInput_write(&obj_conv);
46049         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46050         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46051         CVec_u8Z_free(ret_var);
46052         return ret_arr;
46053 }
46054
46055 int64_t  CS_LDK_TxRemoveInput_read(int8_tArray ser) {
46056         LDKu8slice ser_ref;
46057         ser_ref.datalen = ser->arr_len;
46058         ser_ref.data = ser->elems;
46059         LDKCResult_TxRemoveInputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveInputDecodeErrorZ), "LDKCResult_TxRemoveInputDecodeErrorZ");
46060         *ret_conv = TxRemoveInput_read(ser_ref);
46061         FREE(ser);
46062         return tag_ptr(ret_conv, true);
46063 }
46064
46065 int8_tArray  CS_LDK_TxRemoveOutput_write(int64_t obj) {
46066         LDKTxRemoveOutput obj_conv;
46067         obj_conv.inner = untag_ptr(obj);
46068         obj_conv.is_owned = ptr_is_owned(obj);
46069         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46070         obj_conv.is_owned = false;
46071         LDKCVec_u8Z ret_var = TxRemoveOutput_write(&obj_conv);
46072         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46073         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46074         CVec_u8Z_free(ret_var);
46075         return ret_arr;
46076 }
46077
46078 int64_t  CS_LDK_TxRemoveOutput_read(int8_tArray ser) {
46079         LDKu8slice ser_ref;
46080         ser_ref.datalen = ser->arr_len;
46081         ser_ref.data = ser->elems;
46082         LDKCResult_TxRemoveOutputDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxRemoveOutputDecodeErrorZ), "LDKCResult_TxRemoveOutputDecodeErrorZ");
46083         *ret_conv = TxRemoveOutput_read(ser_ref);
46084         FREE(ser);
46085         return tag_ptr(ret_conv, true);
46086 }
46087
46088 int8_tArray  CS_LDK_TxComplete_write(int64_t obj) {
46089         LDKTxComplete obj_conv;
46090         obj_conv.inner = untag_ptr(obj);
46091         obj_conv.is_owned = ptr_is_owned(obj);
46092         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46093         obj_conv.is_owned = false;
46094         LDKCVec_u8Z ret_var = TxComplete_write(&obj_conv);
46095         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46096         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46097         CVec_u8Z_free(ret_var);
46098         return ret_arr;
46099 }
46100
46101 int64_t  CS_LDK_TxComplete_read(int8_tArray ser) {
46102         LDKu8slice ser_ref;
46103         ser_ref.datalen = ser->arr_len;
46104         ser_ref.data = ser->elems;
46105         LDKCResult_TxCompleteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCompleteDecodeErrorZ), "LDKCResult_TxCompleteDecodeErrorZ");
46106         *ret_conv = TxComplete_read(ser_ref);
46107         FREE(ser);
46108         return tag_ptr(ret_conv, true);
46109 }
46110
46111 int8_tArray  CS_LDK_TxSignatures_write(int64_t obj) {
46112         LDKTxSignatures obj_conv;
46113         obj_conv.inner = untag_ptr(obj);
46114         obj_conv.is_owned = ptr_is_owned(obj);
46115         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46116         obj_conv.is_owned = false;
46117         LDKCVec_u8Z ret_var = TxSignatures_write(&obj_conv);
46118         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46119         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46120         CVec_u8Z_free(ret_var);
46121         return ret_arr;
46122 }
46123
46124 int64_t  CS_LDK_TxSignatures_read(int8_tArray ser) {
46125         LDKu8slice ser_ref;
46126         ser_ref.datalen = ser->arr_len;
46127         ser_ref.data = ser->elems;
46128         LDKCResult_TxSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxSignaturesDecodeErrorZ), "LDKCResult_TxSignaturesDecodeErrorZ");
46129         *ret_conv = TxSignatures_read(ser_ref);
46130         FREE(ser);
46131         return tag_ptr(ret_conv, true);
46132 }
46133
46134 int8_tArray  CS_LDK_TxInitRbf_write(int64_t obj) {
46135         LDKTxInitRbf obj_conv;
46136         obj_conv.inner = untag_ptr(obj);
46137         obj_conv.is_owned = ptr_is_owned(obj);
46138         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46139         obj_conv.is_owned = false;
46140         LDKCVec_u8Z ret_var = TxInitRbf_write(&obj_conv);
46141         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46142         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46143         CVec_u8Z_free(ret_var);
46144         return ret_arr;
46145 }
46146
46147 int64_t  CS_LDK_TxInitRbf_read(int8_tArray ser) {
46148         LDKu8slice ser_ref;
46149         ser_ref.datalen = ser->arr_len;
46150         ser_ref.data = ser->elems;
46151         LDKCResult_TxInitRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxInitRbfDecodeErrorZ), "LDKCResult_TxInitRbfDecodeErrorZ");
46152         *ret_conv = TxInitRbf_read(ser_ref);
46153         FREE(ser);
46154         return tag_ptr(ret_conv, true);
46155 }
46156
46157 int8_tArray  CS_LDK_TxAckRbf_write(int64_t obj) {
46158         LDKTxAckRbf obj_conv;
46159         obj_conv.inner = untag_ptr(obj);
46160         obj_conv.is_owned = ptr_is_owned(obj);
46161         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46162         obj_conv.is_owned = false;
46163         LDKCVec_u8Z ret_var = TxAckRbf_write(&obj_conv);
46164         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46165         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46166         CVec_u8Z_free(ret_var);
46167         return ret_arr;
46168 }
46169
46170 int64_t  CS_LDK_TxAckRbf_read(int8_tArray ser) {
46171         LDKu8slice ser_ref;
46172         ser_ref.datalen = ser->arr_len;
46173         ser_ref.data = ser->elems;
46174         LDKCResult_TxAckRbfDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAckRbfDecodeErrorZ), "LDKCResult_TxAckRbfDecodeErrorZ");
46175         *ret_conv = TxAckRbf_read(ser_ref);
46176         FREE(ser);
46177         return tag_ptr(ret_conv, true);
46178 }
46179
46180 int8_tArray  CS_LDK_TxAbort_write(int64_t obj) {
46181         LDKTxAbort obj_conv;
46182         obj_conv.inner = untag_ptr(obj);
46183         obj_conv.is_owned = ptr_is_owned(obj);
46184         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46185         obj_conv.is_owned = false;
46186         LDKCVec_u8Z ret_var = TxAbort_write(&obj_conv);
46187         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46188         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46189         CVec_u8Z_free(ret_var);
46190         return ret_arr;
46191 }
46192
46193 int64_t  CS_LDK_TxAbort_read(int8_tArray ser) {
46194         LDKu8slice ser_ref;
46195         ser_ref.datalen = ser->arr_len;
46196         ser_ref.data = ser->elems;
46197         LDKCResult_TxAbortDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxAbortDecodeErrorZ), "LDKCResult_TxAbortDecodeErrorZ");
46198         *ret_conv = TxAbort_read(ser_ref);
46199         FREE(ser);
46200         return tag_ptr(ret_conv, true);
46201 }
46202
46203 int8_tArray  CS_LDK_AnnouncementSignatures_write(int64_t obj) {
46204         LDKAnnouncementSignatures obj_conv;
46205         obj_conv.inner = untag_ptr(obj);
46206         obj_conv.is_owned = ptr_is_owned(obj);
46207         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46208         obj_conv.is_owned = false;
46209         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
46210         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46211         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46212         CVec_u8Z_free(ret_var);
46213         return ret_arr;
46214 }
46215
46216 int64_t  CS_LDK_AnnouncementSignatures_read(int8_tArray ser) {
46217         LDKu8slice ser_ref;
46218         ser_ref.datalen = ser->arr_len;
46219         ser_ref.data = ser->elems;
46220         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
46221         *ret_conv = AnnouncementSignatures_read(ser_ref);
46222         FREE(ser);
46223         return tag_ptr(ret_conv, true);
46224 }
46225
46226 int8_tArray  CS_LDK_ChannelReestablish_write(int64_t obj) {
46227         LDKChannelReestablish obj_conv;
46228         obj_conv.inner = untag_ptr(obj);
46229         obj_conv.is_owned = ptr_is_owned(obj);
46230         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46231         obj_conv.is_owned = false;
46232         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
46233         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46234         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46235         CVec_u8Z_free(ret_var);
46236         return ret_arr;
46237 }
46238
46239 int64_t  CS_LDK_ChannelReestablish_read(int8_tArray ser) {
46240         LDKu8slice ser_ref;
46241         ser_ref.datalen = ser->arr_len;
46242         ser_ref.data = ser->elems;
46243         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
46244         *ret_conv = ChannelReestablish_read(ser_ref);
46245         FREE(ser);
46246         return tag_ptr(ret_conv, true);
46247 }
46248
46249 int8_tArray  CS_LDK_ClosingSigned_write(int64_t obj) {
46250         LDKClosingSigned obj_conv;
46251         obj_conv.inner = untag_ptr(obj);
46252         obj_conv.is_owned = ptr_is_owned(obj);
46253         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46254         obj_conv.is_owned = false;
46255         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
46256         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46257         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46258         CVec_u8Z_free(ret_var);
46259         return ret_arr;
46260 }
46261
46262 int64_t  CS_LDK_ClosingSigned_read(int8_tArray ser) {
46263         LDKu8slice ser_ref;
46264         ser_ref.datalen = ser->arr_len;
46265         ser_ref.data = ser->elems;
46266         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
46267         *ret_conv = ClosingSigned_read(ser_ref);
46268         FREE(ser);
46269         return tag_ptr(ret_conv, true);
46270 }
46271
46272 int8_tArray  CS_LDK_ClosingSignedFeeRange_write(int64_t obj) {
46273         LDKClosingSignedFeeRange obj_conv;
46274         obj_conv.inner = untag_ptr(obj);
46275         obj_conv.is_owned = ptr_is_owned(obj);
46276         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46277         obj_conv.is_owned = false;
46278         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
46279         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46280         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46281         CVec_u8Z_free(ret_var);
46282         return ret_arr;
46283 }
46284
46285 int64_t  CS_LDK_ClosingSignedFeeRange_read(int8_tArray ser) {
46286         LDKu8slice ser_ref;
46287         ser_ref.datalen = ser->arr_len;
46288         ser_ref.data = ser->elems;
46289         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
46290         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
46291         FREE(ser);
46292         return tag_ptr(ret_conv, true);
46293 }
46294
46295 int8_tArray  CS_LDK_CommitmentSigned_write(int64_t obj) {
46296         LDKCommitmentSigned obj_conv;
46297         obj_conv.inner = untag_ptr(obj);
46298         obj_conv.is_owned = ptr_is_owned(obj);
46299         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46300         obj_conv.is_owned = false;
46301         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
46302         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46303         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46304         CVec_u8Z_free(ret_var);
46305         return ret_arr;
46306 }
46307
46308 int64_t  CS_LDK_CommitmentSigned_read(int8_tArray ser) {
46309         LDKu8slice ser_ref;
46310         ser_ref.datalen = ser->arr_len;
46311         ser_ref.data = ser->elems;
46312         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
46313         *ret_conv = CommitmentSigned_read(ser_ref);
46314         FREE(ser);
46315         return tag_ptr(ret_conv, true);
46316 }
46317
46318 int8_tArray  CS_LDK_FundingCreated_write(int64_t obj) {
46319         LDKFundingCreated obj_conv;
46320         obj_conv.inner = untag_ptr(obj);
46321         obj_conv.is_owned = ptr_is_owned(obj);
46322         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46323         obj_conv.is_owned = false;
46324         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
46325         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46326         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46327         CVec_u8Z_free(ret_var);
46328         return ret_arr;
46329 }
46330
46331 int64_t  CS_LDK_FundingCreated_read(int8_tArray ser) {
46332         LDKu8slice ser_ref;
46333         ser_ref.datalen = ser->arr_len;
46334         ser_ref.data = ser->elems;
46335         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
46336         *ret_conv = FundingCreated_read(ser_ref);
46337         FREE(ser);
46338         return tag_ptr(ret_conv, true);
46339 }
46340
46341 int8_tArray  CS_LDK_FundingSigned_write(int64_t obj) {
46342         LDKFundingSigned obj_conv;
46343         obj_conv.inner = untag_ptr(obj);
46344         obj_conv.is_owned = ptr_is_owned(obj);
46345         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46346         obj_conv.is_owned = false;
46347         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
46348         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46349         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46350         CVec_u8Z_free(ret_var);
46351         return ret_arr;
46352 }
46353
46354 int64_t  CS_LDK_FundingSigned_read(int8_tArray ser) {
46355         LDKu8slice ser_ref;
46356         ser_ref.datalen = ser->arr_len;
46357         ser_ref.data = ser->elems;
46358         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
46359         *ret_conv = FundingSigned_read(ser_ref);
46360         FREE(ser);
46361         return tag_ptr(ret_conv, true);
46362 }
46363
46364 int8_tArray  CS_LDK_ChannelReady_write(int64_t obj) {
46365         LDKChannelReady obj_conv;
46366         obj_conv.inner = untag_ptr(obj);
46367         obj_conv.is_owned = ptr_is_owned(obj);
46368         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46369         obj_conv.is_owned = false;
46370         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
46371         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46372         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46373         CVec_u8Z_free(ret_var);
46374         return ret_arr;
46375 }
46376
46377 int64_t  CS_LDK_ChannelReady_read(int8_tArray ser) {
46378         LDKu8slice ser_ref;
46379         ser_ref.datalen = ser->arr_len;
46380         ser_ref.data = ser->elems;
46381         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
46382         *ret_conv = ChannelReady_read(ser_ref);
46383         FREE(ser);
46384         return tag_ptr(ret_conv, true);
46385 }
46386
46387 int8_tArray  CS_LDK_Init_write(int64_t obj) {
46388         LDKInit obj_conv;
46389         obj_conv.inner = untag_ptr(obj);
46390         obj_conv.is_owned = ptr_is_owned(obj);
46391         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46392         obj_conv.is_owned = false;
46393         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
46394         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46395         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46396         CVec_u8Z_free(ret_var);
46397         return ret_arr;
46398 }
46399
46400 int64_t  CS_LDK_Init_read(int8_tArray ser) {
46401         LDKu8slice ser_ref;
46402         ser_ref.datalen = ser->arr_len;
46403         ser_ref.data = ser->elems;
46404         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
46405         *ret_conv = Init_read(ser_ref);
46406         FREE(ser);
46407         return tag_ptr(ret_conv, true);
46408 }
46409
46410 int8_tArray  CS_LDK_OpenChannel_write(int64_t obj) {
46411         LDKOpenChannel obj_conv;
46412         obj_conv.inner = untag_ptr(obj);
46413         obj_conv.is_owned = ptr_is_owned(obj);
46414         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46415         obj_conv.is_owned = false;
46416         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
46417         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46418         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46419         CVec_u8Z_free(ret_var);
46420         return ret_arr;
46421 }
46422
46423 int64_t  CS_LDK_OpenChannel_read(int8_tArray ser) {
46424         LDKu8slice ser_ref;
46425         ser_ref.datalen = ser->arr_len;
46426         ser_ref.data = ser->elems;
46427         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
46428         *ret_conv = OpenChannel_read(ser_ref);
46429         FREE(ser);
46430         return tag_ptr(ret_conv, true);
46431 }
46432
46433 int8_tArray  CS_LDK_OpenChannelV2_write(int64_t obj) {
46434         LDKOpenChannelV2 obj_conv;
46435         obj_conv.inner = untag_ptr(obj);
46436         obj_conv.is_owned = ptr_is_owned(obj);
46437         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46438         obj_conv.is_owned = false;
46439         LDKCVec_u8Z ret_var = OpenChannelV2_write(&obj_conv);
46440         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46441         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46442         CVec_u8Z_free(ret_var);
46443         return ret_arr;
46444 }
46445
46446 int64_t  CS_LDK_OpenChannelV2_read(int8_tArray ser) {
46447         LDKu8slice ser_ref;
46448         ser_ref.datalen = ser->arr_len;
46449         ser_ref.data = ser->elems;
46450         LDKCResult_OpenChannelV2DecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelV2DecodeErrorZ), "LDKCResult_OpenChannelV2DecodeErrorZ");
46451         *ret_conv = OpenChannelV2_read(ser_ref);
46452         FREE(ser);
46453         return tag_ptr(ret_conv, true);
46454 }
46455
46456 int8_tArray  CS_LDK_RevokeAndACK_write(int64_t obj) {
46457         LDKRevokeAndACK obj_conv;
46458         obj_conv.inner = untag_ptr(obj);
46459         obj_conv.is_owned = ptr_is_owned(obj);
46460         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46461         obj_conv.is_owned = false;
46462         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
46463         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46464         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46465         CVec_u8Z_free(ret_var);
46466         return ret_arr;
46467 }
46468
46469 int64_t  CS_LDK_RevokeAndACK_read(int8_tArray ser) {
46470         LDKu8slice ser_ref;
46471         ser_ref.datalen = ser->arr_len;
46472         ser_ref.data = ser->elems;
46473         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
46474         *ret_conv = RevokeAndACK_read(ser_ref);
46475         FREE(ser);
46476         return tag_ptr(ret_conv, true);
46477 }
46478
46479 int8_tArray  CS_LDK_Shutdown_write(int64_t obj) {
46480         LDKShutdown obj_conv;
46481         obj_conv.inner = untag_ptr(obj);
46482         obj_conv.is_owned = ptr_is_owned(obj);
46483         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46484         obj_conv.is_owned = false;
46485         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
46486         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46487         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46488         CVec_u8Z_free(ret_var);
46489         return ret_arr;
46490 }
46491
46492 int64_t  CS_LDK_Shutdown_read(int8_tArray ser) {
46493         LDKu8slice ser_ref;
46494         ser_ref.datalen = ser->arr_len;
46495         ser_ref.data = ser->elems;
46496         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
46497         *ret_conv = Shutdown_read(ser_ref);
46498         FREE(ser);
46499         return tag_ptr(ret_conv, true);
46500 }
46501
46502 int8_tArray  CS_LDK_UpdateFailHTLC_write(int64_t obj) {
46503         LDKUpdateFailHTLC obj_conv;
46504         obj_conv.inner = untag_ptr(obj);
46505         obj_conv.is_owned = ptr_is_owned(obj);
46506         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46507         obj_conv.is_owned = false;
46508         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
46509         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46510         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46511         CVec_u8Z_free(ret_var);
46512         return ret_arr;
46513 }
46514
46515 int64_t  CS_LDK_UpdateFailHTLC_read(int8_tArray ser) {
46516         LDKu8slice ser_ref;
46517         ser_ref.datalen = ser->arr_len;
46518         ser_ref.data = ser->elems;
46519         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
46520         *ret_conv = UpdateFailHTLC_read(ser_ref);
46521         FREE(ser);
46522         return tag_ptr(ret_conv, true);
46523 }
46524
46525 int8_tArray  CS_LDK_UpdateFailMalformedHTLC_write(int64_t obj) {
46526         LDKUpdateFailMalformedHTLC obj_conv;
46527         obj_conv.inner = untag_ptr(obj);
46528         obj_conv.is_owned = ptr_is_owned(obj);
46529         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46530         obj_conv.is_owned = false;
46531         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
46532         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46533         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46534         CVec_u8Z_free(ret_var);
46535         return ret_arr;
46536 }
46537
46538 int64_t  CS_LDK_UpdateFailMalformedHTLC_read(int8_tArray ser) {
46539         LDKu8slice ser_ref;
46540         ser_ref.datalen = ser->arr_len;
46541         ser_ref.data = ser->elems;
46542         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
46543         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
46544         FREE(ser);
46545         return tag_ptr(ret_conv, true);
46546 }
46547
46548 int8_tArray  CS_LDK_UpdateFee_write(int64_t obj) {
46549         LDKUpdateFee obj_conv;
46550         obj_conv.inner = untag_ptr(obj);
46551         obj_conv.is_owned = ptr_is_owned(obj);
46552         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46553         obj_conv.is_owned = false;
46554         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
46555         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46556         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46557         CVec_u8Z_free(ret_var);
46558         return ret_arr;
46559 }
46560
46561 int64_t  CS_LDK_UpdateFee_read(int8_tArray ser) {
46562         LDKu8slice ser_ref;
46563         ser_ref.datalen = ser->arr_len;
46564         ser_ref.data = ser->elems;
46565         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
46566         *ret_conv = UpdateFee_read(ser_ref);
46567         FREE(ser);
46568         return tag_ptr(ret_conv, true);
46569 }
46570
46571 int8_tArray  CS_LDK_UpdateFulfillHTLC_write(int64_t obj) {
46572         LDKUpdateFulfillHTLC obj_conv;
46573         obj_conv.inner = untag_ptr(obj);
46574         obj_conv.is_owned = ptr_is_owned(obj);
46575         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46576         obj_conv.is_owned = false;
46577         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
46578         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46579         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46580         CVec_u8Z_free(ret_var);
46581         return ret_arr;
46582 }
46583
46584 int64_t  CS_LDK_UpdateFulfillHTLC_read(int8_tArray ser) {
46585         LDKu8slice ser_ref;
46586         ser_ref.datalen = ser->arr_len;
46587         ser_ref.data = ser->elems;
46588         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
46589         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
46590         FREE(ser);
46591         return tag_ptr(ret_conv, true);
46592 }
46593
46594 int8_tArray  CS_LDK_UpdateAddHTLC_write(int64_t obj) {
46595         LDKUpdateAddHTLC obj_conv;
46596         obj_conv.inner = untag_ptr(obj);
46597         obj_conv.is_owned = ptr_is_owned(obj);
46598         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46599         obj_conv.is_owned = false;
46600         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
46601         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46602         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46603         CVec_u8Z_free(ret_var);
46604         return ret_arr;
46605 }
46606
46607 int64_t  CS_LDK_UpdateAddHTLC_read(int8_tArray ser) {
46608         LDKu8slice ser_ref;
46609         ser_ref.datalen = ser->arr_len;
46610         ser_ref.data = ser->elems;
46611         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
46612         *ret_conv = UpdateAddHTLC_read(ser_ref);
46613         FREE(ser);
46614         return tag_ptr(ret_conv, true);
46615 }
46616
46617 int64_t  CS_LDK_OnionMessage_read(int8_tArray ser) {
46618         LDKu8slice ser_ref;
46619         ser_ref.datalen = ser->arr_len;
46620         ser_ref.data = ser->elems;
46621         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
46622         *ret_conv = OnionMessage_read(ser_ref);
46623         FREE(ser);
46624         return tag_ptr(ret_conv, true);
46625 }
46626
46627 int8_tArray  CS_LDK_OnionMessage_write(int64_t obj) {
46628         LDKOnionMessage obj_conv;
46629         obj_conv.inner = untag_ptr(obj);
46630         obj_conv.is_owned = ptr_is_owned(obj);
46631         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46632         obj_conv.is_owned = false;
46633         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
46634         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46635         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46636         CVec_u8Z_free(ret_var);
46637         return ret_arr;
46638 }
46639
46640 int8_tArray  CS_LDK_Ping_write(int64_t obj) {
46641         LDKPing obj_conv;
46642         obj_conv.inner = untag_ptr(obj);
46643         obj_conv.is_owned = ptr_is_owned(obj);
46644         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46645         obj_conv.is_owned = false;
46646         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
46647         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46648         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46649         CVec_u8Z_free(ret_var);
46650         return ret_arr;
46651 }
46652
46653 int64_t  CS_LDK_Ping_read(int8_tArray ser) {
46654         LDKu8slice ser_ref;
46655         ser_ref.datalen = ser->arr_len;
46656         ser_ref.data = ser->elems;
46657         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
46658         *ret_conv = Ping_read(ser_ref);
46659         FREE(ser);
46660         return tag_ptr(ret_conv, true);
46661 }
46662
46663 int8_tArray  CS_LDK_Pong_write(int64_t obj) {
46664         LDKPong obj_conv;
46665         obj_conv.inner = untag_ptr(obj);
46666         obj_conv.is_owned = ptr_is_owned(obj);
46667         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46668         obj_conv.is_owned = false;
46669         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
46670         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46671         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46672         CVec_u8Z_free(ret_var);
46673         return ret_arr;
46674 }
46675
46676 int64_t  CS_LDK_Pong_read(int8_tArray ser) {
46677         LDKu8slice ser_ref;
46678         ser_ref.datalen = ser->arr_len;
46679         ser_ref.data = ser->elems;
46680         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
46681         *ret_conv = Pong_read(ser_ref);
46682         FREE(ser);
46683         return tag_ptr(ret_conv, true);
46684 }
46685
46686 int8_tArray  CS_LDK_UnsignedChannelAnnouncement_write(int64_t obj) {
46687         LDKUnsignedChannelAnnouncement obj_conv;
46688         obj_conv.inner = untag_ptr(obj);
46689         obj_conv.is_owned = ptr_is_owned(obj);
46690         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46691         obj_conv.is_owned = false;
46692         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
46693         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46694         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46695         CVec_u8Z_free(ret_var);
46696         return ret_arr;
46697 }
46698
46699 int64_t  CS_LDK_UnsignedChannelAnnouncement_read(int8_tArray ser) {
46700         LDKu8slice ser_ref;
46701         ser_ref.datalen = ser->arr_len;
46702         ser_ref.data = ser->elems;
46703         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
46704         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
46705         FREE(ser);
46706         return tag_ptr(ret_conv, true);
46707 }
46708
46709 int8_tArray  CS_LDK_ChannelAnnouncement_write(int64_t obj) {
46710         LDKChannelAnnouncement obj_conv;
46711         obj_conv.inner = untag_ptr(obj);
46712         obj_conv.is_owned = ptr_is_owned(obj);
46713         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46714         obj_conv.is_owned = false;
46715         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
46716         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46717         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46718         CVec_u8Z_free(ret_var);
46719         return ret_arr;
46720 }
46721
46722 int64_t  CS_LDK_ChannelAnnouncement_read(int8_tArray ser) {
46723         LDKu8slice ser_ref;
46724         ser_ref.datalen = ser->arr_len;
46725         ser_ref.data = ser->elems;
46726         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
46727         *ret_conv = ChannelAnnouncement_read(ser_ref);
46728         FREE(ser);
46729         return tag_ptr(ret_conv, true);
46730 }
46731
46732 int8_tArray  CS_LDK_UnsignedChannelUpdate_write(int64_t obj) {
46733         LDKUnsignedChannelUpdate obj_conv;
46734         obj_conv.inner = untag_ptr(obj);
46735         obj_conv.is_owned = ptr_is_owned(obj);
46736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46737         obj_conv.is_owned = false;
46738         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
46739         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46740         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46741         CVec_u8Z_free(ret_var);
46742         return ret_arr;
46743 }
46744
46745 int64_t  CS_LDK_UnsignedChannelUpdate_read(int8_tArray ser) {
46746         LDKu8slice ser_ref;
46747         ser_ref.datalen = ser->arr_len;
46748         ser_ref.data = ser->elems;
46749         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
46750         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
46751         FREE(ser);
46752         return tag_ptr(ret_conv, true);
46753 }
46754
46755 int8_tArray  CS_LDK_ChannelUpdate_write(int64_t obj) {
46756         LDKChannelUpdate obj_conv;
46757         obj_conv.inner = untag_ptr(obj);
46758         obj_conv.is_owned = ptr_is_owned(obj);
46759         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46760         obj_conv.is_owned = false;
46761         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
46762         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46763         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46764         CVec_u8Z_free(ret_var);
46765         return ret_arr;
46766 }
46767
46768 int64_t  CS_LDK_ChannelUpdate_read(int8_tArray ser) {
46769         LDKu8slice ser_ref;
46770         ser_ref.datalen = ser->arr_len;
46771         ser_ref.data = ser->elems;
46772         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
46773         *ret_conv = ChannelUpdate_read(ser_ref);
46774         FREE(ser);
46775         return tag_ptr(ret_conv, true);
46776 }
46777
46778 int8_tArray  CS_LDK_ErrorMessage_write(int64_t obj) {
46779         LDKErrorMessage obj_conv;
46780         obj_conv.inner = untag_ptr(obj);
46781         obj_conv.is_owned = ptr_is_owned(obj);
46782         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46783         obj_conv.is_owned = false;
46784         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
46785         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46786         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46787         CVec_u8Z_free(ret_var);
46788         return ret_arr;
46789 }
46790
46791 int64_t  CS_LDK_ErrorMessage_read(int8_tArray ser) {
46792         LDKu8slice ser_ref;
46793         ser_ref.datalen = ser->arr_len;
46794         ser_ref.data = ser->elems;
46795         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
46796         *ret_conv = ErrorMessage_read(ser_ref);
46797         FREE(ser);
46798         return tag_ptr(ret_conv, true);
46799 }
46800
46801 int8_tArray  CS_LDK_WarningMessage_write(int64_t obj) {
46802         LDKWarningMessage obj_conv;
46803         obj_conv.inner = untag_ptr(obj);
46804         obj_conv.is_owned = ptr_is_owned(obj);
46805         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46806         obj_conv.is_owned = false;
46807         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
46808         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46809         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46810         CVec_u8Z_free(ret_var);
46811         return ret_arr;
46812 }
46813
46814 int64_t  CS_LDK_WarningMessage_read(int8_tArray ser) {
46815         LDKu8slice ser_ref;
46816         ser_ref.datalen = ser->arr_len;
46817         ser_ref.data = ser->elems;
46818         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
46819         *ret_conv = WarningMessage_read(ser_ref);
46820         FREE(ser);
46821         return tag_ptr(ret_conv, true);
46822 }
46823
46824 int8_tArray  CS_LDK_UnsignedNodeAnnouncement_write(int64_t obj) {
46825         LDKUnsignedNodeAnnouncement obj_conv;
46826         obj_conv.inner = untag_ptr(obj);
46827         obj_conv.is_owned = ptr_is_owned(obj);
46828         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46829         obj_conv.is_owned = false;
46830         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
46831         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46832         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46833         CVec_u8Z_free(ret_var);
46834         return ret_arr;
46835 }
46836
46837 int64_t  CS_LDK_UnsignedNodeAnnouncement_read(int8_tArray ser) {
46838         LDKu8slice ser_ref;
46839         ser_ref.datalen = ser->arr_len;
46840         ser_ref.data = ser->elems;
46841         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
46842         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
46843         FREE(ser);
46844         return tag_ptr(ret_conv, true);
46845 }
46846
46847 int8_tArray  CS_LDK_NodeAnnouncement_write(int64_t obj) {
46848         LDKNodeAnnouncement obj_conv;
46849         obj_conv.inner = untag_ptr(obj);
46850         obj_conv.is_owned = ptr_is_owned(obj);
46851         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46852         obj_conv.is_owned = false;
46853         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
46854         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46855         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46856         CVec_u8Z_free(ret_var);
46857         return ret_arr;
46858 }
46859
46860 int64_t  CS_LDK_NodeAnnouncement_read(int8_tArray ser) {
46861         LDKu8slice ser_ref;
46862         ser_ref.datalen = ser->arr_len;
46863         ser_ref.data = ser->elems;
46864         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
46865         *ret_conv = NodeAnnouncement_read(ser_ref);
46866         FREE(ser);
46867         return tag_ptr(ret_conv, true);
46868 }
46869
46870 int64_t  CS_LDK_QueryShortChannelIds_read(int8_tArray ser) {
46871         LDKu8slice ser_ref;
46872         ser_ref.datalen = ser->arr_len;
46873         ser_ref.data = ser->elems;
46874         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
46875         *ret_conv = QueryShortChannelIds_read(ser_ref);
46876         FREE(ser);
46877         return tag_ptr(ret_conv, true);
46878 }
46879
46880 int8_tArray  CS_LDK_QueryShortChannelIds_write(int64_t obj) {
46881         LDKQueryShortChannelIds obj_conv;
46882         obj_conv.inner = untag_ptr(obj);
46883         obj_conv.is_owned = ptr_is_owned(obj);
46884         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46885         obj_conv.is_owned = false;
46886         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
46887         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46888         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46889         CVec_u8Z_free(ret_var);
46890         return ret_arr;
46891 }
46892
46893 int8_tArray  CS_LDK_ReplyShortChannelIdsEnd_write(int64_t obj) {
46894         LDKReplyShortChannelIdsEnd obj_conv;
46895         obj_conv.inner = untag_ptr(obj);
46896         obj_conv.is_owned = ptr_is_owned(obj);
46897         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46898         obj_conv.is_owned = false;
46899         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
46900         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46901         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46902         CVec_u8Z_free(ret_var);
46903         return ret_arr;
46904 }
46905
46906 int64_t  CS_LDK_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
46907         LDKu8slice ser_ref;
46908         ser_ref.datalen = ser->arr_len;
46909         ser_ref.data = ser->elems;
46910         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
46911         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
46912         FREE(ser);
46913         return tag_ptr(ret_conv, true);
46914 }
46915
46916 int32_t  CS_LDK_QueryChannelRange_end_blocknum(int64_t this_arg) {
46917         LDKQueryChannelRange this_arg_conv;
46918         this_arg_conv.inner = untag_ptr(this_arg);
46919         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46921         this_arg_conv.is_owned = false;
46922         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
46923         return ret_conv;
46924 }
46925
46926 int8_tArray  CS_LDK_QueryChannelRange_write(int64_t obj) {
46927         LDKQueryChannelRange obj_conv;
46928         obj_conv.inner = untag_ptr(obj);
46929         obj_conv.is_owned = ptr_is_owned(obj);
46930         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46931         obj_conv.is_owned = false;
46932         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
46933         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46934         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46935         CVec_u8Z_free(ret_var);
46936         return ret_arr;
46937 }
46938
46939 int64_t  CS_LDK_QueryChannelRange_read(int8_tArray ser) {
46940         LDKu8slice ser_ref;
46941         ser_ref.datalen = ser->arr_len;
46942         ser_ref.data = ser->elems;
46943         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
46944         *ret_conv = QueryChannelRange_read(ser_ref);
46945         FREE(ser);
46946         return tag_ptr(ret_conv, true);
46947 }
46948
46949 int64_t  CS_LDK_ReplyChannelRange_read(int8_tArray ser) {
46950         LDKu8slice ser_ref;
46951         ser_ref.datalen = ser->arr_len;
46952         ser_ref.data = ser->elems;
46953         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
46954         *ret_conv = ReplyChannelRange_read(ser_ref);
46955         FREE(ser);
46956         return tag_ptr(ret_conv, true);
46957 }
46958
46959 int8_tArray  CS_LDK_ReplyChannelRange_write(int64_t obj) {
46960         LDKReplyChannelRange obj_conv;
46961         obj_conv.inner = untag_ptr(obj);
46962         obj_conv.is_owned = ptr_is_owned(obj);
46963         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46964         obj_conv.is_owned = false;
46965         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
46966         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46967         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46968         CVec_u8Z_free(ret_var);
46969         return ret_arr;
46970 }
46971
46972 int8_tArray  CS_LDK_GossipTimestampFilter_write(int64_t obj) {
46973         LDKGossipTimestampFilter obj_conv;
46974         obj_conv.inner = untag_ptr(obj);
46975         obj_conv.is_owned = ptr_is_owned(obj);
46976         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46977         obj_conv.is_owned = false;
46978         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
46979         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
46980         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
46981         CVec_u8Z_free(ret_var);
46982         return ret_arr;
46983 }
46984
46985 int64_t  CS_LDK_GossipTimestampFilter_read(int8_tArray ser) {
46986         LDKu8slice ser_ref;
46987         ser_ref.datalen = ser->arr_len;
46988         ser_ref.data = ser->elems;
46989         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
46990         *ret_conv = GossipTimestampFilter_read(ser_ref);
46991         FREE(ser);
46992         return tag_ptr(ret_conv, true);
46993 }
46994
46995 void  CS_LDK_CustomMessageHandler_free(int64_t this_ptr) {
46996         if (!ptr_is_owned(this_ptr)) return;
46997         void* this_ptr_ptr = untag_ptr(this_ptr);
46998         CHECK_ACCESS(this_ptr_ptr);
46999         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
47000         FREE(untag_ptr(this_ptr));
47001         CustomMessageHandler_free(this_ptr_conv);
47002 }
47003
47004 void  CS_LDK_IgnoringMessageHandler_free(int64_t this_obj) {
47005         LDKIgnoringMessageHandler this_obj_conv;
47006         this_obj_conv.inner = untag_ptr(this_obj);
47007         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47009         IgnoringMessageHandler_free(this_obj_conv);
47010 }
47011
47012 int64_t  CS_LDK_IgnoringMessageHandler_new() {
47013         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
47014         int64_t ret_ref = 0;
47015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47017         return ret_ref;
47018 }
47019
47020 int64_t  CS_LDK_IgnoringMessageHandler_as_MessageSendEventsProvider(int64_t this_arg) {
47021         LDKIgnoringMessageHandler this_arg_conv;
47022         this_arg_conv.inner = untag_ptr(this_arg);
47023         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47025         this_arg_conv.is_owned = false;
47026         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
47027         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
47028         return tag_ptr(ret_ret, true);
47029 }
47030
47031 int64_t  CS_LDK_IgnoringMessageHandler_as_RoutingMessageHandler(int64_t this_arg) {
47032         LDKIgnoringMessageHandler this_arg_conv;
47033         this_arg_conv.inner = untag_ptr(this_arg);
47034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47036         this_arg_conv.is_owned = false;
47037         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
47038         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
47039         return tag_ptr(ret_ret, true);
47040 }
47041
47042 int64_t  CS_LDK_IgnoringMessageHandler_as_OnionMessageHandler(int64_t this_arg) {
47043         LDKIgnoringMessageHandler this_arg_conv;
47044         this_arg_conv.inner = untag_ptr(this_arg);
47045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47047         this_arg_conv.is_owned = false;
47048         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
47049         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
47050         return tag_ptr(ret_ret, true);
47051 }
47052
47053 int64_t  CS_LDK_IgnoringMessageHandler_as_OffersMessageHandler(int64_t this_arg) {
47054         LDKIgnoringMessageHandler this_arg_conv;
47055         this_arg_conv.inner = untag_ptr(this_arg);
47056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47058         this_arg_conv.is_owned = false;
47059         LDKOffersMessageHandler* ret_ret = MALLOC(sizeof(LDKOffersMessageHandler), "LDKOffersMessageHandler");
47060         *ret_ret = IgnoringMessageHandler_as_OffersMessageHandler(&this_arg_conv);
47061         return tag_ptr(ret_ret, true);
47062 }
47063
47064 int64_t  CS_LDK_IgnoringMessageHandler_as_CustomOnionMessageHandler(int64_t this_arg) {
47065         LDKIgnoringMessageHandler this_arg_conv;
47066         this_arg_conv.inner = untag_ptr(this_arg);
47067         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47069         this_arg_conv.is_owned = false;
47070         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
47071         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
47072         return tag_ptr(ret_ret, true);
47073 }
47074
47075 int64_t  CS_LDK_IgnoringMessageHandler_as_CustomMessageReader(int64_t this_arg) {
47076         LDKIgnoringMessageHandler this_arg_conv;
47077         this_arg_conv.inner = untag_ptr(this_arg);
47078         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47080         this_arg_conv.is_owned = false;
47081         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
47082         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
47083         return tag_ptr(ret_ret, true);
47084 }
47085
47086 int64_t  CS_LDK_IgnoringMessageHandler_as_CustomMessageHandler(int64_t this_arg) {
47087         LDKIgnoringMessageHandler this_arg_conv;
47088         this_arg_conv.inner = untag_ptr(this_arg);
47089         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47091         this_arg_conv.is_owned = false;
47092         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
47093         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
47094         return tag_ptr(ret_ret, true);
47095 }
47096
47097 void  CS_LDK_ErroringMessageHandler_free(int64_t this_obj) {
47098         LDKErroringMessageHandler this_obj_conv;
47099         this_obj_conv.inner = untag_ptr(this_obj);
47100         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47102         ErroringMessageHandler_free(this_obj_conv);
47103 }
47104
47105 int64_t  CS_LDK_ErroringMessageHandler_new() {
47106         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
47107         int64_t ret_ref = 0;
47108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47110         return ret_ref;
47111 }
47112
47113 int64_t  CS_LDK_ErroringMessageHandler_as_MessageSendEventsProvider(int64_t this_arg) {
47114         LDKErroringMessageHandler this_arg_conv;
47115         this_arg_conv.inner = untag_ptr(this_arg);
47116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47118         this_arg_conv.is_owned = false;
47119         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
47120         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
47121         return tag_ptr(ret_ret, true);
47122 }
47123
47124 int64_t  CS_LDK_ErroringMessageHandler_as_ChannelMessageHandler(int64_t this_arg) {
47125         LDKErroringMessageHandler this_arg_conv;
47126         this_arg_conv.inner = untag_ptr(this_arg);
47127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47129         this_arg_conv.is_owned = false;
47130         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
47131         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
47132         return tag_ptr(ret_ret, true);
47133 }
47134
47135 void  CS_LDK_MessageHandler_free(int64_t this_obj) {
47136         LDKMessageHandler this_obj_conv;
47137         this_obj_conv.inner = untag_ptr(this_obj);
47138         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47140         MessageHandler_free(this_obj_conv);
47141 }
47142
47143 int64_t  CS_LDK_MessageHandler_get_chan_handler(int64_t this_ptr) {
47144         LDKMessageHandler this_ptr_conv;
47145         this_ptr_conv.inner = untag_ptr(this_ptr);
47146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47148         this_ptr_conv.is_owned = false;
47149         // WARNING: This object doesn't live past this scope, needs clone!
47150         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
47151         return ret_ret;
47152 }
47153
47154 void  CS_LDK_MessageHandler_set_chan_handler(int64_t this_ptr, int64_t val) {
47155         LDKMessageHandler this_ptr_conv;
47156         this_ptr_conv.inner = untag_ptr(this_ptr);
47157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47159         this_ptr_conv.is_owned = false;
47160         void* val_ptr = untag_ptr(val);
47161         CHECK_ACCESS(val_ptr);
47162         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
47163         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
47164                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47165                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
47166         }
47167         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
47168 }
47169
47170 int64_t  CS_LDK_MessageHandler_get_route_handler(int64_t this_ptr) {
47171         LDKMessageHandler this_ptr_conv;
47172         this_ptr_conv.inner = untag_ptr(this_ptr);
47173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47175         this_ptr_conv.is_owned = false;
47176         // WARNING: This object doesn't live past this scope, needs clone!
47177         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
47178         return ret_ret;
47179 }
47180
47181 void  CS_LDK_MessageHandler_set_route_handler(int64_t this_ptr, int64_t val) {
47182         LDKMessageHandler this_ptr_conv;
47183         this_ptr_conv.inner = untag_ptr(this_ptr);
47184         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47186         this_ptr_conv.is_owned = false;
47187         void* val_ptr = untag_ptr(val);
47188         CHECK_ACCESS(val_ptr);
47189         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
47190         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
47191                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47192                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
47193         }
47194         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
47195 }
47196
47197 int64_t  CS_LDK_MessageHandler_get_onion_message_handler(int64_t this_ptr) {
47198         LDKMessageHandler this_ptr_conv;
47199         this_ptr_conv.inner = untag_ptr(this_ptr);
47200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47202         this_ptr_conv.is_owned = false;
47203         // WARNING: This object doesn't live past this scope, needs clone!
47204         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
47205         return ret_ret;
47206 }
47207
47208 void  CS_LDK_MessageHandler_set_onion_message_handler(int64_t this_ptr, int64_t val) {
47209         LDKMessageHandler this_ptr_conv;
47210         this_ptr_conv.inner = untag_ptr(this_ptr);
47211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47213         this_ptr_conv.is_owned = false;
47214         void* val_ptr = untag_ptr(val);
47215         CHECK_ACCESS(val_ptr);
47216         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
47217         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
47218                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47219                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
47220         }
47221         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
47222 }
47223
47224 int64_t  CS_LDK_MessageHandler_get_custom_message_handler(int64_t this_ptr) {
47225         LDKMessageHandler this_ptr_conv;
47226         this_ptr_conv.inner = untag_ptr(this_ptr);
47227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47229         this_ptr_conv.is_owned = false;
47230         // WARNING: This object doesn't live past this scope, needs clone!
47231         int64_t ret_ret = tag_ptr(MessageHandler_get_custom_message_handler(&this_ptr_conv), false);
47232         return ret_ret;
47233 }
47234
47235 void  CS_LDK_MessageHandler_set_custom_message_handler(int64_t this_ptr, int64_t val) {
47236         LDKMessageHandler this_ptr_conv;
47237         this_ptr_conv.inner = untag_ptr(this_ptr);
47238         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47240         this_ptr_conv.is_owned = false;
47241         void* val_ptr = untag_ptr(val);
47242         CHECK_ACCESS(val_ptr);
47243         LDKCustomMessageHandler val_conv = *(LDKCustomMessageHandler*)(val_ptr);
47244         if (val_conv.free == LDKCustomMessageHandler_JCalls_free) {
47245                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47246                 LDKCustomMessageHandler_JCalls_cloned(&val_conv);
47247         }
47248         MessageHandler_set_custom_message_handler(&this_ptr_conv, val_conv);
47249 }
47250
47251 int64_t  CS_LDK_MessageHandler_new(int64_t chan_handler_arg, int64_t route_handler_arg, int64_t onion_message_handler_arg, int64_t custom_message_handler_arg) {
47252         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
47253         CHECK_ACCESS(chan_handler_arg_ptr);
47254         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
47255         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
47256                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47257                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
47258         }
47259         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
47260         CHECK_ACCESS(route_handler_arg_ptr);
47261         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
47262         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
47263                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47264                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
47265         }
47266         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
47267         CHECK_ACCESS(onion_message_handler_arg_ptr);
47268         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
47269         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
47270                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47271                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
47272         }
47273         void* custom_message_handler_arg_ptr = untag_ptr(custom_message_handler_arg);
47274         CHECK_ACCESS(custom_message_handler_arg_ptr);
47275         LDKCustomMessageHandler custom_message_handler_arg_conv = *(LDKCustomMessageHandler*)(custom_message_handler_arg_ptr);
47276         if (custom_message_handler_arg_conv.free == LDKCustomMessageHandler_JCalls_free) {
47277                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47278                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_arg_conv);
47279         }
47280         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv, custom_message_handler_arg_conv);
47281         int64_t ret_ref = 0;
47282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47283         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47284         return ret_ref;
47285 }
47286
47287 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
47288         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
47289         *ret_ret = SocketDescriptor_clone(arg);
47290         return tag_ptr(ret_ret, true);
47291 }
47292 int64_t  CS_LDK_SocketDescriptor_clone_ptr(int64_t arg) {
47293         void* arg_ptr = untag_ptr(arg);
47294         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
47295         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
47296         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
47297         return ret_conv;
47298 }
47299
47300 int64_t  CS_LDK_SocketDescriptor_clone(int64_t orig) {
47301         void* orig_ptr = untag_ptr(orig);
47302         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
47303         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
47304         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
47305         *ret_ret = SocketDescriptor_clone(orig_conv);
47306         return tag_ptr(ret_ret, true);
47307 }
47308
47309 void  CS_LDK_SocketDescriptor_free(int64_t this_ptr) {
47310         if (!ptr_is_owned(this_ptr)) return;
47311         void* this_ptr_ptr = untag_ptr(this_ptr);
47312         CHECK_ACCESS(this_ptr_ptr);
47313         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
47314         FREE(untag_ptr(this_ptr));
47315         SocketDescriptor_free(this_ptr_conv);
47316 }
47317
47318 void  CS_LDK_PeerHandleError_free(int64_t this_obj) {
47319         LDKPeerHandleError this_obj_conv;
47320         this_obj_conv.inner = untag_ptr(this_obj);
47321         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47323         PeerHandleError_free(this_obj_conv);
47324 }
47325
47326 int64_t  CS_LDK_PeerHandleError_new() {
47327         LDKPeerHandleError ret_var = PeerHandleError_new();
47328         int64_t ret_ref = 0;
47329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47331         return ret_ref;
47332 }
47333
47334 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
47335         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
47336         int64_t ret_ref = 0;
47337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47338         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47339         return ret_ref;
47340 }
47341 int64_t  CS_LDK_PeerHandleError_clone_ptr(int64_t arg) {
47342         LDKPeerHandleError arg_conv;
47343         arg_conv.inner = untag_ptr(arg);
47344         arg_conv.is_owned = ptr_is_owned(arg);
47345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47346         arg_conv.is_owned = false;
47347         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
47348         return ret_conv;
47349 }
47350
47351 int64_t  CS_LDK_PeerHandleError_clone(int64_t orig) {
47352         LDKPeerHandleError orig_conv;
47353         orig_conv.inner = untag_ptr(orig);
47354         orig_conv.is_owned = ptr_is_owned(orig);
47355         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47356         orig_conv.is_owned = false;
47357         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
47358         int64_t ret_ref = 0;
47359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47361         return ret_ref;
47362 }
47363
47364 void  CS_LDK_PeerManager_free(int64_t this_obj) {
47365         LDKPeerManager this_obj_conv;
47366         this_obj_conv.inner = untag_ptr(this_obj);
47367         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47369         PeerManager_free(this_obj_conv);
47370 }
47371
47372 int64_t  CS_LDK_PeerManager_new(int64_t message_handler, int32_t current_time, int8_tArray ephemeral_random_data, int64_t logger, int64_t node_signer) {
47373         LDKMessageHandler message_handler_conv;
47374         message_handler_conv.inner = untag_ptr(message_handler);
47375         message_handler_conv.is_owned = ptr_is_owned(message_handler);
47376         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
47377         // WARNING: we need a move here but no clone is available for LDKMessageHandler
47378         
47379         uint8_t ephemeral_random_data_arr[32];
47380         CHECK(ephemeral_random_data->arr_len == 32);
47381         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
47382         uint8_t (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
47383         void* logger_ptr = untag_ptr(logger);
47384         CHECK_ACCESS(logger_ptr);
47385         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47386         if (logger_conv.free == LDKLogger_JCalls_free) {
47387                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47388                 LDKLogger_JCalls_cloned(&logger_conv);
47389         }
47390         void* node_signer_ptr = untag_ptr(node_signer);
47391         CHECK_ACCESS(node_signer_ptr);
47392         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
47393         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
47394                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47395                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
47396         }
47397         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, current_time, ephemeral_random_data_ref, logger_conv, node_signer_conv);
47398         int64_t ret_ref = 0;
47399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47401         return ret_ref;
47402 }
47403
47404 int64_tArray  CS_LDK_PeerManager_get_peer_node_ids(int64_t this_arg) {
47405         LDKPeerManager this_arg_conv;
47406         this_arg_conv.inner = untag_ptr(this_arg);
47407         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47409         this_arg_conv.is_owned = false;
47410         LDKCVec_C2Tuple_PublicKeyCOption_SocketAddressZZZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
47411         int64_tArray ret_arr = NULL;
47412         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
47413         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
47414         for (size_t r = 0; r < ret_var.datalen; r++) {
47415                 LDKC2Tuple_PublicKeyCOption_SocketAddressZZ* ret_conv_43_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyCOption_SocketAddressZZ), "LDKC2Tuple_PublicKeyCOption_SocketAddressZZ");
47416                 *ret_conv_43_conv = ret_var.data[r];
47417                 ret_arr_ptr[r] = tag_ptr(ret_conv_43_conv, true);
47418         }
47419         
47420         FREE(ret_var.data);
47421         return ret_arr;
47422 }
47423
47424 int64_t  CS_LDK_PeerManager_new_outbound_connection(int64_t this_arg, int8_tArray their_node_id, int64_t descriptor, int64_t remote_network_address) {
47425         LDKPeerManager this_arg_conv;
47426         this_arg_conv.inner = untag_ptr(this_arg);
47427         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47429         this_arg_conv.is_owned = false;
47430         LDKPublicKey their_node_id_ref;
47431         CHECK(their_node_id->arr_len == 33);
47432         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
47433         void* descriptor_ptr = untag_ptr(descriptor);
47434         CHECK_ACCESS(descriptor_ptr);
47435         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
47436         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
47437                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47438                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
47439         }
47440         void* remote_network_address_ptr = untag_ptr(remote_network_address);
47441         CHECK_ACCESS(remote_network_address_ptr);
47442         LDKCOption_SocketAddressZ remote_network_address_conv = *(LDKCOption_SocketAddressZ*)(remote_network_address_ptr);
47443         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
47444         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
47445         return tag_ptr(ret_conv, true);
47446 }
47447
47448 int64_t  CS_LDK_PeerManager_new_inbound_connection(int64_t this_arg, int64_t descriptor, int64_t remote_network_address) {
47449         LDKPeerManager this_arg_conv;
47450         this_arg_conv.inner = untag_ptr(this_arg);
47451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47453         this_arg_conv.is_owned = false;
47454         void* descriptor_ptr = untag_ptr(descriptor);
47455         CHECK_ACCESS(descriptor_ptr);
47456         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
47457         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
47458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47459                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
47460         }
47461         void* remote_network_address_ptr = untag_ptr(remote_network_address);
47462         CHECK_ACCESS(remote_network_address_ptr);
47463         LDKCOption_SocketAddressZ remote_network_address_conv = *(LDKCOption_SocketAddressZ*)(remote_network_address_ptr);
47464         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
47465         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
47466         return tag_ptr(ret_conv, true);
47467 }
47468
47469 int64_t  CS_LDK_PeerManager_write_buffer_space_avail(int64_t this_arg, int64_t descriptor) {
47470         LDKPeerManager this_arg_conv;
47471         this_arg_conv.inner = untag_ptr(this_arg);
47472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47474         this_arg_conv.is_owned = false;
47475         void* descriptor_ptr = untag_ptr(descriptor);
47476         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
47477         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
47478         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
47479         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
47480         return tag_ptr(ret_conv, true);
47481 }
47482
47483 int64_t  CS_LDK_PeerManager_read_event(int64_t this_arg, int64_t peer_descriptor, int8_tArray data) {
47484         LDKPeerManager this_arg_conv;
47485         this_arg_conv.inner = untag_ptr(this_arg);
47486         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47488         this_arg_conv.is_owned = false;
47489         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
47490         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
47491         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
47492         LDKu8slice data_ref;
47493         data_ref.datalen = data->arr_len;
47494         data_ref.data = data->elems;
47495         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
47496         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
47497         FREE(data);
47498         return tag_ptr(ret_conv, true);
47499 }
47500
47501 void  CS_LDK_PeerManager_process_events(int64_t this_arg) {
47502         LDKPeerManager this_arg_conv;
47503         this_arg_conv.inner = untag_ptr(this_arg);
47504         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47506         this_arg_conv.is_owned = false;
47507         PeerManager_process_events(&this_arg_conv);
47508 }
47509
47510 void  CS_LDK_PeerManager_socket_disconnected(int64_t this_arg, int64_t descriptor) {
47511         LDKPeerManager this_arg_conv;
47512         this_arg_conv.inner = untag_ptr(this_arg);
47513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47515         this_arg_conv.is_owned = false;
47516         void* descriptor_ptr = untag_ptr(descriptor);
47517         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
47518         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
47519         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
47520 }
47521
47522 void  CS_LDK_PeerManager_disconnect_by_node_id(int64_t this_arg, int8_tArray node_id) {
47523         LDKPeerManager this_arg_conv;
47524         this_arg_conv.inner = untag_ptr(this_arg);
47525         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47527         this_arg_conv.is_owned = false;
47528         LDKPublicKey node_id_ref;
47529         CHECK(node_id->arr_len == 33);
47530         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
47531         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref);
47532 }
47533
47534 void  CS_LDK_PeerManager_disconnect_all_peers(int64_t this_arg) {
47535         LDKPeerManager this_arg_conv;
47536         this_arg_conv.inner = untag_ptr(this_arg);
47537         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47539         this_arg_conv.is_owned = false;
47540         PeerManager_disconnect_all_peers(&this_arg_conv);
47541 }
47542
47543 void  CS_LDK_PeerManager_timer_tick_occurred(int64_t this_arg) {
47544         LDKPeerManager this_arg_conv;
47545         this_arg_conv.inner = untag_ptr(this_arg);
47546         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47548         this_arg_conv.is_owned = false;
47549         PeerManager_timer_tick_occurred(&this_arg_conv);
47550 }
47551
47552 void  CS_LDK_PeerManager_broadcast_node_announcement(int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
47553         LDKPeerManager this_arg_conv;
47554         this_arg_conv.inner = untag_ptr(this_arg);
47555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47557         this_arg_conv.is_owned = false;
47558         LDKThreeBytes rgb_ref;
47559         CHECK(rgb->arr_len == 3);
47560         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
47561         LDKThirtyTwoBytes alias_ref;
47562         CHECK(alias->arr_len == 32);
47563         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
47564         LDKCVec_SocketAddressZ addresses_constr;
47565         addresses_constr.datalen = addresses->arr_len;
47566         if (addresses_constr.datalen > 0)
47567                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKSocketAddress), "LDKCVec_SocketAddressZ Elements");
47568         else
47569                 addresses_constr.data = NULL;
47570         int64_t* addresses_vals = addresses->elems;
47571         for (size_t p = 0; p < addresses_constr.datalen; p++) {
47572                 int64_t addresses_conv_15 = addresses_vals[p];
47573                 void* addresses_conv_15_ptr = untag_ptr(addresses_conv_15);
47574                 CHECK_ACCESS(addresses_conv_15_ptr);
47575                 LDKSocketAddress addresses_conv_15_conv = *(LDKSocketAddress*)(addresses_conv_15_ptr);
47576                 addresses_constr.data[p] = addresses_conv_15_conv;
47577         }
47578         FREE(addresses);
47579         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
47580 }
47581
47582 int64_t  CS_LDK_htlc_success_tx_weight(int64_t channel_type_features) {
47583         LDKChannelTypeFeatures channel_type_features_conv;
47584         channel_type_features_conv.inner = untag_ptr(channel_type_features);
47585         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
47586         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
47587         channel_type_features_conv.is_owned = false;
47588         int64_t ret_conv = htlc_success_tx_weight(&channel_type_features_conv);
47589         return ret_conv;
47590 }
47591
47592 int64_t  CS_LDK_htlc_timeout_tx_weight(int64_t channel_type_features) {
47593         LDKChannelTypeFeatures channel_type_features_conv;
47594         channel_type_features_conv.inner = untag_ptr(channel_type_features);
47595         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
47596         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
47597         channel_type_features_conv.is_owned = false;
47598         int64_t ret_conv = htlc_timeout_tx_weight(&channel_type_features_conv);
47599         return ret_conv;
47600 }
47601
47602 int32_t  CS_LDK_HTLCClaim_clone(int64_t orig) {
47603         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
47604         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_clone(orig_conv));
47605         return ret_conv;
47606 }
47607
47608 int32_t  CS_LDK_HTLCClaim_offered_timeout() {
47609         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_offered_timeout());
47610         return ret_conv;
47611 }
47612
47613 int32_t  CS_LDK_HTLCClaim_offered_preimage() {
47614         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_offered_preimage());
47615         return ret_conv;
47616 }
47617
47618 int32_t  CS_LDK_HTLCClaim_accepted_timeout() {
47619         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_accepted_timeout());
47620         return ret_conv;
47621 }
47622
47623 int32_t  CS_LDK_HTLCClaim_accepted_preimage() {
47624         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_accepted_preimage());
47625         return ret_conv;
47626 }
47627
47628 int32_t  CS_LDK_HTLCClaim_revocation() {
47629         int32_t ret_conv = LDKHTLCClaim_to_cs(HTLCClaim_revocation());
47630         return ret_conv;
47631 }
47632
47633 jboolean  CS_LDK_HTLCClaim_eq(int64_t a, int64_t b) {
47634         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
47635         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
47636         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
47637         return ret_conv;
47638 }
47639
47640 int64_t  CS_LDK_HTLCClaim_from_witness(int8_tArray witness) {
47641         LDKWitness witness_ref;
47642         witness_ref.datalen = witness->arr_len;
47643         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
47644         memcpy(witness_ref.data, witness->elems, witness_ref.datalen); FREE(witness);
47645         witness_ref.data_is_owned = true;
47646         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
47647         *ret_copy = HTLCClaim_from_witness(witness_ref);
47648         int64_t ret_ref = tag_ptr(ret_copy, true);
47649         return ret_ref;
47650 }
47651
47652 int8_tArray  CS_LDK_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
47653         uint8_t commitment_seed_arr[32];
47654         CHECK(commitment_seed->arr_len == 32);
47655         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
47656         uint8_t (*commitment_seed_ref)[32] = &commitment_seed_arr;
47657         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47658         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
47659         return ret_arr;
47660 }
47661
47662 int8_tArray  CS_LDK_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, int64_t funding_outpoint) {
47663         LDKCVec_u8Z to_holder_script_ref;
47664         to_holder_script_ref.datalen = to_holder_script->arr_len;
47665         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
47666         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
47667         LDKCVec_u8Z to_counterparty_script_ref;
47668         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
47669         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
47670         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
47671         LDKOutPoint funding_outpoint_conv;
47672         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
47673         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
47674         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
47675         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
47676         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);
47677         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
47678         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
47679         Transaction_free(ret_var);
47680         return ret_arr;
47681 }
47682
47683 void  CS_LDK_CounterpartyCommitmentSecrets_free(int64_t this_obj) {
47684         LDKCounterpartyCommitmentSecrets this_obj_conv;
47685         this_obj_conv.inner = untag_ptr(this_obj);
47686         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47688         CounterpartyCommitmentSecrets_free(this_obj_conv);
47689 }
47690
47691 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
47692         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
47693         int64_t ret_ref = 0;
47694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47696         return ret_ref;
47697 }
47698 int64_t  CS_LDK_CounterpartyCommitmentSecrets_clone_ptr(int64_t arg) {
47699         LDKCounterpartyCommitmentSecrets arg_conv;
47700         arg_conv.inner = untag_ptr(arg);
47701         arg_conv.is_owned = ptr_is_owned(arg);
47702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47703         arg_conv.is_owned = false;
47704         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
47705         return ret_conv;
47706 }
47707
47708 int64_t  CS_LDK_CounterpartyCommitmentSecrets_clone(int64_t orig) {
47709         LDKCounterpartyCommitmentSecrets orig_conv;
47710         orig_conv.inner = untag_ptr(orig);
47711         orig_conv.is_owned = ptr_is_owned(orig);
47712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47713         orig_conv.is_owned = false;
47714         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
47715         int64_t ret_ref = 0;
47716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47718         return ret_ref;
47719 }
47720
47721 int64_t  CS_LDK_CounterpartyCommitmentSecrets_new() {
47722         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
47723         int64_t ret_ref = 0;
47724         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47725         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47726         return ret_ref;
47727 }
47728
47729 int64_t  CS_LDK_CounterpartyCommitmentSecrets_get_min_seen_secret(int64_t this_arg) {
47730         LDKCounterpartyCommitmentSecrets this_arg_conv;
47731         this_arg_conv.inner = untag_ptr(this_arg);
47732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47734         this_arg_conv.is_owned = false;
47735         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
47736         return ret_conv;
47737 }
47738
47739 int64_t  CS_LDK_CounterpartyCommitmentSecrets_provide_secret(int64_t this_arg, int64_t idx, int8_tArray secret) {
47740         LDKCounterpartyCommitmentSecrets this_arg_conv;
47741         this_arg_conv.inner = untag_ptr(this_arg);
47742         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47744         this_arg_conv.is_owned = false;
47745         LDKThirtyTwoBytes secret_ref;
47746         CHECK(secret->arr_len == 32);
47747         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
47748         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
47749         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
47750         return tag_ptr(ret_conv, true);
47751 }
47752
47753 int8_tArray  CS_LDK_CounterpartyCommitmentSecrets_get_secret(int64_t this_arg, int64_t idx) {
47754         LDKCounterpartyCommitmentSecrets this_arg_conv;
47755         this_arg_conv.inner = untag_ptr(this_arg);
47756         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47758         this_arg_conv.is_owned = false;
47759         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47760         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
47761         return ret_arr;
47762 }
47763
47764 int8_tArray  CS_LDK_CounterpartyCommitmentSecrets_write(int64_t obj) {
47765         LDKCounterpartyCommitmentSecrets obj_conv;
47766         obj_conv.inner = untag_ptr(obj);
47767         obj_conv.is_owned = ptr_is_owned(obj);
47768         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47769         obj_conv.is_owned = false;
47770         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
47771         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
47772         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
47773         CVec_u8Z_free(ret_var);
47774         return ret_arr;
47775 }
47776
47777 int64_t  CS_LDK_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
47778         LDKu8slice ser_ref;
47779         ser_ref.datalen = ser->arr_len;
47780         ser_ref.data = ser->elems;
47781         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
47782         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
47783         FREE(ser);
47784         return tag_ptr(ret_conv, true);
47785 }
47786
47787 int8_tArray  CS_LDK_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
47788         LDKPublicKey per_commitment_point_ref;
47789         CHECK(per_commitment_point->arr_len == 33);
47790         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
47791         uint8_t base_secret_arr[32];
47792         CHECK(base_secret->arr_len == 32);
47793         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
47794         uint8_t (*base_secret_ref)[32] = &base_secret_arr;
47795         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47796         memcpy(ret_arr->elems, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes, 32);
47797         return ret_arr;
47798 }
47799
47800 int8_tArray  CS_LDK_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
47801         LDKPublicKey per_commitment_point_ref;
47802         CHECK(per_commitment_point->arr_len == 33);
47803         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
47804         LDKPublicKey base_point_ref;
47805         CHECK(base_point->arr_len == 33);
47806         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
47807         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47808         memcpy(ret_arr->elems, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form, 33);
47809         return ret_arr;
47810 }
47811
47812 int8_tArray  CS_LDK_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
47813         uint8_t per_commitment_secret_arr[32];
47814         CHECK(per_commitment_secret->arr_len == 32);
47815         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
47816         uint8_t (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
47817         uint8_t countersignatory_revocation_base_secret_arr[32];
47818         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
47819         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
47820         uint8_t (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
47821         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
47822         memcpy(ret_arr->elems, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes, 32);
47823         return ret_arr;
47824 }
47825
47826 int8_tArray  CS_LDK_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
47827         LDKPublicKey per_commitment_point_ref;
47828         CHECK(per_commitment_point->arr_len == 33);
47829         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
47830         LDKPublicKey countersignatory_revocation_base_point_ref;
47831         CHECK(countersignatory_revocation_base_point->arr_len == 33);
47832         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
47833         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47834         memcpy(ret_arr->elems, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form, 33);
47835         return ret_arr;
47836 }
47837
47838 void  CS_LDK_TxCreationKeys_free(int64_t this_obj) {
47839         LDKTxCreationKeys this_obj_conv;
47840         this_obj_conv.inner = untag_ptr(this_obj);
47841         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47843         TxCreationKeys_free(this_obj_conv);
47844 }
47845
47846 int8_tArray  CS_LDK_TxCreationKeys_get_per_commitment_point(int64_t this_ptr) {
47847         LDKTxCreationKeys this_ptr_conv;
47848         this_ptr_conv.inner = untag_ptr(this_ptr);
47849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47851         this_ptr_conv.is_owned = false;
47852         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47853         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
47854         return ret_arr;
47855 }
47856
47857 void  CS_LDK_TxCreationKeys_set_per_commitment_point(int64_t this_ptr, int8_tArray val) {
47858         LDKTxCreationKeys this_ptr_conv;
47859         this_ptr_conv.inner = untag_ptr(this_ptr);
47860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47862         this_ptr_conv.is_owned = false;
47863         LDKPublicKey val_ref;
47864         CHECK(val->arr_len == 33);
47865         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47866         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
47867 }
47868
47869 int8_tArray  CS_LDK_TxCreationKeys_get_revocation_key(int64_t this_ptr) {
47870         LDKTxCreationKeys this_ptr_conv;
47871         this_ptr_conv.inner = untag_ptr(this_ptr);
47872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47874         this_ptr_conv.is_owned = false;
47875         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47876         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
47877         return ret_arr;
47878 }
47879
47880 void  CS_LDK_TxCreationKeys_set_revocation_key(int64_t this_ptr, int8_tArray val) {
47881         LDKTxCreationKeys this_ptr_conv;
47882         this_ptr_conv.inner = untag_ptr(this_ptr);
47883         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47885         this_ptr_conv.is_owned = false;
47886         LDKPublicKey val_ref;
47887         CHECK(val->arr_len == 33);
47888         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47889         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
47890 }
47891
47892 int8_tArray  CS_LDK_TxCreationKeys_get_broadcaster_htlc_key(int64_t this_ptr) {
47893         LDKTxCreationKeys this_ptr_conv;
47894         this_ptr_conv.inner = untag_ptr(this_ptr);
47895         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47897         this_ptr_conv.is_owned = false;
47898         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47899         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
47900         return ret_arr;
47901 }
47902
47903 void  CS_LDK_TxCreationKeys_set_broadcaster_htlc_key(int64_t this_ptr, int8_tArray val) {
47904         LDKTxCreationKeys this_ptr_conv;
47905         this_ptr_conv.inner = untag_ptr(this_ptr);
47906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47908         this_ptr_conv.is_owned = false;
47909         LDKPublicKey val_ref;
47910         CHECK(val->arr_len == 33);
47911         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47912         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
47913 }
47914
47915 int8_tArray  CS_LDK_TxCreationKeys_get_countersignatory_htlc_key(int64_t this_ptr) {
47916         LDKTxCreationKeys this_ptr_conv;
47917         this_ptr_conv.inner = untag_ptr(this_ptr);
47918         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47920         this_ptr_conv.is_owned = false;
47921         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47922         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
47923         return ret_arr;
47924 }
47925
47926 void  CS_LDK_TxCreationKeys_set_countersignatory_htlc_key(int64_t this_ptr, int8_tArray val) {
47927         LDKTxCreationKeys this_ptr_conv;
47928         this_ptr_conv.inner = untag_ptr(this_ptr);
47929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47931         this_ptr_conv.is_owned = false;
47932         LDKPublicKey val_ref;
47933         CHECK(val->arr_len == 33);
47934         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47935         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
47936 }
47937
47938 int8_tArray  CS_LDK_TxCreationKeys_get_broadcaster_delayed_payment_key(int64_t this_ptr) {
47939         LDKTxCreationKeys this_ptr_conv;
47940         this_ptr_conv.inner = untag_ptr(this_ptr);
47941         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47943         this_ptr_conv.is_owned = false;
47944         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
47945         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
47946         return ret_arr;
47947 }
47948
47949 void  CS_LDK_TxCreationKeys_set_broadcaster_delayed_payment_key(int64_t this_ptr, int8_tArray val) {
47950         LDKTxCreationKeys this_ptr_conv;
47951         this_ptr_conv.inner = untag_ptr(this_ptr);
47952         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47954         this_ptr_conv.is_owned = false;
47955         LDKPublicKey val_ref;
47956         CHECK(val->arr_len == 33);
47957         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
47958         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
47959 }
47960
47961 int64_t  CS_LDK_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) {
47962         LDKPublicKey per_commitment_point_arg_ref;
47963         CHECK(per_commitment_point_arg->arr_len == 33);
47964         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
47965         LDKPublicKey revocation_key_arg_ref;
47966         CHECK(revocation_key_arg->arr_len == 33);
47967         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
47968         LDKPublicKey broadcaster_htlc_key_arg_ref;
47969         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
47970         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
47971         LDKPublicKey countersignatory_htlc_key_arg_ref;
47972         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
47973         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
47974         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
47975         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
47976         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
47977         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);
47978         int64_t ret_ref = 0;
47979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47981         return ret_ref;
47982 }
47983
47984 jboolean  CS_LDK_TxCreationKeys_eq(int64_t a, int64_t b) {
47985         LDKTxCreationKeys a_conv;
47986         a_conv.inner = untag_ptr(a);
47987         a_conv.is_owned = ptr_is_owned(a);
47988         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47989         a_conv.is_owned = false;
47990         LDKTxCreationKeys b_conv;
47991         b_conv.inner = untag_ptr(b);
47992         b_conv.is_owned = ptr_is_owned(b);
47993         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47994         b_conv.is_owned = false;
47995         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
47996         return ret_conv;
47997 }
47998
47999 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
48000         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
48001         int64_t ret_ref = 0;
48002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48004         return ret_ref;
48005 }
48006 int64_t  CS_LDK_TxCreationKeys_clone_ptr(int64_t arg) {
48007         LDKTxCreationKeys arg_conv;
48008         arg_conv.inner = untag_ptr(arg);
48009         arg_conv.is_owned = ptr_is_owned(arg);
48010         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48011         arg_conv.is_owned = false;
48012         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
48013         return ret_conv;
48014 }
48015
48016 int64_t  CS_LDK_TxCreationKeys_clone(int64_t orig) {
48017         LDKTxCreationKeys orig_conv;
48018         orig_conv.inner = untag_ptr(orig);
48019         orig_conv.is_owned = ptr_is_owned(orig);
48020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48021         orig_conv.is_owned = false;
48022         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
48023         int64_t ret_ref = 0;
48024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48025         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48026         return ret_ref;
48027 }
48028
48029 int8_tArray  CS_LDK_TxCreationKeys_write(int64_t obj) {
48030         LDKTxCreationKeys obj_conv;
48031         obj_conv.inner = untag_ptr(obj);
48032         obj_conv.is_owned = ptr_is_owned(obj);
48033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48034         obj_conv.is_owned = false;
48035         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
48036         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48037         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48038         CVec_u8Z_free(ret_var);
48039         return ret_arr;
48040 }
48041
48042 int64_t  CS_LDK_TxCreationKeys_read(int8_tArray ser) {
48043         LDKu8slice ser_ref;
48044         ser_ref.datalen = ser->arr_len;
48045         ser_ref.data = ser->elems;
48046         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
48047         *ret_conv = TxCreationKeys_read(ser_ref);
48048         FREE(ser);
48049         return tag_ptr(ret_conv, true);
48050 }
48051
48052 void  CS_LDK_ChannelPublicKeys_free(int64_t this_obj) {
48053         LDKChannelPublicKeys this_obj_conv;
48054         this_obj_conv.inner = untag_ptr(this_obj);
48055         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48057         ChannelPublicKeys_free(this_obj_conv);
48058 }
48059
48060 int8_tArray  CS_LDK_ChannelPublicKeys_get_funding_pubkey(int64_t this_ptr) {
48061         LDKChannelPublicKeys this_ptr_conv;
48062         this_ptr_conv.inner = untag_ptr(this_ptr);
48063         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48065         this_ptr_conv.is_owned = false;
48066         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48067         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
48068         return ret_arr;
48069 }
48070
48071 void  CS_LDK_ChannelPublicKeys_set_funding_pubkey(int64_t this_ptr, int8_tArray val) {
48072         LDKChannelPublicKeys this_ptr_conv;
48073         this_ptr_conv.inner = untag_ptr(this_ptr);
48074         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48076         this_ptr_conv.is_owned = false;
48077         LDKPublicKey val_ref;
48078         CHECK(val->arr_len == 33);
48079         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48080         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
48081 }
48082
48083 int8_tArray  CS_LDK_ChannelPublicKeys_get_revocation_basepoint(int64_t this_ptr) {
48084         LDKChannelPublicKeys this_ptr_conv;
48085         this_ptr_conv.inner = untag_ptr(this_ptr);
48086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48088         this_ptr_conv.is_owned = false;
48089         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48090         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
48091         return ret_arr;
48092 }
48093
48094 void  CS_LDK_ChannelPublicKeys_set_revocation_basepoint(int64_t this_ptr, int8_tArray val) {
48095         LDKChannelPublicKeys this_ptr_conv;
48096         this_ptr_conv.inner = untag_ptr(this_ptr);
48097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48099         this_ptr_conv.is_owned = false;
48100         LDKPublicKey val_ref;
48101         CHECK(val->arr_len == 33);
48102         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48103         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
48104 }
48105
48106 int8_tArray  CS_LDK_ChannelPublicKeys_get_payment_point(int64_t this_ptr) {
48107         LDKChannelPublicKeys this_ptr_conv;
48108         this_ptr_conv.inner = untag_ptr(this_ptr);
48109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48111         this_ptr_conv.is_owned = false;
48112         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48113         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
48114         return ret_arr;
48115 }
48116
48117 void  CS_LDK_ChannelPublicKeys_set_payment_point(int64_t this_ptr, int8_tArray val) {
48118         LDKChannelPublicKeys this_ptr_conv;
48119         this_ptr_conv.inner = untag_ptr(this_ptr);
48120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48122         this_ptr_conv.is_owned = false;
48123         LDKPublicKey val_ref;
48124         CHECK(val->arr_len == 33);
48125         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48126         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
48127 }
48128
48129 int8_tArray  CS_LDK_ChannelPublicKeys_get_delayed_payment_basepoint(int64_t this_ptr) {
48130         LDKChannelPublicKeys this_ptr_conv;
48131         this_ptr_conv.inner = untag_ptr(this_ptr);
48132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48134         this_ptr_conv.is_owned = false;
48135         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48136         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
48137         return ret_arr;
48138 }
48139
48140 void  CS_LDK_ChannelPublicKeys_set_delayed_payment_basepoint(int64_t this_ptr, int8_tArray val) {
48141         LDKChannelPublicKeys this_ptr_conv;
48142         this_ptr_conv.inner = untag_ptr(this_ptr);
48143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48145         this_ptr_conv.is_owned = false;
48146         LDKPublicKey val_ref;
48147         CHECK(val->arr_len == 33);
48148         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48149         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
48150 }
48151
48152 int8_tArray  CS_LDK_ChannelPublicKeys_get_htlc_basepoint(int64_t this_ptr) {
48153         LDKChannelPublicKeys this_ptr_conv;
48154         this_ptr_conv.inner = untag_ptr(this_ptr);
48155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48157         this_ptr_conv.is_owned = false;
48158         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
48159         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
48160         return ret_arr;
48161 }
48162
48163 void  CS_LDK_ChannelPublicKeys_set_htlc_basepoint(int64_t this_ptr, int8_tArray val) {
48164         LDKChannelPublicKeys this_ptr_conv;
48165         this_ptr_conv.inner = untag_ptr(this_ptr);
48166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48168         this_ptr_conv.is_owned = false;
48169         LDKPublicKey val_ref;
48170         CHECK(val->arr_len == 33);
48171         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
48172         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
48173 }
48174
48175 int64_t  CS_LDK_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) {
48176         LDKPublicKey funding_pubkey_arg_ref;
48177         CHECK(funding_pubkey_arg->arr_len == 33);
48178         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
48179         LDKPublicKey revocation_basepoint_arg_ref;
48180         CHECK(revocation_basepoint_arg->arr_len == 33);
48181         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
48182         LDKPublicKey payment_point_arg_ref;
48183         CHECK(payment_point_arg->arr_len == 33);
48184         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
48185         LDKPublicKey delayed_payment_basepoint_arg_ref;
48186         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
48187         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
48188         LDKPublicKey htlc_basepoint_arg_ref;
48189         CHECK(htlc_basepoint_arg->arr_len == 33);
48190         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
48191         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);
48192         int64_t ret_ref = 0;
48193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48195         return ret_ref;
48196 }
48197
48198 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
48199         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
48200         int64_t ret_ref = 0;
48201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48203         return ret_ref;
48204 }
48205 int64_t  CS_LDK_ChannelPublicKeys_clone_ptr(int64_t arg) {
48206         LDKChannelPublicKeys arg_conv;
48207         arg_conv.inner = untag_ptr(arg);
48208         arg_conv.is_owned = ptr_is_owned(arg);
48209         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48210         arg_conv.is_owned = false;
48211         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
48212         return ret_conv;
48213 }
48214
48215 int64_t  CS_LDK_ChannelPublicKeys_clone(int64_t orig) {
48216         LDKChannelPublicKeys orig_conv;
48217         orig_conv.inner = untag_ptr(orig);
48218         orig_conv.is_owned = ptr_is_owned(orig);
48219         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48220         orig_conv.is_owned = false;
48221         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
48222         int64_t ret_ref = 0;
48223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48225         return ret_ref;
48226 }
48227
48228 int64_t  CS_LDK_ChannelPublicKeys_hash(int64_t o) {
48229         LDKChannelPublicKeys o_conv;
48230         o_conv.inner = untag_ptr(o);
48231         o_conv.is_owned = ptr_is_owned(o);
48232         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48233         o_conv.is_owned = false;
48234         int64_t ret_conv = ChannelPublicKeys_hash(&o_conv);
48235         return ret_conv;
48236 }
48237
48238 jboolean  CS_LDK_ChannelPublicKeys_eq(int64_t a, int64_t b) {
48239         LDKChannelPublicKeys a_conv;
48240         a_conv.inner = untag_ptr(a);
48241         a_conv.is_owned = ptr_is_owned(a);
48242         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48243         a_conv.is_owned = false;
48244         LDKChannelPublicKeys b_conv;
48245         b_conv.inner = untag_ptr(b);
48246         b_conv.is_owned = ptr_is_owned(b);
48247         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48248         b_conv.is_owned = false;
48249         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
48250         return ret_conv;
48251 }
48252
48253 int8_tArray  CS_LDK_ChannelPublicKeys_write(int64_t obj) {
48254         LDKChannelPublicKeys obj_conv;
48255         obj_conv.inner = untag_ptr(obj);
48256         obj_conv.is_owned = ptr_is_owned(obj);
48257         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48258         obj_conv.is_owned = false;
48259         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
48260         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48261         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48262         CVec_u8Z_free(ret_var);
48263         return ret_arr;
48264 }
48265
48266 int64_t  CS_LDK_ChannelPublicKeys_read(int8_tArray ser) {
48267         LDKu8slice ser_ref;
48268         ser_ref.datalen = ser->arr_len;
48269         ser_ref.data = ser->elems;
48270         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
48271         *ret_conv = ChannelPublicKeys_read(ser_ref);
48272         FREE(ser);
48273         return tag_ptr(ret_conv, true);
48274 }
48275
48276 int64_t  CS_LDK_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) {
48277         LDKPublicKey per_commitment_point_ref;
48278         CHECK(per_commitment_point->arr_len == 33);
48279         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
48280         LDKPublicKey broadcaster_delayed_payment_base_ref;
48281         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
48282         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
48283         LDKPublicKey broadcaster_htlc_base_ref;
48284         CHECK(broadcaster_htlc_base->arr_len == 33);
48285         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
48286         LDKPublicKey countersignatory_revocation_base_ref;
48287         CHECK(countersignatory_revocation_base->arr_len == 33);
48288         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
48289         LDKPublicKey countersignatory_htlc_base_ref;
48290         CHECK(countersignatory_htlc_base->arr_len == 33);
48291         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
48292         LDKTxCreationKeys ret_var = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
48293         int64_t ret_ref = 0;
48294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48295         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48296         return ret_ref;
48297 }
48298
48299 int64_t  CS_LDK_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, int64_t broadcaster_keys, int64_t countersignatory_keys) {
48300         LDKPublicKey per_commitment_point_ref;
48301         CHECK(per_commitment_point->arr_len == 33);
48302         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
48303         LDKChannelPublicKeys broadcaster_keys_conv;
48304         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
48305         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
48306         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
48307         broadcaster_keys_conv.is_owned = false;
48308         LDKChannelPublicKeys countersignatory_keys_conv;
48309         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
48310         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
48311         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
48312         countersignatory_keys_conv.is_owned = false;
48313         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
48314         int64_t ret_ref = 0;
48315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48317         return ret_ref;
48318 }
48319
48320 int8_tArray  CS_LDK_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
48321         LDKPublicKey revocation_key_ref;
48322         CHECK(revocation_key->arr_len == 33);
48323         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
48324         LDKPublicKey broadcaster_delayed_payment_key_ref;
48325         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
48326         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
48327         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
48328         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48329         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48330         CVec_u8Z_free(ret_var);
48331         return ret_arr;
48332 }
48333
48334 int8_tArray  CS_LDK_get_counterparty_payment_script(int64_t channel_type_features, int8_tArray payment_key) {
48335         LDKChannelTypeFeatures channel_type_features_conv;
48336         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48337         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48338         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48339         channel_type_features_conv.is_owned = false;
48340         LDKPublicKey payment_key_ref;
48341         CHECK(payment_key->arr_len == 33);
48342         memcpy(payment_key_ref.compressed_form, payment_key->elems, 33); FREE(payment_key);
48343         LDKCVec_u8Z ret_var = get_counterparty_payment_script(&channel_type_features_conv, payment_key_ref);
48344         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48345         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48346         CVec_u8Z_free(ret_var);
48347         return ret_arr;
48348 }
48349
48350 void  CS_LDK_HTLCOutputInCommitment_free(int64_t this_obj) {
48351         LDKHTLCOutputInCommitment this_obj_conv;
48352         this_obj_conv.inner = untag_ptr(this_obj);
48353         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48355         HTLCOutputInCommitment_free(this_obj_conv);
48356 }
48357
48358 jboolean  CS_LDK_HTLCOutputInCommitment_get_offered(int64_t this_ptr) {
48359         LDKHTLCOutputInCommitment this_ptr_conv;
48360         this_ptr_conv.inner = untag_ptr(this_ptr);
48361         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48363         this_ptr_conv.is_owned = false;
48364         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
48365         return ret_conv;
48366 }
48367
48368 void  CS_LDK_HTLCOutputInCommitment_set_offered(int64_t this_ptr, jboolean val) {
48369         LDKHTLCOutputInCommitment this_ptr_conv;
48370         this_ptr_conv.inner = untag_ptr(this_ptr);
48371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48373         this_ptr_conv.is_owned = false;
48374         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
48375 }
48376
48377 int64_t  CS_LDK_HTLCOutputInCommitment_get_amount_msat(int64_t this_ptr) {
48378         LDKHTLCOutputInCommitment this_ptr_conv;
48379         this_ptr_conv.inner = untag_ptr(this_ptr);
48380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48382         this_ptr_conv.is_owned = false;
48383         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
48384         return ret_conv;
48385 }
48386
48387 void  CS_LDK_HTLCOutputInCommitment_set_amount_msat(int64_t this_ptr, int64_t val) {
48388         LDKHTLCOutputInCommitment this_ptr_conv;
48389         this_ptr_conv.inner = untag_ptr(this_ptr);
48390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48392         this_ptr_conv.is_owned = false;
48393         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
48394 }
48395
48396 int32_t  CS_LDK_HTLCOutputInCommitment_get_cltv_expiry(int64_t this_ptr) {
48397         LDKHTLCOutputInCommitment this_ptr_conv;
48398         this_ptr_conv.inner = untag_ptr(this_ptr);
48399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48401         this_ptr_conv.is_owned = false;
48402         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
48403         return ret_conv;
48404 }
48405
48406 void  CS_LDK_HTLCOutputInCommitment_set_cltv_expiry(int64_t this_ptr, int32_t val) {
48407         LDKHTLCOutputInCommitment this_ptr_conv;
48408         this_ptr_conv.inner = untag_ptr(this_ptr);
48409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48411         this_ptr_conv.is_owned = false;
48412         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
48413 }
48414
48415 int8_tArray  CS_LDK_HTLCOutputInCommitment_get_payment_hash(int64_t this_ptr) {
48416         LDKHTLCOutputInCommitment this_ptr_conv;
48417         this_ptr_conv.inner = untag_ptr(this_ptr);
48418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48420         this_ptr_conv.is_owned = false;
48421         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
48422         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
48423         return ret_arr;
48424 }
48425
48426 void  CS_LDK_HTLCOutputInCommitment_set_payment_hash(int64_t this_ptr, int8_tArray val) {
48427         LDKHTLCOutputInCommitment this_ptr_conv;
48428         this_ptr_conv.inner = untag_ptr(this_ptr);
48429         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48431         this_ptr_conv.is_owned = false;
48432         LDKThirtyTwoBytes val_ref;
48433         CHECK(val->arr_len == 32);
48434         memcpy(val_ref.data, val->elems, 32); FREE(val);
48435         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
48436 }
48437
48438 int64_t  CS_LDK_HTLCOutputInCommitment_get_transaction_output_index(int64_t this_ptr) {
48439         LDKHTLCOutputInCommitment this_ptr_conv;
48440         this_ptr_conv.inner = untag_ptr(this_ptr);
48441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48443         this_ptr_conv.is_owned = false;
48444         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
48445         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
48446         int64_t ret_ref = tag_ptr(ret_copy, true);
48447         return ret_ref;
48448 }
48449
48450 void  CS_LDK_HTLCOutputInCommitment_set_transaction_output_index(int64_t this_ptr, int64_t val) {
48451         LDKHTLCOutputInCommitment this_ptr_conv;
48452         this_ptr_conv.inner = untag_ptr(this_ptr);
48453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48455         this_ptr_conv.is_owned = false;
48456         void* val_ptr = untag_ptr(val);
48457         CHECK_ACCESS(val_ptr);
48458         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
48459         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
48460         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
48461 }
48462
48463 int64_t  CS_LDK_HTLCOutputInCommitment_new(jboolean offered_arg, int64_t amount_msat_arg, int32_t cltv_expiry_arg, int8_tArray payment_hash_arg, int64_t transaction_output_index_arg) {
48464         LDKThirtyTwoBytes payment_hash_arg_ref;
48465         CHECK(payment_hash_arg->arr_len == 32);
48466         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
48467         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
48468         CHECK_ACCESS(transaction_output_index_arg_ptr);
48469         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
48470         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
48471         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
48472         int64_t ret_ref = 0;
48473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48474         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48475         return ret_ref;
48476 }
48477
48478 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
48479         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
48480         int64_t ret_ref = 0;
48481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48483         return ret_ref;
48484 }
48485 int64_t  CS_LDK_HTLCOutputInCommitment_clone_ptr(int64_t arg) {
48486         LDKHTLCOutputInCommitment arg_conv;
48487         arg_conv.inner = untag_ptr(arg);
48488         arg_conv.is_owned = ptr_is_owned(arg);
48489         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48490         arg_conv.is_owned = false;
48491         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
48492         return ret_conv;
48493 }
48494
48495 int64_t  CS_LDK_HTLCOutputInCommitment_clone(int64_t orig) {
48496         LDKHTLCOutputInCommitment orig_conv;
48497         orig_conv.inner = untag_ptr(orig);
48498         orig_conv.is_owned = ptr_is_owned(orig);
48499         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48500         orig_conv.is_owned = false;
48501         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
48502         int64_t ret_ref = 0;
48503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48505         return ret_ref;
48506 }
48507
48508 jboolean  CS_LDK_HTLCOutputInCommitment_eq(int64_t a, int64_t b) {
48509         LDKHTLCOutputInCommitment a_conv;
48510         a_conv.inner = untag_ptr(a);
48511         a_conv.is_owned = ptr_is_owned(a);
48512         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48513         a_conv.is_owned = false;
48514         LDKHTLCOutputInCommitment b_conv;
48515         b_conv.inner = untag_ptr(b);
48516         b_conv.is_owned = ptr_is_owned(b);
48517         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48518         b_conv.is_owned = false;
48519         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
48520         return ret_conv;
48521 }
48522
48523 int8_tArray  CS_LDK_HTLCOutputInCommitment_write(int64_t obj) {
48524         LDKHTLCOutputInCommitment obj_conv;
48525         obj_conv.inner = untag_ptr(obj);
48526         obj_conv.is_owned = ptr_is_owned(obj);
48527         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48528         obj_conv.is_owned = false;
48529         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
48530         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48531         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48532         CVec_u8Z_free(ret_var);
48533         return ret_arr;
48534 }
48535
48536 int64_t  CS_LDK_HTLCOutputInCommitment_read(int8_tArray ser) {
48537         LDKu8slice ser_ref;
48538         ser_ref.datalen = ser->arr_len;
48539         ser_ref.data = ser->elems;
48540         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
48541         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
48542         FREE(ser);
48543         return tag_ptr(ret_conv, true);
48544 }
48545
48546 int8_tArray  CS_LDK_get_htlc_redeemscript(int64_t htlc, int64_t channel_type_features, int64_t keys) {
48547         LDKHTLCOutputInCommitment htlc_conv;
48548         htlc_conv.inner = untag_ptr(htlc);
48549         htlc_conv.is_owned = ptr_is_owned(htlc);
48550         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
48551         htlc_conv.is_owned = false;
48552         LDKChannelTypeFeatures channel_type_features_conv;
48553         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48554         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48555         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48556         channel_type_features_conv.is_owned = false;
48557         LDKTxCreationKeys keys_conv;
48558         keys_conv.inner = untag_ptr(keys);
48559         keys_conv.is_owned = ptr_is_owned(keys);
48560         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
48561         keys_conv.is_owned = false;
48562         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &channel_type_features_conv, &keys_conv);
48563         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48564         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48565         CVec_u8Z_free(ret_var);
48566         return ret_arr;
48567 }
48568
48569 int8_tArray  CS_LDK_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
48570         LDKPublicKey broadcaster_ref;
48571         CHECK(broadcaster->arr_len == 33);
48572         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
48573         LDKPublicKey countersignatory_ref;
48574         CHECK(countersignatory->arr_len == 33);
48575         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
48576         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
48577         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48578         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48579         CVec_u8Z_free(ret_var);
48580         return ret_arr;
48581 }
48582
48583 int8_tArray  CS_LDK_build_htlc_transaction(int8_tArray commitment_txid, int32_t feerate_per_kw, int16_t contest_delay, int64_t htlc, int64_t channel_type_features, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
48584         uint8_t commitment_txid_arr[32];
48585         CHECK(commitment_txid->arr_len == 32);
48586         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
48587         uint8_t (*commitment_txid_ref)[32] = &commitment_txid_arr;
48588         LDKHTLCOutputInCommitment htlc_conv;
48589         htlc_conv.inner = untag_ptr(htlc);
48590         htlc_conv.is_owned = ptr_is_owned(htlc);
48591         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
48592         htlc_conv.is_owned = false;
48593         LDKChannelTypeFeatures channel_type_features_conv;
48594         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48595         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48596         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48597         channel_type_features_conv.is_owned = false;
48598         LDKPublicKey broadcaster_delayed_payment_key_ref;
48599         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
48600         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
48601         LDKPublicKey revocation_key_ref;
48602         CHECK(revocation_key->arr_len == 33);
48603         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
48604         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, &channel_type_features_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
48605         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48606         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48607         Transaction_free(ret_var);
48608         return ret_arr;
48609 }
48610
48611 int8_tArray  CS_LDK_build_htlc_input_witness(int8_tArray local_sig, int8_tArray remote_sig, int64_t preimage, int8_tArray redeem_script, int64_t channel_type_features) {
48612         LDKECDSASignature local_sig_ref;
48613         CHECK(local_sig->arr_len == 64);
48614         memcpy(local_sig_ref.compact_form, local_sig->elems, 64); FREE(local_sig);
48615         LDKECDSASignature remote_sig_ref;
48616         CHECK(remote_sig->arr_len == 64);
48617         memcpy(remote_sig_ref.compact_form, remote_sig->elems, 64); FREE(remote_sig);
48618         void* preimage_ptr = untag_ptr(preimage);
48619         CHECK_ACCESS(preimage_ptr);
48620         LDKCOption_ThirtyTwoBytesZ preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(preimage_ptr);
48621         preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(preimage));
48622         LDKu8slice redeem_script_ref;
48623         redeem_script_ref.datalen = redeem_script->arr_len;
48624         redeem_script_ref.data = redeem_script->elems;
48625         LDKChannelTypeFeatures channel_type_features_conv;
48626         channel_type_features_conv.inner = untag_ptr(channel_type_features);
48627         channel_type_features_conv.is_owned = ptr_is_owned(channel_type_features);
48628         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_conv);
48629         channel_type_features_conv.is_owned = false;
48630         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_conv, redeem_script_ref, &channel_type_features_conv);
48631         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48632         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48633         Witness_free(ret_var);
48634         FREE(redeem_script);
48635         return ret_arr;
48636 }
48637
48638 int8_tArray  CS_LDK_get_to_countersignatory_with_anchors_redeemscript(int8_tArray payment_point) {
48639         LDKPublicKey payment_point_ref;
48640         CHECK(payment_point->arr_len == 33);
48641         memcpy(payment_point_ref.compressed_form, payment_point->elems, 33); FREE(payment_point);
48642         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
48643         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48644         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48645         CVec_u8Z_free(ret_var);
48646         return ret_arr;
48647 }
48648
48649 int8_tArray  CS_LDK_get_anchor_redeemscript(int8_tArray funding_pubkey) {
48650         LDKPublicKey funding_pubkey_ref;
48651         CHECK(funding_pubkey->arr_len == 33);
48652         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
48653         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
48654         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48655         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48656         CVec_u8Z_free(ret_var);
48657         return ret_arr;
48658 }
48659
48660 int8_tArray  CS_LDK_build_anchor_input_witness(int8_tArray funding_key, int8_tArray funding_sig) {
48661         LDKPublicKey funding_key_ref;
48662         CHECK(funding_key->arr_len == 33);
48663         memcpy(funding_key_ref.compressed_form, funding_key->elems, 33); FREE(funding_key);
48664         LDKECDSASignature funding_sig_ref;
48665         CHECK(funding_sig->arr_len == 64);
48666         memcpy(funding_sig_ref.compact_form, funding_sig->elems, 64); FREE(funding_sig);
48667         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
48668         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
48669         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
48670         Witness_free(ret_var);
48671         return ret_arr;
48672 }
48673
48674 void  CS_LDK_ChannelTransactionParameters_free(int64_t this_obj) {
48675         LDKChannelTransactionParameters this_obj_conv;
48676         this_obj_conv.inner = untag_ptr(this_obj);
48677         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48679         ChannelTransactionParameters_free(this_obj_conv);
48680 }
48681
48682 int64_t  CS_LDK_ChannelTransactionParameters_get_holder_pubkeys(int64_t this_ptr) {
48683         LDKChannelTransactionParameters this_ptr_conv;
48684         this_ptr_conv.inner = untag_ptr(this_ptr);
48685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48687         this_ptr_conv.is_owned = false;
48688         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
48689         int64_t ret_ref = 0;
48690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48692         return ret_ref;
48693 }
48694
48695 void  CS_LDK_ChannelTransactionParameters_set_holder_pubkeys(int64_t this_ptr, int64_t val) {
48696         LDKChannelTransactionParameters this_ptr_conv;
48697         this_ptr_conv.inner = untag_ptr(this_ptr);
48698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48700         this_ptr_conv.is_owned = false;
48701         LDKChannelPublicKeys val_conv;
48702         val_conv.inner = untag_ptr(val);
48703         val_conv.is_owned = ptr_is_owned(val);
48704         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48705         val_conv = ChannelPublicKeys_clone(&val_conv);
48706         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
48707 }
48708
48709 int16_t  CS_LDK_ChannelTransactionParameters_get_holder_selected_contest_delay(int64_t this_ptr) {
48710         LDKChannelTransactionParameters this_ptr_conv;
48711         this_ptr_conv.inner = untag_ptr(this_ptr);
48712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48714         this_ptr_conv.is_owned = false;
48715         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
48716         return ret_conv;
48717 }
48718
48719 void  CS_LDK_ChannelTransactionParameters_set_holder_selected_contest_delay(int64_t this_ptr, int16_t val) {
48720         LDKChannelTransactionParameters this_ptr_conv;
48721         this_ptr_conv.inner = untag_ptr(this_ptr);
48722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48724         this_ptr_conv.is_owned = false;
48725         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
48726 }
48727
48728 jboolean  CS_LDK_ChannelTransactionParameters_get_is_outbound_from_holder(int64_t this_ptr) {
48729         LDKChannelTransactionParameters this_ptr_conv;
48730         this_ptr_conv.inner = untag_ptr(this_ptr);
48731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48733         this_ptr_conv.is_owned = false;
48734         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
48735         return ret_conv;
48736 }
48737
48738 void  CS_LDK_ChannelTransactionParameters_set_is_outbound_from_holder(int64_t this_ptr, jboolean val) {
48739         LDKChannelTransactionParameters this_ptr_conv;
48740         this_ptr_conv.inner = untag_ptr(this_ptr);
48741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48743         this_ptr_conv.is_owned = false;
48744         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
48745 }
48746
48747 int64_t  CS_LDK_ChannelTransactionParameters_get_counterparty_parameters(int64_t this_ptr) {
48748         LDKChannelTransactionParameters this_ptr_conv;
48749         this_ptr_conv.inner = untag_ptr(this_ptr);
48750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48752         this_ptr_conv.is_owned = false;
48753         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
48754         int64_t ret_ref = 0;
48755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48757         return ret_ref;
48758 }
48759
48760 void  CS_LDK_ChannelTransactionParameters_set_counterparty_parameters(int64_t this_ptr, int64_t val) {
48761         LDKChannelTransactionParameters this_ptr_conv;
48762         this_ptr_conv.inner = untag_ptr(this_ptr);
48763         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48765         this_ptr_conv.is_owned = false;
48766         LDKCounterpartyChannelTransactionParameters val_conv;
48767         val_conv.inner = untag_ptr(val);
48768         val_conv.is_owned = ptr_is_owned(val);
48769         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48770         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
48771         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
48772 }
48773
48774 int64_t  CS_LDK_ChannelTransactionParameters_get_funding_outpoint(int64_t this_ptr) {
48775         LDKChannelTransactionParameters this_ptr_conv;
48776         this_ptr_conv.inner = untag_ptr(this_ptr);
48777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48779         this_ptr_conv.is_owned = false;
48780         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
48781         int64_t ret_ref = 0;
48782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48783         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48784         return ret_ref;
48785 }
48786
48787 void  CS_LDK_ChannelTransactionParameters_set_funding_outpoint(int64_t this_ptr, int64_t val) {
48788         LDKChannelTransactionParameters this_ptr_conv;
48789         this_ptr_conv.inner = untag_ptr(this_ptr);
48790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48792         this_ptr_conv.is_owned = false;
48793         LDKOutPoint val_conv;
48794         val_conv.inner = untag_ptr(val);
48795         val_conv.is_owned = ptr_is_owned(val);
48796         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48797         val_conv = OutPoint_clone(&val_conv);
48798         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
48799 }
48800
48801 int64_t  CS_LDK_ChannelTransactionParameters_get_channel_type_features(int64_t this_ptr) {
48802         LDKChannelTransactionParameters this_ptr_conv;
48803         this_ptr_conv.inner = untag_ptr(this_ptr);
48804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48806         this_ptr_conv.is_owned = false;
48807         LDKChannelTypeFeatures ret_var = ChannelTransactionParameters_get_channel_type_features(&this_ptr_conv);
48808         int64_t ret_ref = 0;
48809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48811         return ret_ref;
48812 }
48813
48814 void  CS_LDK_ChannelTransactionParameters_set_channel_type_features(int64_t this_ptr, int64_t val) {
48815         LDKChannelTransactionParameters this_ptr_conv;
48816         this_ptr_conv.inner = untag_ptr(this_ptr);
48817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48819         this_ptr_conv.is_owned = false;
48820         LDKChannelTypeFeatures val_conv;
48821         val_conv.inner = untag_ptr(val);
48822         val_conv.is_owned = ptr_is_owned(val);
48823         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48824         val_conv = ChannelTypeFeatures_clone(&val_conv);
48825         ChannelTransactionParameters_set_channel_type_features(&this_ptr_conv, val_conv);
48826 }
48827
48828 int64_t  CS_LDK_ChannelTransactionParameters_new(int64_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, int64_t counterparty_parameters_arg, int64_t funding_outpoint_arg, int64_t channel_type_features_arg) {
48829         LDKChannelPublicKeys holder_pubkeys_arg_conv;
48830         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
48831         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
48832         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
48833         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
48834         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
48835         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
48836         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
48837         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
48838         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
48839         LDKOutPoint funding_outpoint_arg_conv;
48840         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
48841         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
48842         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
48843         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
48844         LDKChannelTypeFeatures channel_type_features_arg_conv;
48845         channel_type_features_arg_conv.inner = untag_ptr(channel_type_features_arg);
48846         channel_type_features_arg_conv.is_owned = ptr_is_owned(channel_type_features_arg);
48847         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_features_arg_conv);
48848         channel_type_features_arg_conv = ChannelTypeFeatures_clone(&channel_type_features_arg_conv);
48849         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, channel_type_features_arg_conv);
48850         int64_t ret_ref = 0;
48851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48852         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48853         return ret_ref;
48854 }
48855
48856 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
48857         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
48858         int64_t ret_ref = 0;
48859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48860         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48861         return ret_ref;
48862 }
48863 int64_t  CS_LDK_ChannelTransactionParameters_clone_ptr(int64_t arg) {
48864         LDKChannelTransactionParameters arg_conv;
48865         arg_conv.inner = untag_ptr(arg);
48866         arg_conv.is_owned = ptr_is_owned(arg);
48867         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48868         arg_conv.is_owned = false;
48869         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
48870         return ret_conv;
48871 }
48872
48873 int64_t  CS_LDK_ChannelTransactionParameters_clone(int64_t orig) {
48874         LDKChannelTransactionParameters orig_conv;
48875         orig_conv.inner = untag_ptr(orig);
48876         orig_conv.is_owned = ptr_is_owned(orig);
48877         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48878         orig_conv.is_owned = false;
48879         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
48880         int64_t ret_ref = 0;
48881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48882         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48883         return ret_ref;
48884 }
48885
48886 int64_t  CS_LDK_ChannelTransactionParameters_hash(int64_t o) {
48887         LDKChannelTransactionParameters o_conv;
48888         o_conv.inner = untag_ptr(o);
48889         o_conv.is_owned = ptr_is_owned(o);
48890         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48891         o_conv.is_owned = false;
48892         int64_t ret_conv = ChannelTransactionParameters_hash(&o_conv);
48893         return ret_conv;
48894 }
48895
48896 jboolean  CS_LDK_ChannelTransactionParameters_eq(int64_t a, int64_t b) {
48897         LDKChannelTransactionParameters a_conv;
48898         a_conv.inner = untag_ptr(a);
48899         a_conv.is_owned = ptr_is_owned(a);
48900         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48901         a_conv.is_owned = false;
48902         LDKChannelTransactionParameters b_conv;
48903         b_conv.inner = untag_ptr(b);
48904         b_conv.is_owned = ptr_is_owned(b);
48905         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48906         b_conv.is_owned = false;
48907         jboolean ret_conv = ChannelTransactionParameters_eq(&a_conv, &b_conv);
48908         return ret_conv;
48909 }
48910
48911 void  CS_LDK_CounterpartyChannelTransactionParameters_free(int64_t this_obj) {
48912         LDKCounterpartyChannelTransactionParameters this_obj_conv;
48913         this_obj_conv.inner = untag_ptr(this_obj);
48914         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48916         CounterpartyChannelTransactionParameters_free(this_obj_conv);
48917 }
48918
48919 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_get_pubkeys(int64_t this_ptr) {
48920         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48921         this_ptr_conv.inner = untag_ptr(this_ptr);
48922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48924         this_ptr_conv.is_owned = false;
48925         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
48926         int64_t ret_ref = 0;
48927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48929         return ret_ref;
48930 }
48931
48932 void  CS_LDK_CounterpartyChannelTransactionParameters_set_pubkeys(int64_t this_ptr, int64_t val) {
48933         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48934         this_ptr_conv.inner = untag_ptr(this_ptr);
48935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48937         this_ptr_conv.is_owned = false;
48938         LDKChannelPublicKeys val_conv;
48939         val_conv.inner = untag_ptr(val);
48940         val_conv.is_owned = ptr_is_owned(val);
48941         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48942         val_conv = ChannelPublicKeys_clone(&val_conv);
48943         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
48944 }
48945
48946 int16_t  CS_LDK_CounterpartyChannelTransactionParameters_get_selected_contest_delay(int64_t this_ptr) {
48947         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48948         this_ptr_conv.inner = untag_ptr(this_ptr);
48949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48951         this_ptr_conv.is_owned = false;
48952         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
48953         return ret_conv;
48954 }
48955
48956 void  CS_LDK_CounterpartyChannelTransactionParameters_set_selected_contest_delay(int64_t this_ptr, int16_t val) {
48957         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
48958         this_ptr_conv.inner = untag_ptr(this_ptr);
48959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48961         this_ptr_conv.is_owned = false;
48962         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
48963 }
48964
48965 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_new(int64_t pubkeys_arg, int16_t selected_contest_delay_arg) {
48966         LDKChannelPublicKeys pubkeys_arg_conv;
48967         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
48968         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
48969         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
48970         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
48971         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
48972         int64_t ret_ref = 0;
48973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48975         return ret_ref;
48976 }
48977
48978 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
48979         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
48980         int64_t ret_ref = 0;
48981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48983         return ret_ref;
48984 }
48985 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_clone_ptr(int64_t arg) {
48986         LDKCounterpartyChannelTransactionParameters arg_conv;
48987         arg_conv.inner = untag_ptr(arg);
48988         arg_conv.is_owned = ptr_is_owned(arg);
48989         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48990         arg_conv.is_owned = false;
48991         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
48992         return ret_conv;
48993 }
48994
48995 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_clone(int64_t orig) {
48996         LDKCounterpartyChannelTransactionParameters orig_conv;
48997         orig_conv.inner = untag_ptr(orig);
48998         orig_conv.is_owned = ptr_is_owned(orig);
48999         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49000         orig_conv.is_owned = false;
49001         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
49002         int64_t ret_ref = 0;
49003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49005         return ret_ref;
49006 }
49007
49008 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_hash(int64_t o) {
49009         LDKCounterpartyChannelTransactionParameters o_conv;
49010         o_conv.inner = untag_ptr(o);
49011         o_conv.is_owned = ptr_is_owned(o);
49012         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49013         o_conv.is_owned = false;
49014         int64_t ret_conv = CounterpartyChannelTransactionParameters_hash(&o_conv);
49015         return ret_conv;
49016 }
49017
49018 jboolean  CS_LDK_CounterpartyChannelTransactionParameters_eq(int64_t a, int64_t b) {
49019         LDKCounterpartyChannelTransactionParameters a_conv;
49020         a_conv.inner = untag_ptr(a);
49021         a_conv.is_owned = ptr_is_owned(a);
49022         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49023         a_conv.is_owned = false;
49024         LDKCounterpartyChannelTransactionParameters b_conv;
49025         b_conv.inner = untag_ptr(b);
49026         b_conv.is_owned = ptr_is_owned(b);
49027         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49028         b_conv.is_owned = false;
49029         jboolean ret_conv = CounterpartyChannelTransactionParameters_eq(&a_conv, &b_conv);
49030         return ret_conv;
49031 }
49032
49033 jboolean  CS_LDK_ChannelTransactionParameters_is_populated(int64_t this_arg) {
49034         LDKChannelTransactionParameters this_arg_conv;
49035         this_arg_conv.inner = untag_ptr(this_arg);
49036         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49038         this_arg_conv.is_owned = false;
49039         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
49040         return ret_conv;
49041 }
49042
49043 int64_t  CS_LDK_ChannelTransactionParameters_as_holder_broadcastable(int64_t this_arg) {
49044         LDKChannelTransactionParameters this_arg_conv;
49045         this_arg_conv.inner = untag_ptr(this_arg);
49046         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49048         this_arg_conv.is_owned = false;
49049         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
49050         int64_t ret_ref = 0;
49051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49053         return ret_ref;
49054 }
49055
49056 int64_t  CS_LDK_ChannelTransactionParameters_as_counterparty_broadcastable(int64_t this_arg) {
49057         LDKChannelTransactionParameters this_arg_conv;
49058         this_arg_conv.inner = untag_ptr(this_arg);
49059         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49061         this_arg_conv.is_owned = false;
49062         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
49063         int64_t ret_ref = 0;
49064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49066         return ret_ref;
49067 }
49068
49069 int8_tArray  CS_LDK_CounterpartyChannelTransactionParameters_write(int64_t obj) {
49070         LDKCounterpartyChannelTransactionParameters obj_conv;
49071         obj_conv.inner = untag_ptr(obj);
49072         obj_conv.is_owned = ptr_is_owned(obj);
49073         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49074         obj_conv.is_owned = false;
49075         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
49076         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49077         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49078         CVec_u8Z_free(ret_var);
49079         return ret_arr;
49080 }
49081
49082 int64_t  CS_LDK_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
49083         LDKu8slice ser_ref;
49084         ser_ref.datalen = ser->arr_len;
49085         ser_ref.data = ser->elems;
49086         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
49087         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
49088         FREE(ser);
49089         return tag_ptr(ret_conv, true);
49090 }
49091
49092 int8_tArray  CS_LDK_ChannelTransactionParameters_write(int64_t obj) {
49093         LDKChannelTransactionParameters obj_conv;
49094         obj_conv.inner = untag_ptr(obj);
49095         obj_conv.is_owned = ptr_is_owned(obj);
49096         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49097         obj_conv.is_owned = false;
49098         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
49099         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49100         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49101         CVec_u8Z_free(ret_var);
49102         return ret_arr;
49103 }
49104
49105 int64_t  CS_LDK_ChannelTransactionParameters_read(int8_tArray ser) {
49106         LDKu8slice ser_ref;
49107         ser_ref.datalen = ser->arr_len;
49108         ser_ref.data = ser->elems;
49109         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
49110         *ret_conv = ChannelTransactionParameters_read(ser_ref);
49111         FREE(ser);
49112         return tag_ptr(ret_conv, true);
49113 }
49114
49115 void  CS_LDK_DirectedChannelTransactionParameters_free(int64_t this_obj) {
49116         LDKDirectedChannelTransactionParameters this_obj_conv;
49117         this_obj_conv.inner = untag_ptr(this_obj);
49118         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49120         DirectedChannelTransactionParameters_free(this_obj_conv);
49121 }
49122
49123 int64_t  CS_LDK_DirectedChannelTransactionParameters_broadcaster_pubkeys(int64_t this_arg) {
49124         LDKDirectedChannelTransactionParameters this_arg_conv;
49125         this_arg_conv.inner = untag_ptr(this_arg);
49126         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49128         this_arg_conv.is_owned = false;
49129         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
49130         int64_t ret_ref = 0;
49131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49132         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49133         return ret_ref;
49134 }
49135
49136 int64_t  CS_LDK_DirectedChannelTransactionParameters_countersignatory_pubkeys(int64_t this_arg) {
49137         LDKDirectedChannelTransactionParameters this_arg_conv;
49138         this_arg_conv.inner = untag_ptr(this_arg);
49139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49141         this_arg_conv.is_owned = false;
49142         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
49143         int64_t ret_ref = 0;
49144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49145         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49146         return ret_ref;
49147 }
49148
49149 int16_t  CS_LDK_DirectedChannelTransactionParameters_contest_delay(int64_t this_arg) {
49150         LDKDirectedChannelTransactionParameters this_arg_conv;
49151         this_arg_conv.inner = untag_ptr(this_arg);
49152         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49154         this_arg_conv.is_owned = false;
49155         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
49156         return ret_conv;
49157 }
49158
49159 jboolean  CS_LDK_DirectedChannelTransactionParameters_is_outbound(int64_t this_arg) {
49160         LDKDirectedChannelTransactionParameters this_arg_conv;
49161         this_arg_conv.inner = untag_ptr(this_arg);
49162         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49164         this_arg_conv.is_owned = false;
49165         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
49166         return ret_conv;
49167 }
49168
49169 int64_t  CS_LDK_DirectedChannelTransactionParameters_funding_outpoint(int64_t this_arg) {
49170         LDKDirectedChannelTransactionParameters this_arg_conv;
49171         this_arg_conv.inner = untag_ptr(this_arg);
49172         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49174         this_arg_conv.is_owned = false;
49175         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
49176         int64_t ret_ref = 0;
49177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49179         return ret_ref;
49180 }
49181
49182 int64_t  CS_LDK_DirectedChannelTransactionParameters_channel_type_features(int64_t this_arg) {
49183         LDKDirectedChannelTransactionParameters this_arg_conv;
49184         this_arg_conv.inner = untag_ptr(this_arg);
49185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49187         this_arg_conv.is_owned = false;
49188         LDKChannelTypeFeatures ret_var = DirectedChannelTransactionParameters_channel_type_features(&this_arg_conv);
49189         int64_t ret_ref = 0;
49190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49192         return ret_ref;
49193 }
49194
49195 void  CS_LDK_HolderCommitmentTransaction_free(int64_t this_obj) {
49196         LDKHolderCommitmentTransaction this_obj_conv;
49197         this_obj_conv.inner = untag_ptr(this_obj);
49198         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49200         HolderCommitmentTransaction_free(this_obj_conv);
49201 }
49202
49203 int8_tArray  CS_LDK_HolderCommitmentTransaction_get_counterparty_sig(int64_t this_ptr) {
49204         LDKHolderCommitmentTransaction this_ptr_conv;
49205         this_ptr_conv.inner = untag_ptr(this_ptr);
49206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49208         this_ptr_conv.is_owned = false;
49209         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49210         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
49211         return ret_arr;
49212 }
49213
49214 void  CS_LDK_HolderCommitmentTransaction_set_counterparty_sig(int64_t this_ptr, int8_tArray val) {
49215         LDKHolderCommitmentTransaction this_ptr_conv;
49216         this_ptr_conv.inner = untag_ptr(this_ptr);
49217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49219         this_ptr_conv.is_owned = false;
49220         LDKECDSASignature val_ref;
49221         CHECK(val->arr_len == 64);
49222         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
49223         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
49224 }
49225
49226 ptrArray  CS_LDK_HolderCommitmentTransaction_get_counterparty_htlc_sigs(int64_t this_ptr) {
49227         LDKHolderCommitmentTransaction this_ptr_conv;
49228         this_ptr_conv.inner = untag_ptr(this_ptr);
49229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49231         this_ptr_conv.is_owned = false;
49232         LDKCVec_ECDSASignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
49233         ptrArray ret_arr = NULL;
49234         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
49235         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
49236         for (size_t i = 0; i < ret_var.datalen; i++) {
49237                 int8_tArray ret_conv_8_arr = init_int8_tArray(64, __LINE__);
49238                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compact_form, 64);
49239                 ret_arr_ptr[i] = ret_conv_8_arr;
49240         }
49241         
49242         FREE(ret_var.data);
49243         return ret_arr;
49244 }
49245
49246 void  CS_LDK_HolderCommitmentTransaction_set_counterparty_htlc_sigs(int64_t this_ptr, ptrArray val) {
49247         LDKHolderCommitmentTransaction this_ptr_conv;
49248         this_ptr_conv.inner = untag_ptr(this_ptr);
49249         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49251         this_ptr_conv.is_owned = false;
49252         LDKCVec_ECDSASignatureZ val_constr;
49253         val_constr.datalen = val->arr_len;
49254         if (val_constr.datalen > 0)
49255                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
49256         else
49257                 val_constr.data = NULL;
49258         int8_tArray* val_vals = (void*) val->elems;
49259         for (size_t i = 0; i < val_constr.datalen; i++) {
49260                 int8_tArray val_conv_8 = val_vals[i];
49261                 LDKECDSASignature val_conv_8_ref;
49262                 CHECK(val_conv_8->arr_len == 64);
49263                 memcpy(val_conv_8_ref.compact_form, val_conv_8->elems, 64); FREE(val_conv_8);
49264                 val_constr.data[i] = val_conv_8_ref;
49265         }
49266         FREE(val);
49267         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
49268 }
49269
49270 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
49271         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
49272         int64_t ret_ref = 0;
49273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49275         return ret_ref;
49276 }
49277 int64_t  CS_LDK_HolderCommitmentTransaction_clone_ptr(int64_t arg) {
49278         LDKHolderCommitmentTransaction arg_conv;
49279         arg_conv.inner = untag_ptr(arg);
49280         arg_conv.is_owned = ptr_is_owned(arg);
49281         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49282         arg_conv.is_owned = false;
49283         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
49284         return ret_conv;
49285 }
49286
49287 int64_t  CS_LDK_HolderCommitmentTransaction_clone(int64_t orig) {
49288         LDKHolderCommitmentTransaction orig_conv;
49289         orig_conv.inner = untag_ptr(orig);
49290         orig_conv.is_owned = ptr_is_owned(orig);
49291         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49292         orig_conv.is_owned = false;
49293         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
49294         int64_t ret_ref = 0;
49295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49297         return ret_ref;
49298 }
49299
49300 int8_tArray  CS_LDK_HolderCommitmentTransaction_write(int64_t obj) {
49301         LDKHolderCommitmentTransaction obj_conv;
49302         obj_conv.inner = untag_ptr(obj);
49303         obj_conv.is_owned = ptr_is_owned(obj);
49304         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49305         obj_conv.is_owned = false;
49306         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
49307         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49308         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49309         CVec_u8Z_free(ret_var);
49310         return ret_arr;
49311 }
49312
49313 int64_t  CS_LDK_HolderCommitmentTransaction_read(int8_tArray ser) {
49314         LDKu8slice ser_ref;
49315         ser_ref.datalen = ser->arr_len;
49316         ser_ref.data = ser->elems;
49317         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
49318         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
49319         FREE(ser);
49320         return tag_ptr(ret_conv, true);
49321 }
49322
49323 int64_t  CS_LDK_HolderCommitmentTransaction_new(int64_t commitment_tx, int8_tArray counterparty_sig, ptrArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
49324         LDKCommitmentTransaction commitment_tx_conv;
49325         commitment_tx_conv.inner = untag_ptr(commitment_tx);
49326         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
49327         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
49328         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
49329         LDKECDSASignature counterparty_sig_ref;
49330         CHECK(counterparty_sig->arr_len == 64);
49331         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
49332         LDKCVec_ECDSASignatureZ counterparty_htlc_sigs_constr;
49333         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
49334         if (counterparty_htlc_sigs_constr.datalen > 0)
49335                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKECDSASignature), "LDKCVec_ECDSASignatureZ Elements");
49336         else
49337                 counterparty_htlc_sigs_constr.data = NULL;
49338         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems;
49339         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
49340                 int8_tArray counterparty_htlc_sigs_conv_8 = counterparty_htlc_sigs_vals[i];
49341                 LDKECDSASignature counterparty_htlc_sigs_conv_8_ref;
49342                 CHECK(counterparty_htlc_sigs_conv_8->arr_len == 64);
49343                 memcpy(counterparty_htlc_sigs_conv_8_ref.compact_form, counterparty_htlc_sigs_conv_8->elems, 64); FREE(counterparty_htlc_sigs_conv_8);
49344                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
49345         }
49346         FREE(counterparty_htlc_sigs);
49347         LDKPublicKey holder_funding_key_ref;
49348         CHECK(holder_funding_key->arr_len == 33);
49349         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
49350         LDKPublicKey counterparty_funding_key_ref;
49351         CHECK(counterparty_funding_key->arr_len == 33);
49352         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
49353         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
49354         int64_t ret_ref = 0;
49355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49356         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49357         return ret_ref;
49358 }
49359
49360 void  CS_LDK_BuiltCommitmentTransaction_free(int64_t this_obj) {
49361         LDKBuiltCommitmentTransaction this_obj_conv;
49362         this_obj_conv.inner = untag_ptr(this_obj);
49363         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49365         BuiltCommitmentTransaction_free(this_obj_conv);
49366 }
49367
49368 int8_tArray  CS_LDK_BuiltCommitmentTransaction_get_transaction(int64_t this_ptr) {
49369         LDKBuiltCommitmentTransaction this_ptr_conv;
49370         this_ptr_conv.inner = untag_ptr(this_ptr);
49371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49373         this_ptr_conv.is_owned = false;
49374         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
49375         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49376         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49377         Transaction_free(ret_var);
49378         return ret_arr;
49379 }
49380
49381 void  CS_LDK_BuiltCommitmentTransaction_set_transaction(int64_t this_ptr, int8_tArray val) {
49382         LDKBuiltCommitmentTransaction this_ptr_conv;
49383         this_ptr_conv.inner = untag_ptr(this_ptr);
49384         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49386         this_ptr_conv.is_owned = false;
49387         LDKTransaction val_ref;
49388         val_ref.datalen = val->arr_len;
49389         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
49390         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
49391         val_ref.data_is_owned = true;
49392         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
49393 }
49394
49395 int8_tArray  CS_LDK_BuiltCommitmentTransaction_get_txid(int64_t this_ptr) {
49396         LDKBuiltCommitmentTransaction this_ptr_conv;
49397         this_ptr_conv.inner = untag_ptr(this_ptr);
49398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49400         this_ptr_conv.is_owned = false;
49401         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49402         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
49403         return ret_arr;
49404 }
49405
49406 void  CS_LDK_BuiltCommitmentTransaction_set_txid(int64_t this_ptr, int8_tArray val) {
49407         LDKBuiltCommitmentTransaction this_ptr_conv;
49408         this_ptr_conv.inner = untag_ptr(this_ptr);
49409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49411         this_ptr_conv.is_owned = false;
49412         LDKThirtyTwoBytes val_ref;
49413         CHECK(val->arr_len == 32);
49414         memcpy(val_ref.data, val->elems, 32); FREE(val);
49415         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
49416 }
49417
49418 int64_t  CS_LDK_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
49419         LDKTransaction transaction_arg_ref;
49420         transaction_arg_ref.datalen = transaction_arg->arr_len;
49421         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
49422         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
49423         transaction_arg_ref.data_is_owned = true;
49424         LDKThirtyTwoBytes txid_arg_ref;
49425         CHECK(txid_arg->arr_len == 32);
49426         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
49427         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
49428         int64_t ret_ref = 0;
49429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49431         return ret_ref;
49432 }
49433
49434 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
49435         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
49436         int64_t ret_ref = 0;
49437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49439         return ret_ref;
49440 }
49441 int64_t  CS_LDK_BuiltCommitmentTransaction_clone_ptr(int64_t arg) {
49442         LDKBuiltCommitmentTransaction arg_conv;
49443         arg_conv.inner = untag_ptr(arg);
49444         arg_conv.is_owned = ptr_is_owned(arg);
49445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49446         arg_conv.is_owned = false;
49447         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
49448         return ret_conv;
49449 }
49450
49451 int64_t  CS_LDK_BuiltCommitmentTransaction_clone(int64_t orig) {
49452         LDKBuiltCommitmentTransaction orig_conv;
49453         orig_conv.inner = untag_ptr(orig);
49454         orig_conv.is_owned = ptr_is_owned(orig);
49455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49456         orig_conv.is_owned = false;
49457         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
49458         int64_t ret_ref = 0;
49459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49461         return ret_ref;
49462 }
49463
49464 int8_tArray  CS_LDK_BuiltCommitmentTransaction_write(int64_t obj) {
49465         LDKBuiltCommitmentTransaction obj_conv;
49466         obj_conv.inner = untag_ptr(obj);
49467         obj_conv.is_owned = ptr_is_owned(obj);
49468         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49469         obj_conv.is_owned = false;
49470         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
49471         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49472         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49473         CVec_u8Z_free(ret_var);
49474         return ret_arr;
49475 }
49476
49477 int64_t  CS_LDK_BuiltCommitmentTransaction_read(int8_tArray ser) {
49478         LDKu8slice ser_ref;
49479         ser_ref.datalen = ser->arr_len;
49480         ser_ref.data = ser->elems;
49481         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
49482         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
49483         FREE(ser);
49484         return tag_ptr(ret_conv, true);
49485 }
49486
49487 int8_tArray  CS_LDK_BuiltCommitmentTransaction_get_sighash_all(int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
49488         LDKBuiltCommitmentTransaction this_arg_conv;
49489         this_arg_conv.inner = untag_ptr(this_arg);
49490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49492         this_arg_conv.is_owned = false;
49493         LDKu8slice funding_redeemscript_ref;
49494         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49495         funding_redeemscript_ref.data = funding_redeemscript->elems;
49496         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49497         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
49498         FREE(funding_redeemscript);
49499         return ret_arr;
49500 }
49501
49502 int8_tArray  CS_LDK_BuiltCommitmentTransaction_sign_counterparty_commitment(int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
49503         LDKBuiltCommitmentTransaction this_arg_conv;
49504         this_arg_conv.inner = untag_ptr(this_arg);
49505         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49507         this_arg_conv.is_owned = false;
49508         uint8_t funding_key_arr[32];
49509         CHECK(funding_key->arr_len == 32);
49510         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
49511         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
49512         LDKu8slice funding_redeemscript_ref;
49513         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49514         funding_redeemscript_ref.data = funding_redeemscript->elems;
49515         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49516         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign_counterparty_commitment(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
49517         FREE(funding_redeemscript);
49518         return ret_arr;
49519 }
49520
49521 int8_tArray  CS_LDK_BuiltCommitmentTransaction_sign_holder_commitment(int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis, int64_t entropy_source) {
49522         LDKBuiltCommitmentTransaction this_arg_conv;
49523         this_arg_conv.inner = untag_ptr(this_arg);
49524         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49526         this_arg_conv.is_owned = false;
49527         uint8_t funding_key_arr[32];
49528         CHECK(funding_key->arr_len == 32);
49529         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
49530         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
49531         LDKu8slice funding_redeemscript_ref;
49532         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49533         funding_redeemscript_ref.data = funding_redeemscript->elems;
49534         void* entropy_source_ptr = untag_ptr(entropy_source);
49535         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
49536         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
49537         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49538         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign_holder_commitment(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis, entropy_source_conv).compact_form, 64);
49539         FREE(funding_redeemscript);
49540         return ret_arr;
49541 }
49542
49543 void  CS_LDK_ClosingTransaction_free(int64_t this_obj) {
49544         LDKClosingTransaction this_obj_conv;
49545         this_obj_conv.inner = untag_ptr(this_obj);
49546         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49548         ClosingTransaction_free(this_obj_conv);
49549 }
49550
49551 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
49552         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
49553         int64_t ret_ref = 0;
49554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49556         return ret_ref;
49557 }
49558 int64_t  CS_LDK_ClosingTransaction_clone_ptr(int64_t arg) {
49559         LDKClosingTransaction arg_conv;
49560         arg_conv.inner = untag_ptr(arg);
49561         arg_conv.is_owned = ptr_is_owned(arg);
49562         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49563         arg_conv.is_owned = false;
49564         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
49565         return ret_conv;
49566 }
49567
49568 int64_t  CS_LDK_ClosingTransaction_clone(int64_t orig) {
49569         LDKClosingTransaction orig_conv;
49570         orig_conv.inner = untag_ptr(orig);
49571         orig_conv.is_owned = ptr_is_owned(orig);
49572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49573         orig_conv.is_owned = false;
49574         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
49575         int64_t ret_ref = 0;
49576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49578         return ret_ref;
49579 }
49580
49581 int64_t  CS_LDK_ClosingTransaction_hash(int64_t o) {
49582         LDKClosingTransaction o_conv;
49583         o_conv.inner = untag_ptr(o);
49584         o_conv.is_owned = ptr_is_owned(o);
49585         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49586         o_conv.is_owned = false;
49587         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
49588         return ret_conv;
49589 }
49590
49591 jboolean  CS_LDK_ClosingTransaction_eq(int64_t a, int64_t b) {
49592         LDKClosingTransaction a_conv;
49593         a_conv.inner = untag_ptr(a);
49594         a_conv.is_owned = ptr_is_owned(a);
49595         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49596         a_conv.is_owned = false;
49597         LDKClosingTransaction b_conv;
49598         b_conv.inner = untag_ptr(b);
49599         b_conv.is_owned = ptr_is_owned(b);
49600         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49601         b_conv.is_owned = false;
49602         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
49603         return ret_conv;
49604 }
49605
49606 int64_t  CS_LDK_ClosingTransaction_new(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, int64_t funding_outpoint) {
49607         LDKCVec_u8Z to_holder_script_ref;
49608         to_holder_script_ref.datalen = to_holder_script->arr_len;
49609         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
49610         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
49611         LDKCVec_u8Z to_counterparty_script_ref;
49612         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
49613         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
49614         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
49615         LDKOutPoint funding_outpoint_conv;
49616         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
49617         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
49618         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
49619         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
49620         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
49621         int64_t ret_ref = 0;
49622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49623         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49624         return ret_ref;
49625 }
49626
49627 int64_t  CS_LDK_ClosingTransaction_trust(int64_t this_arg) {
49628         LDKClosingTransaction this_arg_conv;
49629         this_arg_conv.inner = untag_ptr(this_arg);
49630         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49632         this_arg_conv.is_owned = false;
49633         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
49634         int64_t ret_ref = 0;
49635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49636         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49637         return ret_ref;
49638 }
49639
49640 int64_t  CS_LDK_ClosingTransaction_verify(int64_t this_arg, int64_t funding_outpoint) {
49641         LDKClosingTransaction this_arg_conv;
49642         this_arg_conv.inner = untag_ptr(this_arg);
49643         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49645         this_arg_conv.is_owned = false;
49646         LDKOutPoint funding_outpoint_conv;
49647         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
49648         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
49649         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
49650         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
49651         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
49652         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
49653         return tag_ptr(ret_conv, true);
49654 }
49655
49656 int64_t  CS_LDK_ClosingTransaction_to_holder_value_sat(int64_t this_arg) {
49657         LDKClosingTransaction this_arg_conv;
49658         this_arg_conv.inner = untag_ptr(this_arg);
49659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49661         this_arg_conv.is_owned = false;
49662         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
49663         return ret_conv;
49664 }
49665
49666 int64_t  CS_LDK_ClosingTransaction_to_counterparty_value_sat(int64_t this_arg) {
49667         LDKClosingTransaction this_arg_conv;
49668         this_arg_conv.inner = untag_ptr(this_arg);
49669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49671         this_arg_conv.is_owned = false;
49672         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
49673         return ret_conv;
49674 }
49675
49676 int8_tArray  CS_LDK_ClosingTransaction_to_holder_script(int64_t this_arg) {
49677         LDKClosingTransaction this_arg_conv;
49678         this_arg_conv.inner = untag_ptr(this_arg);
49679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49681         this_arg_conv.is_owned = false;
49682         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
49683         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49684         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49685         return ret_arr;
49686 }
49687
49688 int8_tArray  CS_LDK_ClosingTransaction_to_counterparty_script(int64_t this_arg) {
49689         LDKClosingTransaction this_arg_conv;
49690         this_arg_conv.inner = untag_ptr(this_arg);
49691         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49693         this_arg_conv.is_owned = false;
49694         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
49695         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49696         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49697         return ret_arr;
49698 }
49699
49700 void  CS_LDK_TrustedClosingTransaction_free(int64_t this_obj) {
49701         LDKTrustedClosingTransaction this_obj_conv;
49702         this_obj_conv.inner = untag_ptr(this_obj);
49703         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49705         TrustedClosingTransaction_free(this_obj_conv);
49706 }
49707
49708 int8_tArray  CS_LDK_TrustedClosingTransaction_built_transaction(int64_t this_arg) {
49709         LDKTrustedClosingTransaction this_arg_conv;
49710         this_arg_conv.inner = untag_ptr(this_arg);
49711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49713         this_arg_conv.is_owned = false;
49714         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
49715         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49716         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49717         Transaction_free(ret_var);
49718         return ret_arr;
49719 }
49720
49721 int8_tArray  CS_LDK_TrustedClosingTransaction_get_sighash_all(int64_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
49722         LDKTrustedClosingTransaction this_arg_conv;
49723         this_arg_conv.inner = untag_ptr(this_arg);
49724         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49726         this_arg_conv.is_owned = false;
49727         LDKu8slice funding_redeemscript_ref;
49728         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49729         funding_redeemscript_ref.data = funding_redeemscript->elems;
49730         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49731         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
49732         FREE(funding_redeemscript);
49733         return ret_arr;
49734 }
49735
49736 int8_tArray  CS_LDK_TrustedClosingTransaction_sign(int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
49737         LDKTrustedClosingTransaction this_arg_conv;
49738         this_arg_conv.inner = untag_ptr(this_arg);
49739         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49741         this_arg_conv.is_owned = false;
49742         uint8_t funding_key_arr[32];
49743         CHECK(funding_key->arr_len == 32);
49744         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
49745         uint8_t (*funding_key_ref)[32] = &funding_key_arr;
49746         LDKu8slice funding_redeemscript_ref;
49747         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
49748         funding_redeemscript_ref.data = funding_redeemscript->elems;
49749         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
49750         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
49751         FREE(funding_redeemscript);
49752         return ret_arr;
49753 }
49754
49755 void  CS_LDK_CommitmentTransaction_free(int64_t this_obj) {
49756         LDKCommitmentTransaction this_obj_conv;
49757         this_obj_conv.inner = untag_ptr(this_obj);
49758         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49760         CommitmentTransaction_free(this_obj_conv);
49761 }
49762
49763 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
49764         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
49765         int64_t ret_ref = 0;
49766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49767         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49768         return ret_ref;
49769 }
49770 int64_t  CS_LDK_CommitmentTransaction_clone_ptr(int64_t arg) {
49771         LDKCommitmentTransaction arg_conv;
49772         arg_conv.inner = untag_ptr(arg);
49773         arg_conv.is_owned = ptr_is_owned(arg);
49774         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49775         arg_conv.is_owned = false;
49776         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
49777         return ret_conv;
49778 }
49779
49780 int64_t  CS_LDK_CommitmentTransaction_clone(int64_t orig) {
49781         LDKCommitmentTransaction orig_conv;
49782         orig_conv.inner = untag_ptr(orig);
49783         orig_conv.is_owned = ptr_is_owned(orig);
49784         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49785         orig_conv.is_owned = false;
49786         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
49787         int64_t ret_ref = 0;
49788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49789         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49790         return ret_ref;
49791 }
49792
49793 int8_tArray  CS_LDK_CommitmentTransaction_write(int64_t obj) {
49794         LDKCommitmentTransaction obj_conv;
49795         obj_conv.inner = untag_ptr(obj);
49796         obj_conv.is_owned = ptr_is_owned(obj);
49797         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49798         obj_conv.is_owned = false;
49799         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
49800         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
49801         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
49802         CVec_u8Z_free(ret_var);
49803         return ret_arr;
49804 }
49805
49806 int64_t  CS_LDK_CommitmentTransaction_read(int8_tArray ser) {
49807         LDKu8slice ser_ref;
49808         ser_ref.datalen = ser->arr_len;
49809         ser_ref.data = ser->elems;
49810         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
49811         *ret_conv = CommitmentTransaction_read(ser_ref);
49812         FREE(ser);
49813         return tag_ptr(ret_conv, true);
49814 }
49815
49816 int64_t  CS_LDK_CommitmentTransaction_commitment_number(int64_t this_arg) {
49817         LDKCommitmentTransaction this_arg_conv;
49818         this_arg_conv.inner = untag_ptr(this_arg);
49819         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49821         this_arg_conv.is_owned = false;
49822         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
49823         return ret_conv;
49824 }
49825
49826 int8_tArray  CS_LDK_CommitmentTransaction_per_commitment_point(int64_t this_arg) {
49827         LDKCommitmentTransaction this_arg_conv;
49828         this_arg_conv.inner = untag_ptr(this_arg);
49829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49831         this_arg_conv.is_owned = false;
49832         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
49833         memcpy(ret_arr->elems, CommitmentTransaction_per_commitment_point(&this_arg_conv).compressed_form, 33);
49834         return ret_arr;
49835 }
49836
49837 int64_t  CS_LDK_CommitmentTransaction_to_broadcaster_value_sat(int64_t this_arg) {
49838         LDKCommitmentTransaction this_arg_conv;
49839         this_arg_conv.inner = untag_ptr(this_arg);
49840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49842         this_arg_conv.is_owned = false;
49843         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
49844         return ret_conv;
49845 }
49846
49847 int64_t  CS_LDK_CommitmentTransaction_to_countersignatory_value_sat(int64_t this_arg) {
49848         LDKCommitmentTransaction this_arg_conv;
49849         this_arg_conv.inner = untag_ptr(this_arg);
49850         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49852         this_arg_conv.is_owned = false;
49853         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
49854         return ret_conv;
49855 }
49856
49857 int32_t  CS_LDK_CommitmentTransaction_feerate_per_kw(int64_t this_arg) {
49858         LDKCommitmentTransaction this_arg_conv;
49859         this_arg_conv.inner = untag_ptr(this_arg);
49860         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49862         this_arg_conv.is_owned = false;
49863         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
49864         return ret_conv;
49865 }
49866
49867 int64_t  CS_LDK_CommitmentTransaction_trust(int64_t this_arg) {
49868         LDKCommitmentTransaction this_arg_conv;
49869         this_arg_conv.inner = untag_ptr(this_arg);
49870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49872         this_arg_conv.is_owned = false;
49873         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
49874         int64_t ret_ref = 0;
49875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49876         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49877         return ret_ref;
49878 }
49879
49880 int64_t  CS_LDK_CommitmentTransaction_verify(int64_t this_arg, int64_t channel_parameters, int64_t broadcaster_keys, int64_t countersignatory_keys) {
49881         LDKCommitmentTransaction this_arg_conv;
49882         this_arg_conv.inner = untag_ptr(this_arg);
49883         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49885         this_arg_conv.is_owned = false;
49886         LDKDirectedChannelTransactionParameters channel_parameters_conv;
49887         channel_parameters_conv.inner = untag_ptr(channel_parameters);
49888         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
49889         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
49890         channel_parameters_conv.is_owned = false;
49891         LDKChannelPublicKeys broadcaster_keys_conv;
49892         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
49893         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
49894         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
49895         broadcaster_keys_conv.is_owned = false;
49896         LDKChannelPublicKeys countersignatory_keys_conv;
49897         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
49898         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
49899         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
49900         countersignatory_keys_conv.is_owned = false;
49901         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
49902         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
49903         return tag_ptr(ret_conv, true);
49904 }
49905
49906 void  CS_LDK_TrustedCommitmentTransaction_free(int64_t this_obj) {
49907         LDKTrustedCommitmentTransaction this_obj_conv;
49908         this_obj_conv.inner = untag_ptr(this_obj);
49909         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49911         TrustedCommitmentTransaction_free(this_obj_conv);
49912 }
49913
49914 int8_tArray  CS_LDK_TrustedCommitmentTransaction_txid(int64_t this_arg) {
49915         LDKTrustedCommitmentTransaction this_arg_conv;
49916         this_arg_conv.inner = untag_ptr(this_arg);
49917         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49919         this_arg_conv.is_owned = false;
49920         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
49921         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
49922         return ret_arr;
49923 }
49924
49925 int64_t  CS_LDK_TrustedCommitmentTransaction_built_transaction(int64_t this_arg) {
49926         LDKTrustedCommitmentTransaction this_arg_conv;
49927         this_arg_conv.inner = untag_ptr(this_arg);
49928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49930         this_arg_conv.is_owned = false;
49931         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
49932         int64_t ret_ref = 0;
49933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49935         return ret_ref;
49936 }
49937
49938 int64_t  CS_LDK_TrustedCommitmentTransaction_keys(int64_t this_arg) {
49939         LDKTrustedCommitmentTransaction this_arg_conv;
49940         this_arg_conv.inner = untag_ptr(this_arg);
49941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49943         this_arg_conv.is_owned = false;
49944         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
49945         int64_t ret_ref = 0;
49946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49947         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49948         return ret_ref;
49949 }
49950
49951 int64_t  CS_LDK_TrustedCommitmentTransaction_channel_type_features(int64_t this_arg) {
49952         LDKTrustedCommitmentTransaction this_arg_conv;
49953         this_arg_conv.inner = untag_ptr(this_arg);
49954         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49956         this_arg_conv.is_owned = false;
49957         LDKChannelTypeFeatures ret_var = TrustedCommitmentTransaction_channel_type_features(&this_arg_conv);
49958         int64_t ret_ref = 0;
49959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49961         return ret_ref;
49962 }
49963
49964 int64_t  CS_LDK_TrustedCommitmentTransaction_get_htlc_sigs(int64_t this_arg, int8_tArray htlc_base_key, int64_t channel_parameters, int64_t entropy_source) {
49965         LDKTrustedCommitmentTransaction this_arg_conv;
49966         this_arg_conv.inner = untag_ptr(this_arg);
49967         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49969         this_arg_conv.is_owned = false;
49970         uint8_t htlc_base_key_arr[32];
49971         CHECK(htlc_base_key->arr_len == 32);
49972         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
49973         uint8_t (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
49974         LDKDirectedChannelTransactionParameters channel_parameters_conv;
49975         channel_parameters_conv.inner = untag_ptr(channel_parameters);
49976         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
49977         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
49978         channel_parameters_conv.is_owned = false;
49979         void* entropy_source_ptr = untag_ptr(entropy_source);
49980         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
49981         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
49982         LDKCResult_CVec_ECDSASignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_ECDSASignatureZNoneZ), "LDKCResult_CVec_ECDSASignatureZNoneZ");
49983         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv, entropy_source_conv);
49984         return tag_ptr(ret_conv, true);
49985 }
49986
49987 int64_t  CS_LDK_TrustedCommitmentTransaction_revokeable_output_index(int64_t this_arg) {
49988         LDKTrustedCommitmentTransaction this_arg_conv;
49989         this_arg_conv.inner = untag_ptr(this_arg);
49990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49992         this_arg_conv.is_owned = false;
49993         LDKCOption_usizeZ *ret_copy = MALLOC(sizeof(LDKCOption_usizeZ), "LDKCOption_usizeZ");
49994         *ret_copy = TrustedCommitmentTransaction_revokeable_output_index(&this_arg_conv);
49995         int64_t ret_ref = tag_ptr(ret_copy, true);
49996         return ret_ref;
49997 }
49998
49999 int64_t  CS_LDK_TrustedCommitmentTransaction_build_to_local_justice_tx(int64_t this_arg, int64_t feerate_per_kw, int8_tArray destination_script) {
50000         LDKTrustedCommitmentTransaction this_arg_conv;
50001         this_arg_conv.inner = untag_ptr(this_arg);
50002         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50004         this_arg_conv.is_owned = false;
50005         LDKCVec_u8Z destination_script_ref;
50006         destination_script_ref.datalen = destination_script->arr_len;
50007         destination_script_ref.data = MALLOC(destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
50008         memcpy(destination_script_ref.data, destination_script->elems, destination_script_ref.datalen); FREE(destination_script);
50009         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
50010         *ret_conv = TrustedCommitmentTransaction_build_to_local_justice_tx(&this_arg_conv, feerate_per_kw, destination_script_ref);
50011         return tag_ptr(ret_conv, true);
50012 }
50013
50014 int64_t  CS_LDK_get_commitment_transaction_number_obscure_factor(int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
50015         LDKPublicKey broadcaster_payment_basepoint_ref;
50016         CHECK(broadcaster_payment_basepoint->arr_len == 33);
50017         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
50018         LDKPublicKey countersignatory_payment_basepoint_ref;
50019         CHECK(countersignatory_payment_basepoint->arr_len == 33);
50020         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
50021         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
50022         return ret_conv;
50023 }
50024
50025 jboolean  CS_LDK_InitFeatures_eq(int64_t a, int64_t b) {
50026         LDKInitFeatures a_conv;
50027         a_conv.inner = untag_ptr(a);
50028         a_conv.is_owned = ptr_is_owned(a);
50029         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50030         a_conv.is_owned = false;
50031         LDKInitFeatures b_conv;
50032         b_conv.inner = untag_ptr(b);
50033         b_conv.is_owned = ptr_is_owned(b);
50034         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50035         b_conv.is_owned = false;
50036         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
50037         return ret_conv;
50038 }
50039
50040 jboolean  CS_LDK_NodeFeatures_eq(int64_t a, int64_t b) {
50041         LDKNodeFeatures a_conv;
50042         a_conv.inner = untag_ptr(a);
50043         a_conv.is_owned = ptr_is_owned(a);
50044         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50045         a_conv.is_owned = false;
50046         LDKNodeFeatures b_conv;
50047         b_conv.inner = untag_ptr(b);
50048         b_conv.is_owned = ptr_is_owned(b);
50049         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50050         b_conv.is_owned = false;
50051         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
50052         return ret_conv;
50053 }
50054
50055 jboolean  CS_LDK_ChannelFeatures_eq(int64_t a, int64_t b) {
50056         LDKChannelFeatures a_conv;
50057         a_conv.inner = untag_ptr(a);
50058         a_conv.is_owned = ptr_is_owned(a);
50059         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50060         a_conv.is_owned = false;
50061         LDKChannelFeatures b_conv;
50062         b_conv.inner = untag_ptr(b);
50063         b_conv.is_owned = ptr_is_owned(b);
50064         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50065         b_conv.is_owned = false;
50066         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
50067         return ret_conv;
50068 }
50069
50070 jboolean  CS_LDK_Bolt11InvoiceFeatures_eq(int64_t a, int64_t b) {
50071         LDKBolt11InvoiceFeatures a_conv;
50072         a_conv.inner = untag_ptr(a);
50073         a_conv.is_owned = ptr_is_owned(a);
50074         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50075         a_conv.is_owned = false;
50076         LDKBolt11InvoiceFeatures b_conv;
50077         b_conv.inner = untag_ptr(b);
50078         b_conv.is_owned = ptr_is_owned(b);
50079         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50080         b_conv.is_owned = false;
50081         jboolean ret_conv = Bolt11InvoiceFeatures_eq(&a_conv, &b_conv);
50082         return ret_conv;
50083 }
50084
50085 jboolean  CS_LDK_OfferFeatures_eq(int64_t a, int64_t b) {
50086         LDKOfferFeatures a_conv;
50087         a_conv.inner = untag_ptr(a);
50088         a_conv.is_owned = ptr_is_owned(a);
50089         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50090         a_conv.is_owned = false;
50091         LDKOfferFeatures b_conv;
50092         b_conv.inner = untag_ptr(b);
50093         b_conv.is_owned = ptr_is_owned(b);
50094         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50095         b_conv.is_owned = false;
50096         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
50097         return ret_conv;
50098 }
50099
50100 jboolean  CS_LDK_InvoiceRequestFeatures_eq(int64_t a, int64_t b) {
50101         LDKInvoiceRequestFeatures a_conv;
50102         a_conv.inner = untag_ptr(a);
50103         a_conv.is_owned = ptr_is_owned(a);
50104         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50105         a_conv.is_owned = false;
50106         LDKInvoiceRequestFeatures b_conv;
50107         b_conv.inner = untag_ptr(b);
50108         b_conv.is_owned = ptr_is_owned(b);
50109         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50110         b_conv.is_owned = false;
50111         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
50112         return ret_conv;
50113 }
50114
50115 jboolean  CS_LDK_Bolt12InvoiceFeatures_eq(int64_t a, int64_t b) {
50116         LDKBolt12InvoiceFeatures a_conv;
50117         a_conv.inner = untag_ptr(a);
50118         a_conv.is_owned = ptr_is_owned(a);
50119         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50120         a_conv.is_owned = false;
50121         LDKBolt12InvoiceFeatures b_conv;
50122         b_conv.inner = untag_ptr(b);
50123         b_conv.is_owned = ptr_is_owned(b);
50124         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50125         b_conv.is_owned = false;
50126         jboolean ret_conv = Bolt12InvoiceFeatures_eq(&a_conv, &b_conv);
50127         return ret_conv;
50128 }
50129
50130 jboolean  CS_LDK_BlindedHopFeatures_eq(int64_t a, int64_t b) {
50131         LDKBlindedHopFeatures a_conv;
50132         a_conv.inner = untag_ptr(a);
50133         a_conv.is_owned = ptr_is_owned(a);
50134         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50135         a_conv.is_owned = false;
50136         LDKBlindedHopFeatures b_conv;
50137         b_conv.inner = untag_ptr(b);
50138         b_conv.is_owned = ptr_is_owned(b);
50139         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50140         b_conv.is_owned = false;
50141         jboolean ret_conv = BlindedHopFeatures_eq(&a_conv, &b_conv);
50142         return ret_conv;
50143 }
50144
50145 jboolean  CS_LDK_ChannelTypeFeatures_eq(int64_t a, int64_t b) {
50146         LDKChannelTypeFeatures a_conv;
50147         a_conv.inner = untag_ptr(a);
50148         a_conv.is_owned = ptr_is_owned(a);
50149         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50150         a_conv.is_owned = false;
50151         LDKChannelTypeFeatures b_conv;
50152         b_conv.inner = untag_ptr(b);
50153         b_conv.is_owned = ptr_is_owned(b);
50154         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
50155         b_conv.is_owned = false;
50156         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
50157         return ret_conv;
50158 }
50159
50160 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
50161         LDKInitFeatures ret_var = InitFeatures_clone(arg);
50162         int64_t ret_ref = 0;
50163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50165         return ret_ref;
50166 }
50167 int64_t  CS_LDK_InitFeatures_clone_ptr(int64_t arg) {
50168         LDKInitFeatures arg_conv;
50169         arg_conv.inner = untag_ptr(arg);
50170         arg_conv.is_owned = ptr_is_owned(arg);
50171         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50172         arg_conv.is_owned = false;
50173         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
50174         return ret_conv;
50175 }
50176
50177 int64_t  CS_LDK_InitFeatures_clone(int64_t orig) {
50178         LDKInitFeatures orig_conv;
50179         orig_conv.inner = untag_ptr(orig);
50180         orig_conv.is_owned = ptr_is_owned(orig);
50181         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50182         orig_conv.is_owned = false;
50183         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
50184         int64_t ret_ref = 0;
50185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50187         return ret_ref;
50188 }
50189
50190 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
50191         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
50192         int64_t ret_ref = 0;
50193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50195         return ret_ref;
50196 }
50197 int64_t  CS_LDK_NodeFeatures_clone_ptr(int64_t arg) {
50198         LDKNodeFeatures arg_conv;
50199         arg_conv.inner = untag_ptr(arg);
50200         arg_conv.is_owned = ptr_is_owned(arg);
50201         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50202         arg_conv.is_owned = false;
50203         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
50204         return ret_conv;
50205 }
50206
50207 int64_t  CS_LDK_NodeFeatures_clone(int64_t orig) {
50208         LDKNodeFeatures orig_conv;
50209         orig_conv.inner = untag_ptr(orig);
50210         orig_conv.is_owned = ptr_is_owned(orig);
50211         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50212         orig_conv.is_owned = false;
50213         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
50214         int64_t ret_ref = 0;
50215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50217         return ret_ref;
50218 }
50219
50220 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
50221         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
50222         int64_t ret_ref = 0;
50223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50225         return ret_ref;
50226 }
50227 int64_t  CS_LDK_ChannelFeatures_clone_ptr(int64_t arg) {
50228         LDKChannelFeatures arg_conv;
50229         arg_conv.inner = untag_ptr(arg);
50230         arg_conv.is_owned = ptr_is_owned(arg);
50231         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50232         arg_conv.is_owned = false;
50233         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
50234         return ret_conv;
50235 }
50236
50237 int64_t  CS_LDK_ChannelFeatures_clone(int64_t orig) {
50238         LDKChannelFeatures orig_conv;
50239         orig_conv.inner = untag_ptr(orig);
50240         orig_conv.is_owned = ptr_is_owned(orig);
50241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50242         orig_conv.is_owned = false;
50243         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
50244         int64_t ret_ref = 0;
50245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50247         return ret_ref;
50248 }
50249
50250 static inline uint64_t Bolt11InvoiceFeatures_clone_ptr(LDKBolt11InvoiceFeatures *NONNULL_PTR arg) {
50251         LDKBolt11InvoiceFeatures ret_var = Bolt11InvoiceFeatures_clone(arg);
50252         int64_t ret_ref = 0;
50253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50255         return ret_ref;
50256 }
50257 int64_t  CS_LDK_Bolt11InvoiceFeatures_clone_ptr(int64_t arg) {
50258         LDKBolt11InvoiceFeatures arg_conv;
50259         arg_conv.inner = untag_ptr(arg);
50260         arg_conv.is_owned = ptr_is_owned(arg);
50261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50262         arg_conv.is_owned = false;
50263         int64_t ret_conv = Bolt11InvoiceFeatures_clone_ptr(&arg_conv);
50264         return ret_conv;
50265 }
50266
50267 int64_t  CS_LDK_Bolt11InvoiceFeatures_clone(int64_t orig) {
50268         LDKBolt11InvoiceFeatures orig_conv;
50269         orig_conv.inner = untag_ptr(orig);
50270         orig_conv.is_owned = ptr_is_owned(orig);
50271         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50272         orig_conv.is_owned = false;
50273         LDKBolt11InvoiceFeatures ret_var = Bolt11InvoiceFeatures_clone(&orig_conv);
50274         int64_t ret_ref = 0;
50275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50276         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50277         return ret_ref;
50278 }
50279
50280 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
50281         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
50282         int64_t ret_ref = 0;
50283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50285         return ret_ref;
50286 }
50287 int64_t  CS_LDK_OfferFeatures_clone_ptr(int64_t arg) {
50288         LDKOfferFeatures arg_conv;
50289         arg_conv.inner = untag_ptr(arg);
50290         arg_conv.is_owned = ptr_is_owned(arg);
50291         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50292         arg_conv.is_owned = false;
50293         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
50294         return ret_conv;
50295 }
50296
50297 int64_t  CS_LDK_OfferFeatures_clone(int64_t orig) {
50298         LDKOfferFeatures orig_conv;
50299         orig_conv.inner = untag_ptr(orig);
50300         orig_conv.is_owned = ptr_is_owned(orig);
50301         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50302         orig_conv.is_owned = false;
50303         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
50304         int64_t ret_ref = 0;
50305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50307         return ret_ref;
50308 }
50309
50310 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
50311         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
50312         int64_t ret_ref = 0;
50313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50315         return ret_ref;
50316 }
50317 int64_t  CS_LDK_InvoiceRequestFeatures_clone_ptr(int64_t arg) {
50318         LDKInvoiceRequestFeatures arg_conv;
50319         arg_conv.inner = untag_ptr(arg);
50320         arg_conv.is_owned = ptr_is_owned(arg);
50321         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50322         arg_conv.is_owned = false;
50323         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
50324         return ret_conv;
50325 }
50326
50327 int64_t  CS_LDK_InvoiceRequestFeatures_clone(int64_t orig) {
50328         LDKInvoiceRequestFeatures orig_conv;
50329         orig_conv.inner = untag_ptr(orig);
50330         orig_conv.is_owned = ptr_is_owned(orig);
50331         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50332         orig_conv.is_owned = false;
50333         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
50334         int64_t ret_ref = 0;
50335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50336         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50337         return ret_ref;
50338 }
50339
50340 static inline uint64_t Bolt12InvoiceFeatures_clone_ptr(LDKBolt12InvoiceFeatures *NONNULL_PTR arg) {
50341         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(arg);
50342         int64_t ret_ref = 0;
50343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50344         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50345         return ret_ref;
50346 }
50347 int64_t  CS_LDK_Bolt12InvoiceFeatures_clone_ptr(int64_t arg) {
50348         LDKBolt12InvoiceFeatures arg_conv;
50349         arg_conv.inner = untag_ptr(arg);
50350         arg_conv.is_owned = ptr_is_owned(arg);
50351         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50352         arg_conv.is_owned = false;
50353         int64_t ret_conv = Bolt12InvoiceFeatures_clone_ptr(&arg_conv);
50354         return ret_conv;
50355 }
50356
50357 int64_t  CS_LDK_Bolt12InvoiceFeatures_clone(int64_t orig) {
50358         LDKBolt12InvoiceFeatures orig_conv;
50359         orig_conv.inner = untag_ptr(orig);
50360         orig_conv.is_owned = ptr_is_owned(orig);
50361         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50362         orig_conv.is_owned = false;
50363         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_clone(&orig_conv);
50364         int64_t ret_ref = 0;
50365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50367         return ret_ref;
50368 }
50369
50370 static inline uint64_t BlindedHopFeatures_clone_ptr(LDKBlindedHopFeatures *NONNULL_PTR arg) {
50371         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(arg);
50372         int64_t ret_ref = 0;
50373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50374         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50375         return ret_ref;
50376 }
50377 int64_t  CS_LDK_BlindedHopFeatures_clone_ptr(int64_t arg) {
50378         LDKBlindedHopFeatures arg_conv;
50379         arg_conv.inner = untag_ptr(arg);
50380         arg_conv.is_owned = ptr_is_owned(arg);
50381         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50382         arg_conv.is_owned = false;
50383         int64_t ret_conv = BlindedHopFeatures_clone_ptr(&arg_conv);
50384         return ret_conv;
50385 }
50386
50387 int64_t  CS_LDK_BlindedHopFeatures_clone(int64_t orig) {
50388         LDKBlindedHopFeatures orig_conv;
50389         orig_conv.inner = untag_ptr(orig);
50390         orig_conv.is_owned = ptr_is_owned(orig);
50391         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50392         orig_conv.is_owned = false;
50393         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_clone(&orig_conv);
50394         int64_t ret_ref = 0;
50395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50396         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50397         return ret_ref;
50398 }
50399
50400 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
50401         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
50402         int64_t ret_ref = 0;
50403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50405         return ret_ref;
50406 }
50407 int64_t  CS_LDK_ChannelTypeFeatures_clone_ptr(int64_t arg) {
50408         LDKChannelTypeFeatures arg_conv;
50409         arg_conv.inner = untag_ptr(arg);
50410         arg_conv.is_owned = ptr_is_owned(arg);
50411         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50412         arg_conv.is_owned = false;
50413         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
50414         return ret_conv;
50415 }
50416
50417 int64_t  CS_LDK_ChannelTypeFeatures_clone(int64_t orig) {
50418         LDKChannelTypeFeatures orig_conv;
50419         orig_conv.inner = untag_ptr(orig);
50420         orig_conv.is_owned = ptr_is_owned(orig);
50421         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50422         orig_conv.is_owned = false;
50423         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
50424         int64_t ret_ref = 0;
50425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50426         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50427         return ret_ref;
50428 }
50429
50430 void  CS_LDK_InitFeatures_free(int64_t this_obj) {
50431         LDKInitFeatures this_obj_conv;
50432         this_obj_conv.inner = untag_ptr(this_obj);
50433         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50435         InitFeatures_free(this_obj_conv);
50436 }
50437
50438 void  CS_LDK_NodeFeatures_free(int64_t this_obj) {
50439         LDKNodeFeatures this_obj_conv;
50440         this_obj_conv.inner = untag_ptr(this_obj);
50441         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50443         NodeFeatures_free(this_obj_conv);
50444 }
50445
50446 void  CS_LDK_ChannelFeatures_free(int64_t this_obj) {
50447         LDKChannelFeatures this_obj_conv;
50448         this_obj_conv.inner = untag_ptr(this_obj);
50449         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50451         ChannelFeatures_free(this_obj_conv);
50452 }
50453
50454 void  CS_LDK_Bolt11InvoiceFeatures_free(int64_t this_obj) {
50455         LDKBolt11InvoiceFeatures this_obj_conv;
50456         this_obj_conv.inner = untag_ptr(this_obj);
50457         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50459         Bolt11InvoiceFeatures_free(this_obj_conv);
50460 }
50461
50462 void  CS_LDK_OfferFeatures_free(int64_t this_obj) {
50463         LDKOfferFeatures this_obj_conv;
50464         this_obj_conv.inner = untag_ptr(this_obj);
50465         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50467         OfferFeatures_free(this_obj_conv);
50468 }
50469
50470 void  CS_LDK_InvoiceRequestFeatures_free(int64_t this_obj) {
50471         LDKInvoiceRequestFeatures this_obj_conv;
50472         this_obj_conv.inner = untag_ptr(this_obj);
50473         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50475         InvoiceRequestFeatures_free(this_obj_conv);
50476 }
50477
50478 void  CS_LDK_Bolt12InvoiceFeatures_free(int64_t this_obj) {
50479         LDKBolt12InvoiceFeatures this_obj_conv;
50480         this_obj_conv.inner = untag_ptr(this_obj);
50481         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50483         Bolt12InvoiceFeatures_free(this_obj_conv);
50484 }
50485
50486 void  CS_LDK_BlindedHopFeatures_free(int64_t this_obj) {
50487         LDKBlindedHopFeatures this_obj_conv;
50488         this_obj_conv.inner = untag_ptr(this_obj);
50489         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50491         BlindedHopFeatures_free(this_obj_conv);
50492 }
50493
50494 void  CS_LDK_ChannelTypeFeatures_free(int64_t this_obj) {
50495         LDKChannelTypeFeatures this_obj_conv;
50496         this_obj_conv.inner = untag_ptr(this_obj);
50497         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50499         ChannelTypeFeatures_free(this_obj_conv);
50500 }
50501
50502 int64_t  CS_LDK_InitFeatures_empty() {
50503         LDKInitFeatures ret_var = InitFeatures_empty();
50504         int64_t ret_ref = 0;
50505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50507         return ret_ref;
50508 }
50509
50510 jboolean  CS_LDK_InitFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50511         LDKInitFeatures this_arg_conv;
50512         this_arg_conv.inner = untag_ptr(this_arg);
50513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50515         this_arg_conv.is_owned = false;
50516         LDKInitFeatures other_conv;
50517         other_conv.inner = untag_ptr(other);
50518         other_conv.is_owned = ptr_is_owned(other);
50519         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50520         other_conv.is_owned = false;
50521         jboolean ret_conv = InitFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50522         return ret_conv;
50523 }
50524
50525 jboolean  CS_LDK_InitFeatures_requires_unknown_bits(int64_t this_arg) {
50526         LDKInitFeatures this_arg_conv;
50527         this_arg_conv.inner = untag_ptr(this_arg);
50528         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50530         this_arg_conv.is_owned = false;
50531         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
50532         return ret_conv;
50533 }
50534
50535 int64_t  CS_LDK_InitFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50536         LDKInitFeatures this_arg_conv;
50537         this_arg_conv.inner = untag_ptr(this_arg);
50538         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50540         this_arg_conv.is_owned = false;
50541         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50542         *ret_conv = InitFeatures_set_required_feature_bit(&this_arg_conv, bit);
50543         return tag_ptr(ret_conv, true);
50544 }
50545
50546 int64_t  CS_LDK_InitFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50547         LDKInitFeatures this_arg_conv;
50548         this_arg_conv.inner = untag_ptr(this_arg);
50549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50551         this_arg_conv.is_owned = false;
50552         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50553         *ret_conv = InitFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50554         return tag_ptr(ret_conv, true);
50555 }
50556
50557 int64_t  CS_LDK_InitFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50558         LDKInitFeatures this_arg_conv;
50559         this_arg_conv.inner = untag_ptr(this_arg);
50560         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50562         this_arg_conv.is_owned = false;
50563         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50564         *ret_conv = InitFeatures_set_required_custom_bit(&this_arg_conv, bit);
50565         return tag_ptr(ret_conv, true);
50566 }
50567
50568 int64_t  CS_LDK_InitFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50569         LDKInitFeatures this_arg_conv;
50570         this_arg_conv.inner = untag_ptr(this_arg);
50571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50573         this_arg_conv.is_owned = false;
50574         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50575         *ret_conv = InitFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50576         return tag_ptr(ret_conv, true);
50577 }
50578
50579 int64_t  CS_LDK_NodeFeatures_empty() {
50580         LDKNodeFeatures ret_var = NodeFeatures_empty();
50581         int64_t ret_ref = 0;
50582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50584         return ret_ref;
50585 }
50586
50587 jboolean  CS_LDK_NodeFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50588         LDKNodeFeatures this_arg_conv;
50589         this_arg_conv.inner = untag_ptr(this_arg);
50590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50592         this_arg_conv.is_owned = false;
50593         LDKNodeFeatures other_conv;
50594         other_conv.inner = untag_ptr(other);
50595         other_conv.is_owned = ptr_is_owned(other);
50596         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50597         other_conv.is_owned = false;
50598         jboolean ret_conv = NodeFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50599         return ret_conv;
50600 }
50601
50602 jboolean  CS_LDK_NodeFeatures_requires_unknown_bits(int64_t this_arg) {
50603         LDKNodeFeatures this_arg_conv;
50604         this_arg_conv.inner = untag_ptr(this_arg);
50605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50607         this_arg_conv.is_owned = false;
50608         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
50609         return ret_conv;
50610 }
50611
50612 int64_t  CS_LDK_NodeFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50613         LDKNodeFeatures this_arg_conv;
50614         this_arg_conv.inner = untag_ptr(this_arg);
50615         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50617         this_arg_conv.is_owned = false;
50618         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50619         *ret_conv = NodeFeatures_set_required_feature_bit(&this_arg_conv, bit);
50620         return tag_ptr(ret_conv, true);
50621 }
50622
50623 int64_t  CS_LDK_NodeFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50624         LDKNodeFeatures this_arg_conv;
50625         this_arg_conv.inner = untag_ptr(this_arg);
50626         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50628         this_arg_conv.is_owned = false;
50629         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50630         *ret_conv = NodeFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50631         return tag_ptr(ret_conv, true);
50632 }
50633
50634 int64_t  CS_LDK_NodeFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50635         LDKNodeFeatures this_arg_conv;
50636         this_arg_conv.inner = untag_ptr(this_arg);
50637         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50639         this_arg_conv.is_owned = false;
50640         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50641         *ret_conv = NodeFeatures_set_required_custom_bit(&this_arg_conv, bit);
50642         return tag_ptr(ret_conv, true);
50643 }
50644
50645 int64_t  CS_LDK_NodeFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50646         LDKNodeFeatures this_arg_conv;
50647         this_arg_conv.inner = untag_ptr(this_arg);
50648         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50650         this_arg_conv.is_owned = false;
50651         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50652         *ret_conv = NodeFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50653         return tag_ptr(ret_conv, true);
50654 }
50655
50656 int64_t  CS_LDK_ChannelFeatures_empty() {
50657         LDKChannelFeatures ret_var = ChannelFeatures_empty();
50658         int64_t ret_ref = 0;
50659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50660         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50661         return ret_ref;
50662 }
50663
50664 jboolean  CS_LDK_ChannelFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50665         LDKChannelFeatures this_arg_conv;
50666         this_arg_conv.inner = untag_ptr(this_arg);
50667         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50669         this_arg_conv.is_owned = false;
50670         LDKChannelFeatures other_conv;
50671         other_conv.inner = untag_ptr(other);
50672         other_conv.is_owned = ptr_is_owned(other);
50673         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50674         other_conv.is_owned = false;
50675         jboolean ret_conv = ChannelFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50676         return ret_conv;
50677 }
50678
50679 jboolean  CS_LDK_ChannelFeatures_requires_unknown_bits(int64_t this_arg) {
50680         LDKChannelFeatures this_arg_conv;
50681         this_arg_conv.inner = untag_ptr(this_arg);
50682         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50684         this_arg_conv.is_owned = false;
50685         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
50686         return ret_conv;
50687 }
50688
50689 int64_t  CS_LDK_ChannelFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50690         LDKChannelFeatures this_arg_conv;
50691         this_arg_conv.inner = untag_ptr(this_arg);
50692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50694         this_arg_conv.is_owned = false;
50695         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50696         *ret_conv = ChannelFeatures_set_required_feature_bit(&this_arg_conv, bit);
50697         return tag_ptr(ret_conv, true);
50698 }
50699
50700 int64_t  CS_LDK_ChannelFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50701         LDKChannelFeatures this_arg_conv;
50702         this_arg_conv.inner = untag_ptr(this_arg);
50703         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50705         this_arg_conv.is_owned = false;
50706         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50707         *ret_conv = ChannelFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50708         return tag_ptr(ret_conv, true);
50709 }
50710
50711 int64_t  CS_LDK_ChannelFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50712         LDKChannelFeatures this_arg_conv;
50713         this_arg_conv.inner = untag_ptr(this_arg);
50714         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50716         this_arg_conv.is_owned = false;
50717         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50718         *ret_conv = ChannelFeatures_set_required_custom_bit(&this_arg_conv, bit);
50719         return tag_ptr(ret_conv, true);
50720 }
50721
50722 int64_t  CS_LDK_ChannelFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50723         LDKChannelFeatures this_arg_conv;
50724         this_arg_conv.inner = untag_ptr(this_arg);
50725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50727         this_arg_conv.is_owned = false;
50728         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50729         *ret_conv = ChannelFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50730         return tag_ptr(ret_conv, true);
50731 }
50732
50733 int64_t  CS_LDK_Bolt11InvoiceFeatures_empty() {
50734         LDKBolt11InvoiceFeatures ret_var = Bolt11InvoiceFeatures_empty();
50735         int64_t ret_ref = 0;
50736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50738         return ret_ref;
50739 }
50740
50741 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50742         LDKBolt11InvoiceFeatures this_arg_conv;
50743         this_arg_conv.inner = untag_ptr(this_arg);
50744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50746         this_arg_conv.is_owned = false;
50747         LDKBolt11InvoiceFeatures other_conv;
50748         other_conv.inner = untag_ptr(other);
50749         other_conv.is_owned = ptr_is_owned(other);
50750         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50751         other_conv.is_owned = false;
50752         jboolean ret_conv = Bolt11InvoiceFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50753         return ret_conv;
50754 }
50755
50756 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_unknown_bits(int64_t this_arg) {
50757         LDKBolt11InvoiceFeatures this_arg_conv;
50758         this_arg_conv.inner = untag_ptr(this_arg);
50759         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50761         this_arg_conv.is_owned = false;
50762         jboolean ret_conv = Bolt11InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
50763         return ret_conv;
50764 }
50765
50766 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50767         LDKBolt11InvoiceFeatures this_arg_conv;
50768         this_arg_conv.inner = untag_ptr(this_arg);
50769         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50771         this_arg_conv.is_owned = false;
50772         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50773         *ret_conv = Bolt11InvoiceFeatures_set_required_feature_bit(&this_arg_conv, bit);
50774         return tag_ptr(ret_conv, true);
50775 }
50776
50777 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50778         LDKBolt11InvoiceFeatures this_arg_conv;
50779         this_arg_conv.inner = untag_ptr(this_arg);
50780         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50782         this_arg_conv.is_owned = false;
50783         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50784         *ret_conv = Bolt11InvoiceFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50785         return tag_ptr(ret_conv, true);
50786 }
50787
50788 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50789         LDKBolt11InvoiceFeatures this_arg_conv;
50790         this_arg_conv.inner = untag_ptr(this_arg);
50791         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50793         this_arg_conv.is_owned = false;
50794         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50795         *ret_conv = Bolt11InvoiceFeatures_set_required_custom_bit(&this_arg_conv, bit);
50796         return tag_ptr(ret_conv, true);
50797 }
50798
50799 int64_t  CS_LDK_Bolt11InvoiceFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50800         LDKBolt11InvoiceFeatures this_arg_conv;
50801         this_arg_conv.inner = untag_ptr(this_arg);
50802         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50804         this_arg_conv.is_owned = false;
50805         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50806         *ret_conv = Bolt11InvoiceFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50807         return tag_ptr(ret_conv, true);
50808 }
50809
50810 int64_t  CS_LDK_OfferFeatures_empty() {
50811         LDKOfferFeatures ret_var = OfferFeatures_empty();
50812         int64_t ret_ref = 0;
50813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50815         return ret_ref;
50816 }
50817
50818 jboolean  CS_LDK_OfferFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50819         LDKOfferFeatures this_arg_conv;
50820         this_arg_conv.inner = untag_ptr(this_arg);
50821         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50823         this_arg_conv.is_owned = false;
50824         LDKOfferFeatures other_conv;
50825         other_conv.inner = untag_ptr(other);
50826         other_conv.is_owned = ptr_is_owned(other);
50827         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50828         other_conv.is_owned = false;
50829         jboolean ret_conv = OfferFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50830         return ret_conv;
50831 }
50832
50833 jboolean  CS_LDK_OfferFeatures_requires_unknown_bits(int64_t this_arg) {
50834         LDKOfferFeatures this_arg_conv;
50835         this_arg_conv.inner = untag_ptr(this_arg);
50836         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50838         this_arg_conv.is_owned = false;
50839         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
50840         return ret_conv;
50841 }
50842
50843 int64_t  CS_LDK_OfferFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50844         LDKOfferFeatures this_arg_conv;
50845         this_arg_conv.inner = untag_ptr(this_arg);
50846         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50848         this_arg_conv.is_owned = false;
50849         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50850         *ret_conv = OfferFeatures_set_required_feature_bit(&this_arg_conv, bit);
50851         return tag_ptr(ret_conv, true);
50852 }
50853
50854 int64_t  CS_LDK_OfferFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50855         LDKOfferFeatures this_arg_conv;
50856         this_arg_conv.inner = untag_ptr(this_arg);
50857         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50859         this_arg_conv.is_owned = false;
50860         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50861         *ret_conv = OfferFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50862         return tag_ptr(ret_conv, true);
50863 }
50864
50865 int64_t  CS_LDK_OfferFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50866         LDKOfferFeatures this_arg_conv;
50867         this_arg_conv.inner = untag_ptr(this_arg);
50868         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50870         this_arg_conv.is_owned = false;
50871         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50872         *ret_conv = OfferFeatures_set_required_custom_bit(&this_arg_conv, bit);
50873         return tag_ptr(ret_conv, true);
50874 }
50875
50876 int64_t  CS_LDK_OfferFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50877         LDKOfferFeatures this_arg_conv;
50878         this_arg_conv.inner = untag_ptr(this_arg);
50879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50881         this_arg_conv.is_owned = false;
50882         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50883         *ret_conv = OfferFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50884         return tag_ptr(ret_conv, true);
50885 }
50886
50887 int64_t  CS_LDK_InvoiceRequestFeatures_empty() {
50888         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
50889         int64_t ret_ref = 0;
50890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50892         return ret_ref;
50893 }
50894
50895 jboolean  CS_LDK_InvoiceRequestFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50896         LDKInvoiceRequestFeatures this_arg_conv;
50897         this_arg_conv.inner = untag_ptr(this_arg);
50898         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50900         this_arg_conv.is_owned = false;
50901         LDKInvoiceRequestFeatures other_conv;
50902         other_conv.inner = untag_ptr(other);
50903         other_conv.is_owned = ptr_is_owned(other);
50904         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50905         other_conv.is_owned = false;
50906         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50907         return ret_conv;
50908 }
50909
50910 jboolean  CS_LDK_InvoiceRequestFeatures_requires_unknown_bits(int64_t this_arg) {
50911         LDKInvoiceRequestFeatures this_arg_conv;
50912         this_arg_conv.inner = untag_ptr(this_arg);
50913         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50915         this_arg_conv.is_owned = false;
50916         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
50917         return ret_conv;
50918 }
50919
50920 int64_t  CS_LDK_InvoiceRequestFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50921         LDKInvoiceRequestFeatures this_arg_conv;
50922         this_arg_conv.inner = untag_ptr(this_arg);
50923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50925         this_arg_conv.is_owned = false;
50926         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50927         *ret_conv = InvoiceRequestFeatures_set_required_feature_bit(&this_arg_conv, bit);
50928         return tag_ptr(ret_conv, true);
50929 }
50930
50931 int64_t  CS_LDK_InvoiceRequestFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
50932         LDKInvoiceRequestFeatures this_arg_conv;
50933         this_arg_conv.inner = untag_ptr(this_arg);
50934         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50936         this_arg_conv.is_owned = false;
50937         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50938         *ret_conv = InvoiceRequestFeatures_set_optional_feature_bit(&this_arg_conv, bit);
50939         return tag_ptr(ret_conv, true);
50940 }
50941
50942 int64_t  CS_LDK_InvoiceRequestFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
50943         LDKInvoiceRequestFeatures this_arg_conv;
50944         this_arg_conv.inner = untag_ptr(this_arg);
50945         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50947         this_arg_conv.is_owned = false;
50948         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50949         *ret_conv = InvoiceRequestFeatures_set_required_custom_bit(&this_arg_conv, bit);
50950         return tag_ptr(ret_conv, true);
50951 }
50952
50953 int64_t  CS_LDK_InvoiceRequestFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
50954         LDKInvoiceRequestFeatures this_arg_conv;
50955         this_arg_conv.inner = untag_ptr(this_arg);
50956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50958         this_arg_conv.is_owned = false;
50959         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
50960         *ret_conv = InvoiceRequestFeatures_set_optional_custom_bit(&this_arg_conv, bit);
50961         return tag_ptr(ret_conv, true);
50962 }
50963
50964 int64_t  CS_LDK_Bolt12InvoiceFeatures_empty() {
50965         LDKBolt12InvoiceFeatures ret_var = Bolt12InvoiceFeatures_empty();
50966         int64_t ret_ref = 0;
50967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50969         return ret_ref;
50970 }
50971
50972 jboolean  CS_LDK_Bolt12InvoiceFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
50973         LDKBolt12InvoiceFeatures this_arg_conv;
50974         this_arg_conv.inner = untag_ptr(this_arg);
50975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50977         this_arg_conv.is_owned = false;
50978         LDKBolt12InvoiceFeatures other_conv;
50979         other_conv.inner = untag_ptr(other);
50980         other_conv.is_owned = ptr_is_owned(other);
50981         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
50982         other_conv.is_owned = false;
50983         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
50984         return ret_conv;
50985 }
50986
50987 jboolean  CS_LDK_Bolt12InvoiceFeatures_requires_unknown_bits(int64_t this_arg) {
50988         LDKBolt12InvoiceFeatures this_arg_conv;
50989         this_arg_conv.inner = untag_ptr(this_arg);
50990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50992         this_arg_conv.is_owned = false;
50993         jboolean ret_conv = Bolt12InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
50994         return ret_conv;
50995 }
50996
50997 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
50998         LDKBolt12InvoiceFeatures this_arg_conv;
50999         this_arg_conv.inner = untag_ptr(this_arg);
51000         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51002         this_arg_conv.is_owned = false;
51003         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51004         *ret_conv = Bolt12InvoiceFeatures_set_required_feature_bit(&this_arg_conv, bit);
51005         return tag_ptr(ret_conv, true);
51006 }
51007
51008 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
51009         LDKBolt12InvoiceFeatures this_arg_conv;
51010         this_arg_conv.inner = untag_ptr(this_arg);
51011         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51013         this_arg_conv.is_owned = false;
51014         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51015         *ret_conv = Bolt12InvoiceFeatures_set_optional_feature_bit(&this_arg_conv, bit);
51016         return tag_ptr(ret_conv, true);
51017 }
51018
51019 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
51020         LDKBolt12InvoiceFeatures this_arg_conv;
51021         this_arg_conv.inner = untag_ptr(this_arg);
51022         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51024         this_arg_conv.is_owned = false;
51025         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51026         *ret_conv = Bolt12InvoiceFeatures_set_required_custom_bit(&this_arg_conv, bit);
51027         return tag_ptr(ret_conv, true);
51028 }
51029
51030 int64_t  CS_LDK_Bolt12InvoiceFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
51031         LDKBolt12InvoiceFeatures this_arg_conv;
51032         this_arg_conv.inner = untag_ptr(this_arg);
51033         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51035         this_arg_conv.is_owned = false;
51036         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51037         *ret_conv = Bolt12InvoiceFeatures_set_optional_custom_bit(&this_arg_conv, bit);
51038         return tag_ptr(ret_conv, true);
51039 }
51040
51041 int64_t  CS_LDK_BlindedHopFeatures_empty() {
51042         LDKBlindedHopFeatures ret_var = BlindedHopFeatures_empty();
51043         int64_t ret_ref = 0;
51044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51045         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51046         return ret_ref;
51047 }
51048
51049 jboolean  CS_LDK_BlindedHopFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
51050         LDKBlindedHopFeatures this_arg_conv;
51051         this_arg_conv.inner = untag_ptr(this_arg);
51052         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51054         this_arg_conv.is_owned = false;
51055         LDKBlindedHopFeatures other_conv;
51056         other_conv.inner = untag_ptr(other);
51057         other_conv.is_owned = ptr_is_owned(other);
51058         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
51059         other_conv.is_owned = false;
51060         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
51061         return ret_conv;
51062 }
51063
51064 jboolean  CS_LDK_BlindedHopFeatures_requires_unknown_bits(int64_t this_arg) {
51065         LDKBlindedHopFeatures this_arg_conv;
51066         this_arg_conv.inner = untag_ptr(this_arg);
51067         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51069         this_arg_conv.is_owned = false;
51070         jboolean ret_conv = BlindedHopFeatures_requires_unknown_bits(&this_arg_conv);
51071         return ret_conv;
51072 }
51073
51074 int64_t  CS_LDK_BlindedHopFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
51075         LDKBlindedHopFeatures this_arg_conv;
51076         this_arg_conv.inner = untag_ptr(this_arg);
51077         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51079         this_arg_conv.is_owned = false;
51080         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51081         *ret_conv = BlindedHopFeatures_set_required_feature_bit(&this_arg_conv, bit);
51082         return tag_ptr(ret_conv, true);
51083 }
51084
51085 int64_t  CS_LDK_BlindedHopFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
51086         LDKBlindedHopFeatures this_arg_conv;
51087         this_arg_conv.inner = untag_ptr(this_arg);
51088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51090         this_arg_conv.is_owned = false;
51091         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51092         *ret_conv = BlindedHopFeatures_set_optional_feature_bit(&this_arg_conv, bit);
51093         return tag_ptr(ret_conv, true);
51094 }
51095
51096 int64_t  CS_LDK_BlindedHopFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
51097         LDKBlindedHopFeatures this_arg_conv;
51098         this_arg_conv.inner = untag_ptr(this_arg);
51099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51101         this_arg_conv.is_owned = false;
51102         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51103         *ret_conv = BlindedHopFeatures_set_required_custom_bit(&this_arg_conv, bit);
51104         return tag_ptr(ret_conv, true);
51105 }
51106
51107 int64_t  CS_LDK_BlindedHopFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
51108         LDKBlindedHopFeatures this_arg_conv;
51109         this_arg_conv.inner = untag_ptr(this_arg);
51110         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51112         this_arg_conv.is_owned = false;
51113         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51114         *ret_conv = BlindedHopFeatures_set_optional_custom_bit(&this_arg_conv, bit);
51115         return tag_ptr(ret_conv, true);
51116 }
51117
51118 int64_t  CS_LDK_ChannelTypeFeatures_empty() {
51119         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
51120         int64_t ret_ref = 0;
51121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51123         return ret_ref;
51124 }
51125
51126 jboolean  CS_LDK_ChannelTypeFeatures_requires_unknown_bits_from(int64_t this_arg, int64_t other) {
51127         LDKChannelTypeFeatures this_arg_conv;
51128         this_arg_conv.inner = untag_ptr(this_arg);
51129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51131         this_arg_conv.is_owned = false;
51132         LDKChannelTypeFeatures other_conv;
51133         other_conv.inner = untag_ptr(other);
51134         other_conv.is_owned = ptr_is_owned(other);
51135         CHECK_INNER_FIELD_ACCESS_OR_NULL(other_conv);
51136         other_conv.is_owned = false;
51137         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits_from(&this_arg_conv, &other_conv);
51138         return ret_conv;
51139 }
51140
51141 jboolean  CS_LDK_ChannelTypeFeatures_requires_unknown_bits(int64_t this_arg) {
51142         LDKChannelTypeFeatures this_arg_conv;
51143         this_arg_conv.inner = untag_ptr(this_arg);
51144         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51146         this_arg_conv.is_owned = false;
51147         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
51148         return ret_conv;
51149 }
51150
51151 int64_t  CS_LDK_ChannelTypeFeatures_set_required_feature_bit(int64_t this_arg, int64_t bit) {
51152         LDKChannelTypeFeatures this_arg_conv;
51153         this_arg_conv.inner = untag_ptr(this_arg);
51154         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51156         this_arg_conv.is_owned = false;
51157         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51158         *ret_conv = ChannelTypeFeatures_set_required_feature_bit(&this_arg_conv, bit);
51159         return tag_ptr(ret_conv, true);
51160 }
51161
51162 int64_t  CS_LDK_ChannelTypeFeatures_set_optional_feature_bit(int64_t this_arg, int64_t bit) {
51163         LDKChannelTypeFeatures this_arg_conv;
51164         this_arg_conv.inner = untag_ptr(this_arg);
51165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51167         this_arg_conv.is_owned = false;
51168         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51169         *ret_conv = ChannelTypeFeatures_set_optional_feature_bit(&this_arg_conv, bit);
51170         return tag_ptr(ret_conv, true);
51171 }
51172
51173 int64_t  CS_LDK_ChannelTypeFeatures_set_required_custom_bit(int64_t this_arg, int64_t bit) {
51174         LDKChannelTypeFeatures this_arg_conv;
51175         this_arg_conv.inner = untag_ptr(this_arg);
51176         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51178         this_arg_conv.is_owned = false;
51179         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51180         *ret_conv = ChannelTypeFeatures_set_required_custom_bit(&this_arg_conv, bit);
51181         return tag_ptr(ret_conv, true);
51182 }
51183
51184 int64_t  CS_LDK_ChannelTypeFeatures_set_optional_custom_bit(int64_t this_arg, int64_t bit) {
51185         LDKChannelTypeFeatures this_arg_conv;
51186         this_arg_conv.inner = untag_ptr(this_arg);
51187         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51189         this_arg_conv.is_owned = false;
51190         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
51191         *ret_conv = ChannelTypeFeatures_set_optional_custom_bit(&this_arg_conv, bit);
51192         return tag_ptr(ret_conv, true);
51193 }
51194
51195 int8_tArray  CS_LDK_InitFeatures_write(int64_t obj) {
51196         LDKInitFeatures obj_conv;
51197         obj_conv.inner = untag_ptr(obj);
51198         obj_conv.is_owned = ptr_is_owned(obj);
51199         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51200         obj_conv.is_owned = false;
51201         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
51202         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51203         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51204         CVec_u8Z_free(ret_var);
51205         return ret_arr;
51206 }
51207
51208 int64_t  CS_LDK_InitFeatures_read(int8_tArray ser) {
51209         LDKu8slice ser_ref;
51210         ser_ref.datalen = ser->arr_len;
51211         ser_ref.data = ser->elems;
51212         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
51213         *ret_conv = InitFeatures_read(ser_ref);
51214         FREE(ser);
51215         return tag_ptr(ret_conv, true);
51216 }
51217
51218 int8_tArray  CS_LDK_ChannelFeatures_write(int64_t obj) {
51219         LDKChannelFeatures obj_conv;
51220         obj_conv.inner = untag_ptr(obj);
51221         obj_conv.is_owned = ptr_is_owned(obj);
51222         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51223         obj_conv.is_owned = false;
51224         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
51225         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51226         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51227         CVec_u8Z_free(ret_var);
51228         return ret_arr;
51229 }
51230
51231 int64_t  CS_LDK_ChannelFeatures_read(int8_tArray ser) {
51232         LDKu8slice ser_ref;
51233         ser_ref.datalen = ser->arr_len;
51234         ser_ref.data = ser->elems;
51235         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
51236         *ret_conv = ChannelFeatures_read(ser_ref);
51237         FREE(ser);
51238         return tag_ptr(ret_conv, true);
51239 }
51240
51241 int8_tArray  CS_LDK_NodeFeatures_write(int64_t obj) {
51242         LDKNodeFeatures obj_conv;
51243         obj_conv.inner = untag_ptr(obj);
51244         obj_conv.is_owned = ptr_is_owned(obj);
51245         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51246         obj_conv.is_owned = false;
51247         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
51248         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51249         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51250         CVec_u8Z_free(ret_var);
51251         return ret_arr;
51252 }
51253
51254 int64_t  CS_LDK_NodeFeatures_read(int8_tArray ser) {
51255         LDKu8slice ser_ref;
51256         ser_ref.datalen = ser->arr_len;
51257         ser_ref.data = ser->elems;
51258         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
51259         *ret_conv = NodeFeatures_read(ser_ref);
51260         FREE(ser);
51261         return tag_ptr(ret_conv, true);
51262 }
51263
51264 int8_tArray  CS_LDK_Bolt11InvoiceFeatures_write(int64_t obj) {
51265         LDKBolt11InvoiceFeatures obj_conv;
51266         obj_conv.inner = untag_ptr(obj);
51267         obj_conv.is_owned = ptr_is_owned(obj);
51268         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51269         obj_conv.is_owned = false;
51270         LDKCVec_u8Z ret_var = Bolt11InvoiceFeatures_write(&obj_conv);
51271         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51272         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51273         CVec_u8Z_free(ret_var);
51274         return ret_arr;
51275 }
51276
51277 int64_t  CS_LDK_Bolt11InvoiceFeatures_read(int8_tArray ser) {
51278         LDKu8slice ser_ref;
51279         ser_ref.datalen = ser->arr_len;
51280         ser_ref.data = ser->elems;
51281         LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt11InvoiceFeaturesDecodeErrorZ");
51282         *ret_conv = Bolt11InvoiceFeatures_read(ser_ref);
51283         FREE(ser);
51284         return tag_ptr(ret_conv, true);
51285 }
51286
51287 int8_tArray  CS_LDK_Bolt12InvoiceFeatures_write(int64_t obj) {
51288         LDKBolt12InvoiceFeatures obj_conv;
51289         obj_conv.inner = untag_ptr(obj);
51290         obj_conv.is_owned = ptr_is_owned(obj);
51291         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51292         obj_conv.is_owned = false;
51293         LDKCVec_u8Z ret_var = Bolt12InvoiceFeatures_write(&obj_conv);
51294         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51295         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51296         CVec_u8Z_free(ret_var);
51297         return ret_arr;
51298 }
51299
51300 int64_t  CS_LDK_Bolt12InvoiceFeatures_read(int8_tArray ser) {
51301         LDKu8slice ser_ref;
51302         ser_ref.datalen = ser->arr_len;
51303         ser_ref.data = ser->elems;
51304         LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ), "LDKCResult_Bolt12InvoiceFeaturesDecodeErrorZ");
51305         *ret_conv = Bolt12InvoiceFeatures_read(ser_ref);
51306         FREE(ser);
51307         return tag_ptr(ret_conv, true);
51308 }
51309
51310 int8_tArray  CS_LDK_BlindedHopFeatures_write(int64_t obj) {
51311         LDKBlindedHopFeatures obj_conv;
51312         obj_conv.inner = untag_ptr(obj);
51313         obj_conv.is_owned = ptr_is_owned(obj);
51314         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51315         obj_conv.is_owned = false;
51316         LDKCVec_u8Z ret_var = BlindedHopFeatures_write(&obj_conv);
51317         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51318         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51319         CVec_u8Z_free(ret_var);
51320         return ret_arr;
51321 }
51322
51323 int64_t  CS_LDK_BlindedHopFeatures_read(int8_tArray ser) {
51324         LDKu8slice ser_ref;
51325         ser_ref.datalen = ser->arr_len;
51326         ser_ref.data = ser->elems;
51327         LDKCResult_BlindedHopFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopFeaturesDecodeErrorZ), "LDKCResult_BlindedHopFeaturesDecodeErrorZ");
51328         *ret_conv = BlindedHopFeatures_read(ser_ref);
51329         FREE(ser);
51330         return tag_ptr(ret_conv, true);
51331 }
51332
51333 int8_tArray  CS_LDK_ChannelTypeFeatures_write(int64_t obj) {
51334         LDKChannelTypeFeatures obj_conv;
51335         obj_conv.inner = untag_ptr(obj);
51336         obj_conv.is_owned = ptr_is_owned(obj);
51337         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
51338         obj_conv.is_owned = false;
51339         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
51340         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
51341         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
51342         CVec_u8Z_free(ret_var);
51343         return ret_arr;
51344 }
51345
51346 int64_t  CS_LDK_ChannelTypeFeatures_read(int8_tArray ser) {
51347         LDKu8slice ser_ref;
51348         ser_ref.datalen = ser->arr_len;
51349         ser_ref.data = ser->elems;
51350         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
51351         *ret_conv = ChannelTypeFeatures_read(ser_ref);
51352         FREE(ser);
51353         return tag_ptr(ret_conv, true);
51354 }
51355
51356 void  CS_LDK_InitFeatures_set_data_loss_protect_optional(int64_t this_arg) {
51357         LDKInitFeatures this_arg_conv;
51358         this_arg_conv.inner = untag_ptr(this_arg);
51359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51361         this_arg_conv.is_owned = false;
51362         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
51363 }
51364
51365 void  CS_LDK_InitFeatures_set_data_loss_protect_required(int64_t this_arg) {
51366         LDKInitFeatures this_arg_conv;
51367         this_arg_conv.inner = untag_ptr(this_arg);
51368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51370         this_arg_conv.is_owned = false;
51371         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
51372 }
51373
51374 jboolean  CS_LDK_InitFeatures_supports_data_loss_protect(int64_t this_arg) {
51375         LDKInitFeatures this_arg_conv;
51376         this_arg_conv.inner = untag_ptr(this_arg);
51377         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51379         this_arg_conv.is_owned = false;
51380         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
51381         return ret_conv;
51382 }
51383
51384 void  CS_LDK_NodeFeatures_set_data_loss_protect_optional(int64_t this_arg) {
51385         LDKNodeFeatures this_arg_conv;
51386         this_arg_conv.inner = untag_ptr(this_arg);
51387         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51389         this_arg_conv.is_owned = false;
51390         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
51391 }
51392
51393 void  CS_LDK_NodeFeatures_set_data_loss_protect_required(int64_t this_arg) {
51394         LDKNodeFeatures this_arg_conv;
51395         this_arg_conv.inner = untag_ptr(this_arg);
51396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51398         this_arg_conv.is_owned = false;
51399         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
51400 }
51401
51402 jboolean  CS_LDK_NodeFeatures_supports_data_loss_protect(int64_t this_arg) {
51403         LDKNodeFeatures this_arg_conv;
51404         this_arg_conv.inner = untag_ptr(this_arg);
51405         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51407         this_arg_conv.is_owned = false;
51408         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
51409         return ret_conv;
51410 }
51411
51412 jboolean  CS_LDK_InitFeatures_requires_data_loss_protect(int64_t this_arg) {
51413         LDKInitFeatures this_arg_conv;
51414         this_arg_conv.inner = untag_ptr(this_arg);
51415         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51417         this_arg_conv.is_owned = false;
51418         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
51419         return ret_conv;
51420 }
51421
51422 jboolean  CS_LDK_NodeFeatures_requires_data_loss_protect(int64_t this_arg) {
51423         LDKNodeFeatures this_arg_conv;
51424         this_arg_conv.inner = untag_ptr(this_arg);
51425         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51427         this_arg_conv.is_owned = false;
51428         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
51429         return ret_conv;
51430 }
51431
51432 void  CS_LDK_InitFeatures_set_initial_routing_sync_optional(int64_t this_arg) {
51433         LDKInitFeatures this_arg_conv;
51434         this_arg_conv.inner = untag_ptr(this_arg);
51435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51437         this_arg_conv.is_owned = false;
51438         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
51439 }
51440
51441 void  CS_LDK_InitFeatures_set_initial_routing_sync_required(int64_t this_arg) {
51442         LDKInitFeatures this_arg_conv;
51443         this_arg_conv.inner = untag_ptr(this_arg);
51444         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51446         this_arg_conv.is_owned = false;
51447         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
51448 }
51449
51450 jboolean  CS_LDK_InitFeatures_initial_routing_sync(int64_t this_arg) {
51451         LDKInitFeatures this_arg_conv;
51452         this_arg_conv.inner = untag_ptr(this_arg);
51453         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51455         this_arg_conv.is_owned = false;
51456         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
51457         return ret_conv;
51458 }
51459
51460 void  CS_LDK_InitFeatures_set_upfront_shutdown_script_optional(int64_t this_arg) {
51461         LDKInitFeatures this_arg_conv;
51462         this_arg_conv.inner = untag_ptr(this_arg);
51463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51465         this_arg_conv.is_owned = false;
51466         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
51467 }
51468
51469 void  CS_LDK_InitFeatures_set_upfront_shutdown_script_required(int64_t this_arg) {
51470         LDKInitFeatures this_arg_conv;
51471         this_arg_conv.inner = untag_ptr(this_arg);
51472         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51474         this_arg_conv.is_owned = false;
51475         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
51476 }
51477
51478 jboolean  CS_LDK_InitFeatures_supports_upfront_shutdown_script(int64_t this_arg) {
51479         LDKInitFeatures this_arg_conv;
51480         this_arg_conv.inner = untag_ptr(this_arg);
51481         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51483         this_arg_conv.is_owned = false;
51484         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
51485         return ret_conv;
51486 }
51487
51488 void  CS_LDK_NodeFeatures_set_upfront_shutdown_script_optional(int64_t this_arg) {
51489         LDKNodeFeatures this_arg_conv;
51490         this_arg_conv.inner = untag_ptr(this_arg);
51491         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51493         this_arg_conv.is_owned = false;
51494         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
51495 }
51496
51497 void  CS_LDK_NodeFeatures_set_upfront_shutdown_script_required(int64_t this_arg) {
51498         LDKNodeFeatures this_arg_conv;
51499         this_arg_conv.inner = untag_ptr(this_arg);
51500         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51502         this_arg_conv.is_owned = false;
51503         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
51504 }
51505
51506 jboolean  CS_LDK_NodeFeatures_supports_upfront_shutdown_script(int64_t this_arg) {
51507         LDKNodeFeatures this_arg_conv;
51508         this_arg_conv.inner = untag_ptr(this_arg);
51509         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51511         this_arg_conv.is_owned = false;
51512         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
51513         return ret_conv;
51514 }
51515
51516 jboolean  CS_LDK_InitFeatures_requires_upfront_shutdown_script(int64_t this_arg) {
51517         LDKInitFeatures this_arg_conv;
51518         this_arg_conv.inner = untag_ptr(this_arg);
51519         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51521         this_arg_conv.is_owned = false;
51522         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
51523         return ret_conv;
51524 }
51525
51526 jboolean  CS_LDK_NodeFeatures_requires_upfront_shutdown_script(int64_t this_arg) {
51527         LDKNodeFeatures this_arg_conv;
51528         this_arg_conv.inner = untag_ptr(this_arg);
51529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51531         this_arg_conv.is_owned = false;
51532         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
51533         return ret_conv;
51534 }
51535
51536 void  CS_LDK_InitFeatures_set_gossip_queries_optional(int64_t this_arg) {
51537         LDKInitFeatures this_arg_conv;
51538         this_arg_conv.inner = untag_ptr(this_arg);
51539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51541         this_arg_conv.is_owned = false;
51542         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
51543 }
51544
51545 void  CS_LDK_InitFeatures_set_gossip_queries_required(int64_t this_arg) {
51546         LDKInitFeatures this_arg_conv;
51547         this_arg_conv.inner = untag_ptr(this_arg);
51548         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51550         this_arg_conv.is_owned = false;
51551         InitFeatures_set_gossip_queries_required(&this_arg_conv);
51552 }
51553
51554 jboolean  CS_LDK_InitFeatures_supports_gossip_queries(int64_t this_arg) {
51555         LDKInitFeatures this_arg_conv;
51556         this_arg_conv.inner = untag_ptr(this_arg);
51557         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51559         this_arg_conv.is_owned = false;
51560         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
51561         return ret_conv;
51562 }
51563
51564 void  CS_LDK_NodeFeatures_set_gossip_queries_optional(int64_t this_arg) {
51565         LDKNodeFeatures this_arg_conv;
51566         this_arg_conv.inner = untag_ptr(this_arg);
51567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51569         this_arg_conv.is_owned = false;
51570         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
51571 }
51572
51573 void  CS_LDK_NodeFeatures_set_gossip_queries_required(int64_t this_arg) {
51574         LDKNodeFeatures this_arg_conv;
51575         this_arg_conv.inner = untag_ptr(this_arg);
51576         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51578         this_arg_conv.is_owned = false;
51579         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
51580 }
51581
51582 jboolean  CS_LDK_NodeFeatures_supports_gossip_queries(int64_t this_arg) {
51583         LDKNodeFeatures this_arg_conv;
51584         this_arg_conv.inner = untag_ptr(this_arg);
51585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51587         this_arg_conv.is_owned = false;
51588         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
51589         return ret_conv;
51590 }
51591
51592 jboolean  CS_LDK_InitFeatures_requires_gossip_queries(int64_t this_arg) {
51593         LDKInitFeatures this_arg_conv;
51594         this_arg_conv.inner = untag_ptr(this_arg);
51595         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51597         this_arg_conv.is_owned = false;
51598         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
51599         return ret_conv;
51600 }
51601
51602 jboolean  CS_LDK_NodeFeatures_requires_gossip_queries(int64_t this_arg) {
51603         LDKNodeFeatures this_arg_conv;
51604         this_arg_conv.inner = untag_ptr(this_arg);
51605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51607         this_arg_conv.is_owned = false;
51608         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
51609         return ret_conv;
51610 }
51611
51612 void  CS_LDK_InitFeatures_set_variable_length_onion_optional(int64_t this_arg) {
51613         LDKInitFeatures this_arg_conv;
51614         this_arg_conv.inner = untag_ptr(this_arg);
51615         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51617         this_arg_conv.is_owned = false;
51618         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
51619 }
51620
51621 void  CS_LDK_InitFeatures_set_variable_length_onion_required(int64_t this_arg) {
51622         LDKInitFeatures this_arg_conv;
51623         this_arg_conv.inner = untag_ptr(this_arg);
51624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51626         this_arg_conv.is_owned = false;
51627         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
51628 }
51629
51630 jboolean  CS_LDK_InitFeatures_supports_variable_length_onion(int64_t this_arg) {
51631         LDKInitFeatures this_arg_conv;
51632         this_arg_conv.inner = untag_ptr(this_arg);
51633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51635         this_arg_conv.is_owned = false;
51636         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
51637         return ret_conv;
51638 }
51639
51640 void  CS_LDK_NodeFeatures_set_variable_length_onion_optional(int64_t this_arg) {
51641         LDKNodeFeatures this_arg_conv;
51642         this_arg_conv.inner = untag_ptr(this_arg);
51643         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51645         this_arg_conv.is_owned = false;
51646         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
51647 }
51648
51649 void  CS_LDK_NodeFeatures_set_variable_length_onion_required(int64_t this_arg) {
51650         LDKNodeFeatures this_arg_conv;
51651         this_arg_conv.inner = untag_ptr(this_arg);
51652         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51654         this_arg_conv.is_owned = false;
51655         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
51656 }
51657
51658 jboolean  CS_LDK_NodeFeatures_supports_variable_length_onion(int64_t this_arg) {
51659         LDKNodeFeatures this_arg_conv;
51660         this_arg_conv.inner = untag_ptr(this_arg);
51661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51663         this_arg_conv.is_owned = false;
51664         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
51665         return ret_conv;
51666 }
51667
51668 void  CS_LDK_Bolt11InvoiceFeatures_set_variable_length_onion_optional(int64_t this_arg) {
51669         LDKBolt11InvoiceFeatures this_arg_conv;
51670         this_arg_conv.inner = untag_ptr(this_arg);
51671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51673         this_arg_conv.is_owned = false;
51674         Bolt11InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
51675 }
51676
51677 void  CS_LDK_Bolt11InvoiceFeatures_set_variable_length_onion_required(int64_t this_arg) {
51678         LDKBolt11InvoiceFeatures this_arg_conv;
51679         this_arg_conv.inner = untag_ptr(this_arg);
51680         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51682         this_arg_conv.is_owned = false;
51683         Bolt11InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
51684 }
51685
51686 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_variable_length_onion(int64_t this_arg) {
51687         LDKBolt11InvoiceFeatures this_arg_conv;
51688         this_arg_conv.inner = untag_ptr(this_arg);
51689         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51691         this_arg_conv.is_owned = false;
51692         jboolean ret_conv = Bolt11InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
51693         return ret_conv;
51694 }
51695
51696 jboolean  CS_LDK_InitFeatures_requires_variable_length_onion(int64_t this_arg) {
51697         LDKInitFeatures this_arg_conv;
51698         this_arg_conv.inner = untag_ptr(this_arg);
51699         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51701         this_arg_conv.is_owned = false;
51702         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
51703         return ret_conv;
51704 }
51705
51706 jboolean  CS_LDK_NodeFeatures_requires_variable_length_onion(int64_t this_arg) {
51707         LDKNodeFeatures this_arg_conv;
51708         this_arg_conv.inner = untag_ptr(this_arg);
51709         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51711         this_arg_conv.is_owned = false;
51712         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
51713         return ret_conv;
51714 }
51715
51716 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_variable_length_onion(int64_t this_arg) {
51717         LDKBolt11InvoiceFeatures this_arg_conv;
51718         this_arg_conv.inner = untag_ptr(this_arg);
51719         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51721         this_arg_conv.is_owned = false;
51722         jboolean ret_conv = Bolt11InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
51723         return ret_conv;
51724 }
51725
51726 void  CS_LDK_InitFeatures_set_static_remote_key_optional(int64_t this_arg) {
51727         LDKInitFeatures this_arg_conv;
51728         this_arg_conv.inner = untag_ptr(this_arg);
51729         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51731         this_arg_conv.is_owned = false;
51732         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
51733 }
51734
51735 void  CS_LDK_InitFeatures_set_static_remote_key_required(int64_t this_arg) {
51736         LDKInitFeatures this_arg_conv;
51737         this_arg_conv.inner = untag_ptr(this_arg);
51738         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51740         this_arg_conv.is_owned = false;
51741         InitFeatures_set_static_remote_key_required(&this_arg_conv);
51742 }
51743
51744 jboolean  CS_LDK_InitFeatures_supports_static_remote_key(int64_t this_arg) {
51745         LDKInitFeatures this_arg_conv;
51746         this_arg_conv.inner = untag_ptr(this_arg);
51747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51749         this_arg_conv.is_owned = false;
51750         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
51751         return ret_conv;
51752 }
51753
51754 void  CS_LDK_NodeFeatures_set_static_remote_key_optional(int64_t this_arg) {
51755         LDKNodeFeatures this_arg_conv;
51756         this_arg_conv.inner = untag_ptr(this_arg);
51757         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51759         this_arg_conv.is_owned = false;
51760         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
51761 }
51762
51763 void  CS_LDK_NodeFeatures_set_static_remote_key_required(int64_t this_arg) {
51764         LDKNodeFeatures this_arg_conv;
51765         this_arg_conv.inner = untag_ptr(this_arg);
51766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51768         this_arg_conv.is_owned = false;
51769         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
51770 }
51771
51772 jboolean  CS_LDK_NodeFeatures_supports_static_remote_key(int64_t this_arg) {
51773         LDKNodeFeatures this_arg_conv;
51774         this_arg_conv.inner = untag_ptr(this_arg);
51775         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51777         this_arg_conv.is_owned = false;
51778         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
51779         return ret_conv;
51780 }
51781
51782 void  CS_LDK_ChannelTypeFeatures_set_static_remote_key_optional(int64_t this_arg) {
51783         LDKChannelTypeFeatures this_arg_conv;
51784         this_arg_conv.inner = untag_ptr(this_arg);
51785         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51787         this_arg_conv.is_owned = false;
51788         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
51789 }
51790
51791 void  CS_LDK_ChannelTypeFeatures_set_static_remote_key_required(int64_t this_arg) {
51792         LDKChannelTypeFeatures this_arg_conv;
51793         this_arg_conv.inner = untag_ptr(this_arg);
51794         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51796         this_arg_conv.is_owned = false;
51797         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
51798 }
51799
51800 jboolean  CS_LDK_ChannelTypeFeatures_supports_static_remote_key(int64_t this_arg) {
51801         LDKChannelTypeFeatures this_arg_conv;
51802         this_arg_conv.inner = untag_ptr(this_arg);
51803         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51805         this_arg_conv.is_owned = false;
51806         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
51807         return ret_conv;
51808 }
51809
51810 jboolean  CS_LDK_InitFeatures_requires_static_remote_key(int64_t this_arg) {
51811         LDKInitFeatures this_arg_conv;
51812         this_arg_conv.inner = untag_ptr(this_arg);
51813         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51815         this_arg_conv.is_owned = false;
51816         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
51817         return ret_conv;
51818 }
51819
51820 jboolean  CS_LDK_NodeFeatures_requires_static_remote_key(int64_t this_arg) {
51821         LDKNodeFeatures this_arg_conv;
51822         this_arg_conv.inner = untag_ptr(this_arg);
51823         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51825         this_arg_conv.is_owned = false;
51826         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
51827         return ret_conv;
51828 }
51829
51830 jboolean  CS_LDK_ChannelTypeFeatures_requires_static_remote_key(int64_t this_arg) {
51831         LDKChannelTypeFeatures this_arg_conv;
51832         this_arg_conv.inner = untag_ptr(this_arg);
51833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51835         this_arg_conv.is_owned = false;
51836         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
51837         return ret_conv;
51838 }
51839
51840 void  CS_LDK_InitFeatures_set_payment_secret_optional(int64_t this_arg) {
51841         LDKInitFeatures this_arg_conv;
51842         this_arg_conv.inner = untag_ptr(this_arg);
51843         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51845         this_arg_conv.is_owned = false;
51846         InitFeatures_set_payment_secret_optional(&this_arg_conv);
51847 }
51848
51849 void  CS_LDK_InitFeatures_set_payment_secret_required(int64_t this_arg) {
51850         LDKInitFeatures this_arg_conv;
51851         this_arg_conv.inner = untag_ptr(this_arg);
51852         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51854         this_arg_conv.is_owned = false;
51855         InitFeatures_set_payment_secret_required(&this_arg_conv);
51856 }
51857
51858 jboolean  CS_LDK_InitFeatures_supports_payment_secret(int64_t this_arg) {
51859         LDKInitFeatures this_arg_conv;
51860         this_arg_conv.inner = untag_ptr(this_arg);
51861         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51863         this_arg_conv.is_owned = false;
51864         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
51865         return ret_conv;
51866 }
51867
51868 void  CS_LDK_NodeFeatures_set_payment_secret_optional(int64_t this_arg) {
51869         LDKNodeFeatures this_arg_conv;
51870         this_arg_conv.inner = untag_ptr(this_arg);
51871         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51873         this_arg_conv.is_owned = false;
51874         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
51875 }
51876
51877 void  CS_LDK_NodeFeatures_set_payment_secret_required(int64_t this_arg) {
51878         LDKNodeFeatures this_arg_conv;
51879         this_arg_conv.inner = untag_ptr(this_arg);
51880         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51882         this_arg_conv.is_owned = false;
51883         NodeFeatures_set_payment_secret_required(&this_arg_conv);
51884 }
51885
51886 jboolean  CS_LDK_NodeFeatures_supports_payment_secret(int64_t this_arg) {
51887         LDKNodeFeatures this_arg_conv;
51888         this_arg_conv.inner = untag_ptr(this_arg);
51889         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51891         this_arg_conv.is_owned = false;
51892         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
51893         return ret_conv;
51894 }
51895
51896 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_secret_optional(int64_t this_arg) {
51897         LDKBolt11InvoiceFeatures this_arg_conv;
51898         this_arg_conv.inner = untag_ptr(this_arg);
51899         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51901         this_arg_conv.is_owned = false;
51902         Bolt11InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
51903 }
51904
51905 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_secret_required(int64_t this_arg) {
51906         LDKBolt11InvoiceFeatures this_arg_conv;
51907         this_arg_conv.inner = untag_ptr(this_arg);
51908         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51910         this_arg_conv.is_owned = false;
51911         Bolt11InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
51912 }
51913
51914 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_payment_secret(int64_t this_arg) {
51915         LDKBolt11InvoiceFeatures this_arg_conv;
51916         this_arg_conv.inner = untag_ptr(this_arg);
51917         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51919         this_arg_conv.is_owned = false;
51920         jboolean ret_conv = Bolt11InvoiceFeatures_supports_payment_secret(&this_arg_conv);
51921         return ret_conv;
51922 }
51923
51924 jboolean  CS_LDK_InitFeatures_requires_payment_secret(int64_t this_arg) {
51925         LDKInitFeatures this_arg_conv;
51926         this_arg_conv.inner = untag_ptr(this_arg);
51927         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51929         this_arg_conv.is_owned = false;
51930         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
51931         return ret_conv;
51932 }
51933
51934 jboolean  CS_LDK_NodeFeatures_requires_payment_secret(int64_t this_arg) {
51935         LDKNodeFeatures this_arg_conv;
51936         this_arg_conv.inner = untag_ptr(this_arg);
51937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51939         this_arg_conv.is_owned = false;
51940         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
51941         return ret_conv;
51942 }
51943
51944 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_payment_secret(int64_t this_arg) {
51945         LDKBolt11InvoiceFeatures this_arg_conv;
51946         this_arg_conv.inner = untag_ptr(this_arg);
51947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51949         this_arg_conv.is_owned = false;
51950         jboolean ret_conv = Bolt11InvoiceFeatures_requires_payment_secret(&this_arg_conv);
51951         return ret_conv;
51952 }
51953
51954 void  CS_LDK_InitFeatures_set_basic_mpp_optional(int64_t this_arg) {
51955         LDKInitFeatures this_arg_conv;
51956         this_arg_conv.inner = untag_ptr(this_arg);
51957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51959         this_arg_conv.is_owned = false;
51960         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
51961 }
51962
51963 void  CS_LDK_InitFeatures_set_basic_mpp_required(int64_t this_arg) {
51964         LDKInitFeatures this_arg_conv;
51965         this_arg_conv.inner = untag_ptr(this_arg);
51966         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51968         this_arg_conv.is_owned = false;
51969         InitFeatures_set_basic_mpp_required(&this_arg_conv);
51970 }
51971
51972 jboolean  CS_LDK_InitFeatures_supports_basic_mpp(int64_t this_arg) {
51973         LDKInitFeatures this_arg_conv;
51974         this_arg_conv.inner = untag_ptr(this_arg);
51975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51977         this_arg_conv.is_owned = false;
51978         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
51979         return ret_conv;
51980 }
51981
51982 void  CS_LDK_NodeFeatures_set_basic_mpp_optional(int64_t this_arg) {
51983         LDKNodeFeatures this_arg_conv;
51984         this_arg_conv.inner = untag_ptr(this_arg);
51985         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51987         this_arg_conv.is_owned = false;
51988         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
51989 }
51990
51991 void  CS_LDK_NodeFeatures_set_basic_mpp_required(int64_t this_arg) {
51992         LDKNodeFeatures this_arg_conv;
51993         this_arg_conv.inner = untag_ptr(this_arg);
51994         this_arg_conv.is_owned = ptr_is_owned(this_arg);
51995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
51996         this_arg_conv.is_owned = false;
51997         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
51998 }
51999
52000 jboolean  CS_LDK_NodeFeatures_supports_basic_mpp(int64_t this_arg) {
52001         LDKNodeFeatures this_arg_conv;
52002         this_arg_conv.inner = untag_ptr(this_arg);
52003         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52005         this_arg_conv.is_owned = false;
52006         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
52007         return ret_conv;
52008 }
52009
52010 void  CS_LDK_Bolt11InvoiceFeatures_set_basic_mpp_optional(int64_t this_arg) {
52011         LDKBolt11InvoiceFeatures this_arg_conv;
52012         this_arg_conv.inner = untag_ptr(this_arg);
52013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52015         this_arg_conv.is_owned = false;
52016         Bolt11InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
52017 }
52018
52019 void  CS_LDK_Bolt11InvoiceFeatures_set_basic_mpp_required(int64_t this_arg) {
52020         LDKBolt11InvoiceFeatures this_arg_conv;
52021         this_arg_conv.inner = untag_ptr(this_arg);
52022         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52024         this_arg_conv.is_owned = false;
52025         Bolt11InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
52026 }
52027
52028 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_basic_mpp(int64_t this_arg) {
52029         LDKBolt11InvoiceFeatures this_arg_conv;
52030         this_arg_conv.inner = untag_ptr(this_arg);
52031         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52033         this_arg_conv.is_owned = false;
52034         jboolean ret_conv = Bolt11InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
52035         return ret_conv;
52036 }
52037
52038 void  CS_LDK_Bolt12InvoiceFeatures_set_basic_mpp_optional(int64_t this_arg) {
52039         LDKBolt12InvoiceFeatures this_arg_conv;
52040         this_arg_conv.inner = untag_ptr(this_arg);
52041         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52043         this_arg_conv.is_owned = false;
52044         Bolt12InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
52045 }
52046
52047 void  CS_LDK_Bolt12InvoiceFeatures_set_basic_mpp_required(int64_t this_arg) {
52048         LDKBolt12InvoiceFeatures this_arg_conv;
52049         this_arg_conv.inner = untag_ptr(this_arg);
52050         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52052         this_arg_conv.is_owned = false;
52053         Bolt12InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
52054 }
52055
52056 jboolean  CS_LDK_Bolt12InvoiceFeatures_supports_basic_mpp(int64_t this_arg) {
52057         LDKBolt12InvoiceFeatures this_arg_conv;
52058         this_arg_conv.inner = untag_ptr(this_arg);
52059         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52061         this_arg_conv.is_owned = false;
52062         jboolean ret_conv = Bolt12InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
52063         return ret_conv;
52064 }
52065
52066 jboolean  CS_LDK_InitFeatures_requires_basic_mpp(int64_t this_arg) {
52067         LDKInitFeatures this_arg_conv;
52068         this_arg_conv.inner = untag_ptr(this_arg);
52069         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52071         this_arg_conv.is_owned = false;
52072         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
52073         return ret_conv;
52074 }
52075
52076 jboolean  CS_LDK_NodeFeatures_requires_basic_mpp(int64_t this_arg) {
52077         LDKNodeFeatures this_arg_conv;
52078         this_arg_conv.inner = untag_ptr(this_arg);
52079         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52081         this_arg_conv.is_owned = false;
52082         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
52083         return ret_conv;
52084 }
52085
52086 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_basic_mpp(int64_t this_arg) {
52087         LDKBolt11InvoiceFeatures this_arg_conv;
52088         this_arg_conv.inner = untag_ptr(this_arg);
52089         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52091         this_arg_conv.is_owned = false;
52092         jboolean ret_conv = Bolt11InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
52093         return ret_conv;
52094 }
52095
52096 jboolean  CS_LDK_Bolt12InvoiceFeatures_requires_basic_mpp(int64_t this_arg) {
52097         LDKBolt12InvoiceFeatures this_arg_conv;
52098         this_arg_conv.inner = untag_ptr(this_arg);
52099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52101         this_arg_conv.is_owned = false;
52102         jboolean ret_conv = Bolt12InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
52103         return ret_conv;
52104 }
52105
52106 void  CS_LDK_InitFeatures_set_wumbo_optional(int64_t this_arg) {
52107         LDKInitFeatures this_arg_conv;
52108         this_arg_conv.inner = untag_ptr(this_arg);
52109         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52111         this_arg_conv.is_owned = false;
52112         InitFeatures_set_wumbo_optional(&this_arg_conv);
52113 }
52114
52115 void  CS_LDK_InitFeatures_set_wumbo_required(int64_t this_arg) {
52116         LDKInitFeatures this_arg_conv;
52117         this_arg_conv.inner = untag_ptr(this_arg);
52118         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52120         this_arg_conv.is_owned = false;
52121         InitFeatures_set_wumbo_required(&this_arg_conv);
52122 }
52123
52124 jboolean  CS_LDK_InitFeatures_supports_wumbo(int64_t this_arg) {
52125         LDKInitFeatures this_arg_conv;
52126         this_arg_conv.inner = untag_ptr(this_arg);
52127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52129         this_arg_conv.is_owned = false;
52130         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
52131         return ret_conv;
52132 }
52133
52134 void  CS_LDK_NodeFeatures_set_wumbo_optional(int64_t this_arg) {
52135         LDKNodeFeatures this_arg_conv;
52136         this_arg_conv.inner = untag_ptr(this_arg);
52137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52139         this_arg_conv.is_owned = false;
52140         NodeFeatures_set_wumbo_optional(&this_arg_conv);
52141 }
52142
52143 void  CS_LDK_NodeFeatures_set_wumbo_required(int64_t this_arg) {
52144         LDKNodeFeatures this_arg_conv;
52145         this_arg_conv.inner = untag_ptr(this_arg);
52146         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52148         this_arg_conv.is_owned = false;
52149         NodeFeatures_set_wumbo_required(&this_arg_conv);
52150 }
52151
52152 jboolean  CS_LDK_NodeFeatures_supports_wumbo(int64_t this_arg) {
52153         LDKNodeFeatures this_arg_conv;
52154         this_arg_conv.inner = untag_ptr(this_arg);
52155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52157         this_arg_conv.is_owned = false;
52158         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
52159         return ret_conv;
52160 }
52161
52162 jboolean  CS_LDK_InitFeatures_requires_wumbo(int64_t this_arg) {
52163         LDKInitFeatures this_arg_conv;
52164         this_arg_conv.inner = untag_ptr(this_arg);
52165         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52167         this_arg_conv.is_owned = false;
52168         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
52169         return ret_conv;
52170 }
52171
52172 jboolean  CS_LDK_NodeFeatures_requires_wumbo(int64_t this_arg) {
52173         LDKNodeFeatures this_arg_conv;
52174         this_arg_conv.inner = untag_ptr(this_arg);
52175         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52177         this_arg_conv.is_owned = false;
52178         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
52179         return ret_conv;
52180 }
52181
52182 void  CS_LDK_InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(int64_t this_arg) {
52183         LDKInitFeatures this_arg_conv;
52184         this_arg_conv.inner = untag_ptr(this_arg);
52185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52187         this_arg_conv.is_owned = false;
52188         InitFeatures_set_anchors_nonzero_fee_htlc_tx_optional(&this_arg_conv);
52189 }
52190
52191 void  CS_LDK_InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(int64_t this_arg) {
52192         LDKInitFeatures this_arg_conv;
52193         this_arg_conv.inner = untag_ptr(this_arg);
52194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52196         this_arg_conv.is_owned = false;
52197         InitFeatures_set_anchors_nonzero_fee_htlc_tx_required(&this_arg_conv);
52198 }
52199
52200 jboolean  CS_LDK_InitFeatures_supports_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52201         LDKInitFeatures this_arg_conv;
52202         this_arg_conv.inner = untag_ptr(this_arg);
52203         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52205         this_arg_conv.is_owned = false;
52206         jboolean ret_conv = InitFeatures_supports_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52207         return ret_conv;
52208 }
52209
52210 void  CS_LDK_NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(int64_t this_arg) {
52211         LDKNodeFeatures this_arg_conv;
52212         this_arg_conv.inner = untag_ptr(this_arg);
52213         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52215         this_arg_conv.is_owned = false;
52216         NodeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(&this_arg_conv);
52217 }
52218
52219 void  CS_LDK_NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(int64_t this_arg) {
52220         LDKNodeFeatures this_arg_conv;
52221         this_arg_conv.inner = untag_ptr(this_arg);
52222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52224         this_arg_conv.is_owned = false;
52225         NodeFeatures_set_anchors_nonzero_fee_htlc_tx_required(&this_arg_conv);
52226 }
52227
52228 jboolean  CS_LDK_NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52229         LDKNodeFeatures this_arg_conv;
52230         this_arg_conv.inner = untag_ptr(this_arg);
52231         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52233         this_arg_conv.is_owned = false;
52234         jboolean ret_conv = NodeFeatures_supports_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52235         return ret_conv;
52236 }
52237
52238 void  CS_LDK_ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(int64_t this_arg) {
52239         LDKChannelTypeFeatures this_arg_conv;
52240         this_arg_conv.inner = untag_ptr(this_arg);
52241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52243         this_arg_conv.is_owned = false;
52244         ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_optional(&this_arg_conv);
52245 }
52246
52247 void  CS_LDK_ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(int64_t this_arg) {
52248         LDKChannelTypeFeatures this_arg_conv;
52249         this_arg_conv.inner = untag_ptr(this_arg);
52250         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52252         this_arg_conv.is_owned = false;
52253         ChannelTypeFeatures_set_anchors_nonzero_fee_htlc_tx_required(&this_arg_conv);
52254 }
52255
52256 jboolean  CS_LDK_ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52257         LDKChannelTypeFeatures this_arg_conv;
52258         this_arg_conv.inner = untag_ptr(this_arg);
52259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52261         this_arg_conv.is_owned = false;
52262         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52263         return ret_conv;
52264 }
52265
52266 jboolean  CS_LDK_InitFeatures_requires_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52267         LDKInitFeatures this_arg_conv;
52268         this_arg_conv.inner = untag_ptr(this_arg);
52269         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52271         this_arg_conv.is_owned = false;
52272         jboolean ret_conv = InitFeatures_requires_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52273         return ret_conv;
52274 }
52275
52276 jboolean  CS_LDK_NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52277         LDKNodeFeatures this_arg_conv;
52278         this_arg_conv.inner = untag_ptr(this_arg);
52279         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52281         this_arg_conv.is_owned = false;
52282         jboolean ret_conv = NodeFeatures_requires_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52283         return ret_conv;
52284 }
52285
52286 jboolean  CS_LDK_ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(int64_t this_arg) {
52287         LDKChannelTypeFeatures this_arg_conv;
52288         this_arg_conv.inner = untag_ptr(this_arg);
52289         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52291         this_arg_conv.is_owned = false;
52292         jboolean ret_conv = ChannelTypeFeatures_requires_anchors_nonzero_fee_htlc_tx(&this_arg_conv);
52293         return ret_conv;
52294 }
52295
52296 void  CS_LDK_InitFeatures_set_anchors_zero_fee_htlc_tx_optional(int64_t this_arg) {
52297         LDKInitFeatures this_arg_conv;
52298         this_arg_conv.inner = untag_ptr(this_arg);
52299         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52301         this_arg_conv.is_owned = false;
52302         InitFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
52303 }
52304
52305 void  CS_LDK_InitFeatures_set_anchors_zero_fee_htlc_tx_required(int64_t this_arg) {
52306         LDKInitFeatures this_arg_conv;
52307         this_arg_conv.inner = untag_ptr(this_arg);
52308         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52310         this_arg_conv.is_owned = false;
52311         InitFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
52312 }
52313
52314 jboolean  CS_LDK_InitFeatures_supports_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52315         LDKInitFeatures this_arg_conv;
52316         this_arg_conv.inner = untag_ptr(this_arg);
52317         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52319         this_arg_conv.is_owned = false;
52320         jboolean ret_conv = InitFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
52321         return ret_conv;
52322 }
52323
52324 void  CS_LDK_NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(int64_t this_arg) {
52325         LDKNodeFeatures this_arg_conv;
52326         this_arg_conv.inner = untag_ptr(this_arg);
52327         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52329         this_arg_conv.is_owned = false;
52330         NodeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
52331 }
52332
52333 void  CS_LDK_NodeFeatures_set_anchors_zero_fee_htlc_tx_required(int64_t this_arg) {
52334         LDKNodeFeatures this_arg_conv;
52335         this_arg_conv.inner = untag_ptr(this_arg);
52336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52338         this_arg_conv.is_owned = false;
52339         NodeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
52340 }
52341
52342 jboolean  CS_LDK_NodeFeatures_supports_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52343         LDKNodeFeatures this_arg_conv;
52344         this_arg_conv.inner = untag_ptr(this_arg);
52345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52347         this_arg_conv.is_owned = false;
52348         jboolean ret_conv = NodeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
52349         return ret_conv;
52350 }
52351
52352 void  CS_LDK_ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(int64_t this_arg) {
52353         LDKChannelTypeFeatures this_arg_conv;
52354         this_arg_conv.inner = untag_ptr(this_arg);
52355         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52357         this_arg_conv.is_owned = false;
52358         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_optional(&this_arg_conv);
52359 }
52360
52361 void  CS_LDK_ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(int64_t this_arg) {
52362         LDKChannelTypeFeatures this_arg_conv;
52363         this_arg_conv.inner = untag_ptr(this_arg);
52364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52366         this_arg_conv.is_owned = false;
52367         ChannelTypeFeatures_set_anchors_zero_fee_htlc_tx_required(&this_arg_conv);
52368 }
52369
52370 jboolean  CS_LDK_ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52371         LDKChannelTypeFeatures this_arg_conv;
52372         this_arg_conv.inner = untag_ptr(this_arg);
52373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52375         this_arg_conv.is_owned = false;
52376         jboolean ret_conv = ChannelTypeFeatures_supports_anchors_zero_fee_htlc_tx(&this_arg_conv);
52377         return ret_conv;
52378 }
52379
52380 jboolean  CS_LDK_InitFeatures_requires_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52381         LDKInitFeatures this_arg_conv;
52382         this_arg_conv.inner = untag_ptr(this_arg);
52383         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52385         this_arg_conv.is_owned = false;
52386         jboolean ret_conv = InitFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
52387         return ret_conv;
52388 }
52389
52390 jboolean  CS_LDK_NodeFeatures_requires_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52391         LDKNodeFeatures this_arg_conv;
52392         this_arg_conv.inner = untag_ptr(this_arg);
52393         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52395         this_arg_conv.is_owned = false;
52396         jboolean ret_conv = NodeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
52397         return ret_conv;
52398 }
52399
52400 jboolean  CS_LDK_ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(int64_t this_arg) {
52401         LDKChannelTypeFeatures this_arg_conv;
52402         this_arg_conv.inner = untag_ptr(this_arg);
52403         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52405         this_arg_conv.is_owned = false;
52406         jboolean ret_conv = ChannelTypeFeatures_requires_anchors_zero_fee_htlc_tx(&this_arg_conv);
52407         return ret_conv;
52408 }
52409
52410 void  CS_LDK_InitFeatures_set_shutdown_any_segwit_optional(int64_t this_arg) {
52411         LDKInitFeatures this_arg_conv;
52412         this_arg_conv.inner = untag_ptr(this_arg);
52413         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52415         this_arg_conv.is_owned = false;
52416         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
52417 }
52418
52419 void  CS_LDK_InitFeatures_set_shutdown_any_segwit_required(int64_t this_arg) {
52420         LDKInitFeatures this_arg_conv;
52421         this_arg_conv.inner = untag_ptr(this_arg);
52422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52424         this_arg_conv.is_owned = false;
52425         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
52426 }
52427
52428 jboolean  CS_LDK_InitFeatures_supports_shutdown_anysegwit(int64_t this_arg) {
52429         LDKInitFeatures this_arg_conv;
52430         this_arg_conv.inner = untag_ptr(this_arg);
52431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52433         this_arg_conv.is_owned = false;
52434         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
52435         return ret_conv;
52436 }
52437
52438 void  CS_LDK_NodeFeatures_set_shutdown_any_segwit_optional(int64_t this_arg) {
52439         LDKNodeFeatures this_arg_conv;
52440         this_arg_conv.inner = untag_ptr(this_arg);
52441         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52443         this_arg_conv.is_owned = false;
52444         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
52445 }
52446
52447 void  CS_LDK_NodeFeatures_set_shutdown_any_segwit_required(int64_t this_arg) {
52448         LDKNodeFeatures this_arg_conv;
52449         this_arg_conv.inner = untag_ptr(this_arg);
52450         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52452         this_arg_conv.is_owned = false;
52453         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
52454 }
52455
52456 jboolean  CS_LDK_NodeFeatures_supports_shutdown_anysegwit(int64_t this_arg) {
52457         LDKNodeFeatures this_arg_conv;
52458         this_arg_conv.inner = untag_ptr(this_arg);
52459         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52461         this_arg_conv.is_owned = false;
52462         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
52463         return ret_conv;
52464 }
52465
52466 jboolean  CS_LDK_InitFeatures_requires_shutdown_anysegwit(int64_t this_arg) {
52467         LDKInitFeatures this_arg_conv;
52468         this_arg_conv.inner = untag_ptr(this_arg);
52469         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52471         this_arg_conv.is_owned = false;
52472         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
52473         return ret_conv;
52474 }
52475
52476 jboolean  CS_LDK_NodeFeatures_requires_shutdown_anysegwit(int64_t this_arg) {
52477         LDKNodeFeatures this_arg_conv;
52478         this_arg_conv.inner = untag_ptr(this_arg);
52479         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52481         this_arg_conv.is_owned = false;
52482         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
52483         return ret_conv;
52484 }
52485
52486 void  CS_LDK_InitFeatures_set_taproot_optional(int64_t this_arg) {
52487         LDKInitFeatures this_arg_conv;
52488         this_arg_conv.inner = untag_ptr(this_arg);
52489         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52491         this_arg_conv.is_owned = false;
52492         InitFeatures_set_taproot_optional(&this_arg_conv);
52493 }
52494
52495 void  CS_LDK_InitFeatures_set_taproot_required(int64_t this_arg) {
52496         LDKInitFeatures this_arg_conv;
52497         this_arg_conv.inner = untag_ptr(this_arg);
52498         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52500         this_arg_conv.is_owned = false;
52501         InitFeatures_set_taproot_required(&this_arg_conv);
52502 }
52503
52504 jboolean  CS_LDK_InitFeatures_supports_taproot(int64_t this_arg) {
52505         LDKInitFeatures this_arg_conv;
52506         this_arg_conv.inner = untag_ptr(this_arg);
52507         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52509         this_arg_conv.is_owned = false;
52510         jboolean ret_conv = InitFeatures_supports_taproot(&this_arg_conv);
52511         return ret_conv;
52512 }
52513
52514 void  CS_LDK_NodeFeatures_set_taproot_optional(int64_t this_arg) {
52515         LDKNodeFeatures this_arg_conv;
52516         this_arg_conv.inner = untag_ptr(this_arg);
52517         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52519         this_arg_conv.is_owned = false;
52520         NodeFeatures_set_taproot_optional(&this_arg_conv);
52521 }
52522
52523 void  CS_LDK_NodeFeatures_set_taproot_required(int64_t this_arg) {
52524         LDKNodeFeatures this_arg_conv;
52525         this_arg_conv.inner = untag_ptr(this_arg);
52526         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52528         this_arg_conv.is_owned = false;
52529         NodeFeatures_set_taproot_required(&this_arg_conv);
52530 }
52531
52532 jboolean  CS_LDK_NodeFeatures_supports_taproot(int64_t this_arg) {
52533         LDKNodeFeatures this_arg_conv;
52534         this_arg_conv.inner = untag_ptr(this_arg);
52535         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52537         this_arg_conv.is_owned = false;
52538         jboolean ret_conv = NodeFeatures_supports_taproot(&this_arg_conv);
52539         return ret_conv;
52540 }
52541
52542 void  CS_LDK_ChannelTypeFeatures_set_taproot_optional(int64_t this_arg) {
52543         LDKChannelTypeFeatures this_arg_conv;
52544         this_arg_conv.inner = untag_ptr(this_arg);
52545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52547         this_arg_conv.is_owned = false;
52548         ChannelTypeFeatures_set_taproot_optional(&this_arg_conv);
52549 }
52550
52551 void  CS_LDK_ChannelTypeFeatures_set_taproot_required(int64_t this_arg) {
52552         LDKChannelTypeFeatures this_arg_conv;
52553         this_arg_conv.inner = untag_ptr(this_arg);
52554         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52556         this_arg_conv.is_owned = false;
52557         ChannelTypeFeatures_set_taproot_required(&this_arg_conv);
52558 }
52559
52560 jboolean  CS_LDK_ChannelTypeFeatures_supports_taproot(int64_t this_arg) {
52561         LDKChannelTypeFeatures this_arg_conv;
52562         this_arg_conv.inner = untag_ptr(this_arg);
52563         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52565         this_arg_conv.is_owned = false;
52566         jboolean ret_conv = ChannelTypeFeatures_supports_taproot(&this_arg_conv);
52567         return ret_conv;
52568 }
52569
52570 jboolean  CS_LDK_InitFeatures_requires_taproot(int64_t this_arg) {
52571         LDKInitFeatures this_arg_conv;
52572         this_arg_conv.inner = untag_ptr(this_arg);
52573         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52575         this_arg_conv.is_owned = false;
52576         jboolean ret_conv = InitFeatures_requires_taproot(&this_arg_conv);
52577         return ret_conv;
52578 }
52579
52580 jboolean  CS_LDK_NodeFeatures_requires_taproot(int64_t this_arg) {
52581         LDKNodeFeatures this_arg_conv;
52582         this_arg_conv.inner = untag_ptr(this_arg);
52583         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52585         this_arg_conv.is_owned = false;
52586         jboolean ret_conv = NodeFeatures_requires_taproot(&this_arg_conv);
52587         return ret_conv;
52588 }
52589
52590 jboolean  CS_LDK_ChannelTypeFeatures_requires_taproot(int64_t this_arg) {
52591         LDKChannelTypeFeatures this_arg_conv;
52592         this_arg_conv.inner = untag_ptr(this_arg);
52593         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52595         this_arg_conv.is_owned = false;
52596         jboolean ret_conv = ChannelTypeFeatures_requires_taproot(&this_arg_conv);
52597         return ret_conv;
52598 }
52599
52600 void  CS_LDK_InitFeatures_set_onion_messages_optional(int64_t this_arg) {
52601         LDKInitFeatures this_arg_conv;
52602         this_arg_conv.inner = untag_ptr(this_arg);
52603         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52605         this_arg_conv.is_owned = false;
52606         InitFeatures_set_onion_messages_optional(&this_arg_conv);
52607 }
52608
52609 void  CS_LDK_InitFeatures_set_onion_messages_required(int64_t this_arg) {
52610         LDKInitFeatures this_arg_conv;
52611         this_arg_conv.inner = untag_ptr(this_arg);
52612         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52614         this_arg_conv.is_owned = false;
52615         InitFeatures_set_onion_messages_required(&this_arg_conv);
52616 }
52617
52618 jboolean  CS_LDK_InitFeatures_supports_onion_messages(int64_t this_arg) {
52619         LDKInitFeatures this_arg_conv;
52620         this_arg_conv.inner = untag_ptr(this_arg);
52621         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52623         this_arg_conv.is_owned = false;
52624         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
52625         return ret_conv;
52626 }
52627
52628 void  CS_LDK_NodeFeatures_set_onion_messages_optional(int64_t this_arg) {
52629         LDKNodeFeatures this_arg_conv;
52630         this_arg_conv.inner = untag_ptr(this_arg);
52631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52633         this_arg_conv.is_owned = false;
52634         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
52635 }
52636
52637 void  CS_LDK_NodeFeatures_set_onion_messages_required(int64_t this_arg) {
52638         LDKNodeFeatures this_arg_conv;
52639         this_arg_conv.inner = untag_ptr(this_arg);
52640         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52642         this_arg_conv.is_owned = false;
52643         NodeFeatures_set_onion_messages_required(&this_arg_conv);
52644 }
52645
52646 jboolean  CS_LDK_NodeFeatures_supports_onion_messages(int64_t this_arg) {
52647         LDKNodeFeatures this_arg_conv;
52648         this_arg_conv.inner = untag_ptr(this_arg);
52649         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52651         this_arg_conv.is_owned = false;
52652         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
52653         return ret_conv;
52654 }
52655
52656 jboolean  CS_LDK_InitFeatures_requires_onion_messages(int64_t this_arg) {
52657         LDKInitFeatures this_arg_conv;
52658         this_arg_conv.inner = untag_ptr(this_arg);
52659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52661         this_arg_conv.is_owned = false;
52662         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
52663         return ret_conv;
52664 }
52665
52666 jboolean  CS_LDK_NodeFeatures_requires_onion_messages(int64_t this_arg) {
52667         LDKNodeFeatures this_arg_conv;
52668         this_arg_conv.inner = untag_ptr(this_arg);
52669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52671         this_arg_conv.is_owned = false;
52672         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
52673         return ret_conv;
52674 }
52675
52676 void  CS_LDK_InitFeatures_set_channel_type_optional(int64_t this_arg) {
52677         LDKInitFeatures this_arg_conv;
52678         this_arg_conv.inner = untag_ptr(this_arg);
52679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52681         this_arg_conv.is_owned = false;
52682         InitFeatures_set_channel_type_optional(&this_arg_conv);
52683 }
52684
52685 void  CS_LDK_InitFeatures_set_channel_type_required(int64_t this_arg) {
52686         LDKInitFeatures this_arg_conv;
52687         this_arg_conv.inner = untag_ptr(this_arg);
52688         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52690         this_arg_conv.is_owned = false;
52691         InitFeatures_set_channel_type_required(&this_arg_conv);
52692 }
52693
52694 jboolean  CS_LDK_InitFeatures_supports_channel_type(int64_t this_arg) {
52695         LDKInitFeatures this_arg_conv;
52696         this_arg_conv.inner = untag_ptr(this_arg);
52697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52699         this_arg_conv.is_owned = false;
52700         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
52701         return ret_conv;
52702 }
52703
52704 void  CS_LDK_NodeFeatures_set_channel_type_optional(int64_t this_arg) {
52705         LDKNodeFeatures this_arg_conv;
52706         this_arg_conv.inner = untag_ptr(this_arg);
52707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52709         this_arg_conv.is_owned = false;
52710         NodeFeatures_set_channel_type_optional(&this_arg_conv);
52711 }
52712
52713 void  CS_LDK_NodeFeatures_set_channel_type_required(int64_t this_arg) {
52714         LDKNodeFeatures this_arg_conv;
52715         this_arg_conv.inner = untag_ptr(this_arg);
52716         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52718         this_arg_conv.is_owned = false;
52719         NodeFeatures_set_channel_type_required(&this_arg_conv);
52720 }
52721
52722 jboolean  CS_LDK_NodeFeatures_supports_channel_type(int64_t this_arg) {
52723         LDKNodeFeatures this_arg_conv;
52724         this_arg_conv.inner = untag_ptr(this_arg);
52725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52727         this_arg_conv.is_owned = false;
52728         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
52729         return ret_conv;
52730 }
52731
52732 jboolean  CS_LDK_InitFeatures_requires_channel_type(int64_t this_arg) {
52733         LDKInitFeatures this_arg_conv;
52734         this_arg_conv.inner = untag_ptr(this_arg);
52735         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52737         this_arg_conv.is_owned = false;
52738         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
52739         return ret_conv;
52740 }
52741
52742 jboolean  CS_LDK_NodeFeatures_requires_channel_type(int64_t this_arg) {
52743         LDKNodeFeatures this_arg_conv;
52744         this_arg_conv.inner = untag_ptr(this_arg);
52745         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52747         this_arg_conv.is_owned = false;
52748         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
52749         return ret_conv;
52750 }
52751
52752 void  CS_LDK_InitFeatures_set_scid_privacy_optional(int64_t this_arg) {
52753         LDKInitFeatures this_arg_conv;
52754         this_arg_conv.inner = untag_ptr(this_arg);
52755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52757         this_arg_conv.is_owned = false;
52758         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
52759 }
52760
52761 void  CS_LDK_InitFeatures_set_scid_privacy_required(int64_t this_arg) {
52762         LDKInitFeatures this_arg_conv;
52763         this_arg_conv.inner = untag_ptr(this_arg);
52764         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52766         this_arg_conv.is_owned = false;
52767         InitFeatures_set_scid_privacy_required(&this_arg_conv);
52768 }
52769
52770 jboolean  CS_LDK_InitFeatures_supports_scid_privacy(int64_t this_arg) {
52771         LDKInitFeatures this_arg_conv;
52772         this_arg_conv.inner = untag_ptr(this_arg);
52773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52775         this_arg_conv.is_owned = false;
52776         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
52777         return ret_conv;
52778 }
52779
52780 void  CS_LDK_NodeFeatures_set_scid_privacy_optional(int64_t this_arg) {
52781         LDKNodeFeatures this_arg_conv;
52782         this_arg_conv.inner = untag_ptr(this_arg);
52783         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52785         this_arg_conv.is_owned = false;
52786         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
52787 }
52788
52789 void  CS_LDK_NodeFeatures_set_scid_privacy_required(int64_t this_arg) {
52790         LDKNodeFeatures this_arg_conv;
52791         this_arg_conv.inner = untag_ptr(this_arg);
52792         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52794         this_arg_conv.is_owned = false;
52795         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
52796 }
52797
52798 jboolean  CS_LDK_NodeFeatures_supports_scid_privacy(int64_t this_arg) {
52799         LDKNodeFeatures this_arg_conv;
52800         this_arg_conv.inner = untag_ptr(this_arg);
52801         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52803         this_arg_conv.is_owned = false;
52804         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
52805         return ret_conv;
52806 }
52807
52808 void  CS_LDK_ChannelTypeFeatures_set_scid_privacy_optional(int64_t this_arg) {
52809         LDKChannelTypeFeatures this_arg_conv;
52810         this_arg_conv.inner = untag_ptr(this_arg);
52811         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52813         this_arg_conv.is_owned = false;
52814         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
52815 }
52816
52817 void  CS_LDK_ChannelTypeFeatures_set_scid_privacy_required(int64_t this_arg) {
52818         LDKChannelTypeFeatures this_arg_conv;
52819         this_arg_conv.inner = untag_ptr(this_arg);
52820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52822         this_arg_conv.is_owned = false;
52823         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
52824 }
52825
52826 jboolean  CS_LDK_ChannelTypeFeatures_supports_scid_privacy(int64_t this_arg) {
52827         LDKChannelTypeFeatures this_arg_conv;
52828         this_arg_conv.inner = untag_ptr(this_arg);
52829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52831         this_arg_conv.is_owned = false;
52832         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
52833         return ret_conv;
52834 }
52835
52836 jboolean  CS_LDK_InitFeatures_requires_scid_privacy(int64_t this_arg) {
52837         LDKInitFeatures this_arg_conv;
52838         this_arg_conv.inner = untag_ptr(this_arg);
52839         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52841         this_arg_conv.is_owned = false;
52842         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
52843         return ret_conv;
52844 }
52845
52846 jboolean  CS_LDK_NodeFeatures_requires_scid_privacy(int64_t this_arg) {
52847         LDKNodeFeatures this_arg_conv;
52848         this_arg_conv.inner = untag_ptr(this_arg);
52849         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52851         this_arg_conv.is_owned = false;
52852         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
52853         return ret_conv;
52854 }
52855
52856 jboolean  CS_LDK_ChannelTypeFeatures_requires_scid_privacy(int64_t this_arg) {
52857         LDKChannelTypeFeatures this_arg_conv;
52858         this_arg_conv.inner = untag_ptr(this_arg);
52859         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52861         this_arg_conv.is_owned = false;
52862         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
52863         return ret_conv;
52864 }
52865
52866 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_metadata_optional(int64_t this_arg) {
52867         LDKBolt11InvoiceFeatures this_arg_conv;
52868         this_arg_conv.inner = untag_ptr(this_arg);
52869         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52871         this_arg_conv.is_owned = false;
52872         Bolt11InvoiceFeatures_set_payment_metadata_optional(&this_arg_conv);
52873 }
52874
52875 void  CS_LDK_Bolt11InvoiceFeatures_set_payment_metadata_required(int64_t this_arg) {
52876         LDKBolt11InvoiceFeatures this_arg_conv;
52877         this_arg_conv.inner = untag_ptr(this_arg);
52878         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52880         this_arg_conv.is_owned = false;
52881         Bolt11InvoiceFeatures_set_payment_metadata_required(&this_arg_conv);
52882 }
52883
52884 jboolean  CS_LDK_Bolt11InvoiceFeatures_supports_payment_metadata(int64_t this_arg) {
52885         LDKBolt11InvoiceFeatures this_arg_conv;
52886         this_arg_conv.inner = untag_ptr(this_arg);
52887         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52889         this_arg_conv.is_owned = false;
52890         jboolean ret_conv = Bolt11InvoiceFeatures_supports_payment_metadata(&this_arg_conv);
52891         return ret_conv;
52892 }
52893
52894 jboolean  CS_LDK_Bolt11InvoiceFeatures_requires_payment_metadata(int64_t this_arg) {
52895         LDKBolt11InvoiceFeatures this_arg_conv;
52896         this_arg_conv.inner = untag_ptr(this_arg);
52897         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52899         this_arg_conv.is_owned = false;
52900         jboolean ret_conv = Bolt11InvoiceFeatures_requires_payment_metadata(&this_arg_conv);
52901         return ret_conv;
52902 }
52903
52904 void  CS_LDK_InitFeatures_set_zero_conf_optional(int64_t this_arg) {
52905         LDKInitFeatures this_arg_conv;
52906         this_arg_conv.inner = untag_ptr(this_arg);
52907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52909         this_arg_conv.is_owned = false;
52910         InitFeatures_set_zero_conf_optional(&this_arg_conv);
52911 }
52912
52913 void  CS_LDK_InitFeatures_set_zero_conf_required(int64_t this_arg) {
52914         LDKInitFeatures this_arg_conv;
52915         this_arg_conv.inner = untag_ptr(this_arg);
52916         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52918         this_arg_conv.is_owned = false;
52919         InitFeatures_set_zero_conf_required(&this_arg_conv);
52920 }
52921
52922 jboolean  CS_LDK_InitFeatures_supports_zero_conf(int64_t this_arg) {
52923         LDKInitFeatures this_arg_conv;
52924         this_arg_conv.inner = untag_ptr(this_arg);
52925         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52927         this_arg_conv.is_owned = false;
52928         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
52929         return ret_conv;
52930 }
52931
52932 void  CS_LDK_NodeFeatures_set_zero_conf_optional(int64_t this_arg) {
52933         LDKNodeFeatures this_arg_conv;
52934         this_arg_conv.inner = untag_ptr(this_arg);
52935         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52937         this_arg_conv.is_owned = false;
52938         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
52939 }
52940
52941 void  CS_LDK_NodeFeatures_set_zero_conf_required(int64_t this_arg) {
52942         LDKNodeFeatures this_arg_conv;
52943         this_arg_conv.inner = untag_ptr(this_arg);
52944         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52946         this_arg_conv.is_owned = false;
52947         NodeFeatures_set_zero_conf_required(&this_arg_conv);
52948 }
52949
52950 jboolean  CS_LDK_NodeFeatures_supports_zero_conf(int64_t this_arg) {
52951         LDKNodeFeatures this_arg_conv;
52952         this_arg_conv.inner = untag_ptr(this_arg);
52953         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52955         this_arg_conv.is_owned = false;
52956         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
52957         return ret_conv;
52958 }
52959
52960 void  CS_LDK_ChannelTypeFeatures_set_zero_conf_optional(int64_t this_arg) {
52961         LDKChannelTypeFeatures this_arg_conv;
52962         this_arg_conv.inner = untag_ptr(this_arg);
52963         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52965         this_arg_conv.is_owned = false;
52966         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
52967 }
52968
52969 void  CS_LDK_ChannelTypeFeatures_set_zero_conf_required(int64_t this_arg) {
52970         LDKChannelTypeFeatures this_arg_conv;
52971         this_arg_conv.inner = untag_ptr(this_arg);
52972         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52974         this_arg_conv.is_owned = false;
52975         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
52976 }
52977
52978 jboolean  CS_LDK_ChannelTypeFeatures_supports_zero_conf(int64_t this_arg) {
52979         LDKChannelTypeFeatures this_arg_conv;
52980         this_arg_conv.inner = untag_ptr(this_arg);
52981         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52983         this_arg_conv.is_owned = false;
52984         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
52985         return ret_conv;
52986 }
52987
52988 jboolean  CS_LDK_InitFeatures_requires_zero_conf(int64_t this_arg) {
52989         LDKInitFeatures this_arg_conv;
52990         this_arg_conv.inner = untag_ptr(this_arg);
52991         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52993         this_arg_conv.is_owned = false;
52994         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
52995         return ret_conv;
52996 }
52997
52998 jboolean  CS_LDK_NodeFeatures_requires_zero_conf(int64_t this_arg) {
52999         LDKNodeFeatures this_arg_conv;
53000         this_arg_conv.inner = untag_ptr(this_arg);
53001         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53003         this_arg_conv.is_owned = false;
53004         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
53005         return ret_conv;
53006 }
53007
53008 jboolean  CS_LDK_ChannelTypeFeatures_requires_zero_conf(int64_t this_arg) {
53009         LDKChannelTypeFeatures this_arg_conv;
53010         this_arg_conv.inner = untag_ptr(this_arg);
53011         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53013         this_arg_conv.is_owned = false;
53014         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
53015         return ret_conv;
53016 }
53017
53018 void  CS_LDK_NodeFeatures_set_keysend_optional(int64_t this_arg) {
53019         LDKNodeFeatures this_arg_conv;
53020         this_arg_conv.inner = untag_ptr(this_arg);
53021         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53023         this_arg_conv.is_owned = false;
53024         NodeFeatures_set_keysend_optional(&this_arg_conv);
53025 }
53026
53027 void  CS_LDK_NodeFeatures_set_keysend_required(int64_t this_arg) {
53028         LDKNodeFeatures this_arg_conv;
53029         this_arg_conv.inner = untag_ptr(this_arg);
53030         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53032         this_arg_conv.is_owned = false;
53033         NodeFeatures_set_keysend_required(&this_arg_conv);
53034 }
53035
53036 jboolean  CS_LDK_NodeFeatures_supports_keysend(int64_t this_arg) {
53037         LDKNodeFeatures this_arg_conv;
53038         this_arg_conv.inner = untag_ptr(this_arg);
53039         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53041         this_arg_conv.is_owned = false;
53042         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
53043         return ret_conv;
53044 }
53045
53046 jboolean  CS_LDK_NodeFeatures_requires_keysend(int64_t this_arg) {
53047         LDKNodeFeatures this_arg_conv;
53048         this_arg_conv.inner = untag_ptr(this_arg);
53049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53051         this_arg_conv.is_owned = false;
53052         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
53053         return ret_conv;
53054 }
53055
53056 void  CS_LDK_ShutdownScript_free(int64_t this_obj) {
53057         LDKShutdownScript this_obj_conv;
53058         this_obj_conv.inner = untag_ptr(this_obj);
53059         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53061         ShutdownScript_free(this_obj_conv);
53062 }
53063
53064 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
53065         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
53066         int64_t ret_ref = 0;
53067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53068         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53069         return ret_ref;
53070 }
53071 int64_t  CS_LDK_ShutdownScript_clone_ptr(int64_t arg) {
53072         LDKShutdownScript arg_conv;
53073         arg_conv.inner = untag_ptr(arg);
53074         arg_conv.is_owned = ptr_is_owned(arg);
53075         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53076         arg_conv.is_owned = false;
53077         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
53078         return ret_conv;
53079 }
53080
53081 int64_t  CS_LDK_ShutdownScript_clone(int64_t orig) {
53082         LDKShutdownScript orig_conv;
53083         orig_conv.inner = untag_ptr(orig);
53084         orig_conv.is_owned = ptr_is_owned(orig);
53085         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53086         orig_conv.is_owned = false;
53087         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
53088         int64_t ret_ref = 0;
53089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53091         return ret_ref;
53092 }
53093
53094 jboolean  CS_LDK_ShutdownScript_eq(int64_t a, int64_t b) {
53095         LDKShutdownScript a_conv;
53096         a_conv.inner = untag_ptr(a);
53097         a_conv.is_owned = ptr_is_owned(a);
53098         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53099         a_conv.is_owned = false;
53100         LDKShutdownScript b_conv;
53101         b_conv.inner = untag_ptr(b);
53102         b_conv.is_owned = ptr_is_owned(b);
53103         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53104         b_conv.is_owned = false;
53105         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
53106         return ret_conv;
53107 }
53108
53109 void  CS_LDK_InvalidShutdownScript_free(int64_t this_obj) {
53110         LDKInvalidShutdownScript this_obj_conv;
53111         this_obj_conv.inner = untag_ptr(this_obj);
53112         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53114         InvalidShutdownScript_free(this_obj_conv);
53115 }
53116
53117 int8_tArray  CS_LDK_InvalidShutdownScript_get_script(int64_t this_ptr) {
53118         LDKInvalidShutdownScript this_ptr_conv;
53119         this_ptr_conv.inner = untag_ptr(this_ptr);
53120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53122         this_ptr_conv.is_owned = false;
53123         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
53124         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53125         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53126         return ret_arr;
53127 }
53128
53129 void  CS_LDK_InvalidShutdownScript_set_script(int64_t this_ptr, int8_tArray val) {
53130         LDKInvalidShutdownScript this_ptr_conv;
53131         this_ptr_conv.inner = untag_ptr(this_ptr);
53132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53134         this_ptr_conv.is_owned = false;
53135         LDKCVec_u8Z val_ref;
53136         val_ref.datalen = val->arr_len;
53137         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
53138         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
53139         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
53140 }
53141
53142 int64_t  CS_LDK_InvalidShutdownScript_new(int8_tArray script_arg) {
53143         LDKCVec_u8Z script_arg_ref;
53144         script_arg_ref.datalen = script_arg->arr_len;
53145         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
53146         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
53147         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
53148         int64_t ret_ref = 0;
53149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53151         return ret_ref;
53152 }
53153
53154 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
53155         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
53156         int64_t ret_ref = 0;
53157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53158         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53159         return ret_ref;
53160 }
53161 int64_t  CS_LDK_InvalidShutdownScript_clone_ptr(int64_t arg) {
53162         LDKInvalidShutdownScript arg_conv;
53163         arg_conv.inner = untag_ptr(arg);
53164         arg_conv.is_owned = ptr_is_owned(arg);
53165         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53166         arg_conv.is_owned = false;
53167         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
53168         return ret_conv;
53169 }
53170
53171 int64_t  CS_LDK_InvalidShutdownScript_clone(int64_t orig) {
53172         LDKInvalidShutdownScript orig_conv;
53173         orig_conv.inner = untag_ptr(orig);
53174         orig_conv.is_owned = ptr_is_owned(orig);
53175         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53176         orig_conv.is_owned = false;
53177         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
53178         int64_t ret_ref = 0;
53179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53181         return ret_ref;
53182 }
53183
53184 int8_tArray  CS_LDK_ShutdownScript_write(int64_t obj) {
53185         LDKShutdownScript obj_conv;
53186         obj_conv.inner = untag_ptr(obj);
53187         obj_conv.is_owned = ptr_is_owned(obj);
53188         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53189         obj_conv.is_owned = false;
53190         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
53191         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53192         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53193         CVec_u8Z_free(ret_var);
53194         return ret_arr;
53195 }
53196
53197 int64_t  CS_LDK_ShutdownScript_read(int8_tArray ser) {
53198         LDKu8slice ser_ref;
53199         ser_ref.datalen = ser->arr_len;
53200         ser_ref.data = ser->elems;
53201         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
53202         *ret_conv = ShutdownScript_read(ser_ref);
53203         FREE(ser);
53204         return tag_ptr(ret_conv, true);
53205 }
53206
53207 int64_t  CS_LDK_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
53208         uint8_t pubkey_hash_arr[20];
53209         CHECK(pubkey_hash->arr_len == 20);
53210         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
53211         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
53212         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
53213         int64_t ret_ref = 0;
53214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53215         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53216         return ret_ref;
53217 }
53218
53219 int64_t  CS_LDK_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
53220         uint8_t script_hash_arr[32];
53221         CHECK(script_hash->arr_len == 32);
53222         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
53223         uint8_t (*script_hash_ref)[32] = &script_hash_arr;
53224         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
53225         int64_t ret_ref = 0;
53226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53227         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53228         return ret_ref;
53229 }
53230
53231 int64_t  CS_LDK_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
53232         
53233         LDKu8slice program_ref;
53234         program_ref.datalen = program->arr_len;
53235         program_ref.data = program->elems;
53236         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
53237         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
53238         FREE(program);
53239         return tag_ptr(ret_conv, true);
53240 }
53241
53242 int8_tArray  CS_LDK_ShutdownScript_into_inner(int64_t this_arg) {
53243         LDKShutdownScript this_arg_conv;
53244         this_arg_conv.inner = untag_ptr(this_arg);
53245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53247         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
53248         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
53249         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53250         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53251         CVec_u8Z_free(ret_var);
53252         return ret_arr;
53253 }
53254
53255 int8_tArray  CS_LDK_ShutdownScript_as_legacy_pubkey(int64_t this_arg) {
53256         LDKShutdownScript this_arg_conv;
53257         this_arg_conv.inner = untag_ptr(this_arg);
53258         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53260         this_arg_conv.is_owned = false;
53261         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
53262         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
53263         return ret_arr;
53264 }
53265
53266 jboolean  CS_LDK_ShutdownScript_is_compatible(int64_t this_arg, int64_t features) {
53267         LDKShutdownScript this_arg_conv;
53268         this_arg_conv.inner = untag_ptr(this_arg);
53269         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53271         this_arg_conv.is_owned = false;
53272         LDKInitFeatures features_conv;
53273         features_conv.inner = untag_ptr(features);
53274         features_conv.is_owned = ptr_is_owned(features);
53275         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
53276         features_conv.is_owned = false;
53277         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
53278         return ret_conv;
53279 }
53280
53281 void  CS_LDK_Retry_free(int64_t this_ptr) {
53282         if (!ptr_is_owned(this_ptr)) return;
53283         void* this_ptr_ptr = untag_ptr(this_ptr);
53284         CHECK_ACCESS(this_ptr_ptr);
53285         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
53286         FREE(untag_ptr(this_ptr));
53287         Retry_free(this_ptr_conv);
53288 }
53289
53290 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
53291         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53292         *ret_copy = Retry_clone(arg);
53293         int64_t ret_ref = tag_ptr(ret_copy, true);
53294         return ret_ref;
53295 }
53296 int64_t  CS_LDK_Retry_clone_ptr(int64_t arg) {
53297         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
53298         int64_t ret_conv = Retry_clone_ptr(arg_conv);
53299         return ret_conv;
53300 }
53301
53302 int64_t  CS_LDK_Retry_clone(int64_t orig) {
53303         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
53304         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53305         *ret_copy = Retry_clone(orig_conv);
53306         int64_t ret_ref = tag_ptr(ret_copy, true);
53307         return ret_ref;
53308 }
53309
53310 int64_t  CS_LDK_Retry_attempts(int32_t a) {
53311         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53312         *ret_copy = Retry_attempts(a);
53313         int64_t ret_ref = tag_ptr(ret_copy, true);
53314         return ret_ref;
53315 }
53316
53317 int64_t  CS_LDK_Retry_timeout(int64_t a) {
53318         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
53319         *ret_copy = Retry_timeout(a);
53320         int64_t ret_ref = tag_ptr(ret_copy, true);
53321         return ret_ref;
53322 }
53323
53324 jboolean  CS_LDK_Retry_eq(int64_t a, int64_t b) {
53325         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
53326         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
53327         jboolean ret_conv = Retry_eq(a_conv, b_conv);
53328         return ret_conv;
53329 }
53330
53331 int64_t  CS_LDK_Retry_hash(int64_t o) {
53332         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
53333         int64_t ret_conv = Retry_hash(o_conv);
53334         return ret_conv;
53335 }
53336
53337 int8_tArray  CS_LDK_Retry_write(int64_t obj) {
53338         LDKRetry* obj_conv = (LDKRetry*)untag_ptr(obj);
53339         LDKCVec_u8Z ret_var = Retry_write(obj_conv);
53340         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53341         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53342         CVec_u8Z_free(ret_var);
53343         return ret_arr;
53344 }
53345
53346 int64_t  CS_LDK_Retry_read(int8_tArray ser) {
53347         LDKu8slice ser_ref;
53348         ser_ref.datalen = ser->arr_len;
53349         ser_ref.data = ser->elems;
53350         LDKCResult_RetryDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RetryDecodeErrorZ), "LDKCResult_RetryDecodeErrorZ");
53351         *ret_conv = Retry_read(ser_ref);
53352         FREE(ser);
53353         return tag_ptr(ret_conv, true);
53354 }
53355
53356 int32_t  CS_LDK_RetryableSendFailure_clone(int64_t orig) {
53357         LDKRetryableSendFailure* orig_conv = (LDKRetryableSendFailure*)untag_ptr(orig);
53358         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_clone(orig_conv));
53359         return ret_conv;
53360 }
53361
53362 int32_t  CS_LDK_RetryableSendFailure_payment_expired() {
53363         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_payment_expired());
53364         return ret_conv;
53365 }
53366
53367 int32_t  CS_LDK_RetryableSendFailure_route_not_found() {
53368         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_route_not_found());
53369         return ret_conv;
53370 }
53371
53372 int32_t  CS_LDK_RetryableSendFailure_duplicate_payment() {
53373         int32_t ret_conv = LDKRetryableSendFailure_to_cs(RetryableSendFailure_duplicate_payment());
53374         return ret_conv;
53375 }
53376
53377 jboolean  CS_LDK_RetryableSendFailure_eq(int64_t a, int64_t b) {
53378         LDKRetryableSendFailure* a_conv = (LDKRetryableSendFailure*)untag_ptr(a);
53379         LDKRetryableSendFailure* b_conv = (LDKRetryableSendFailure*)untag_ptr(b);
53380         jboolean ret_conv = RetryableSendFailure_eq(a_conv, b_conv);
53381         return ret_conv;
53382 }
53383
53384 void  CS_LDK_PaymentSendFailure_free(int64_t this_ptr) {
53385         if (!ptr_is_owned(this_ptr)) return;
53386         void* this_ptr_ptr = untag_ptr(this_ptr);
53387         CHECK_ACCESS(this_ptr_ptr);
53388         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
53389         FREE(untag_ptr(this_ptr));
53390         PaymentSendFailure_free(this_ptr_conv);
53391 }
53392
53393 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
53394         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53395         *ret_copy = PaymentSendFailure_clone(arg);
53396         int64_t ret_ref = tag_ptr(ret_copy, true);
53397         return ret_ref;
53398 }
53399 int64_t  CS_LDK_PaymentSendFailure_clone_ptr(int64_t arg) {
53400         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
53401         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
53402         return ret_conv;
53403 }
53404
53405 int64_t  CS_LDK_PaymentSendFailure_clone(int64_t orig) {
53406         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
53407         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53408         *ret_copy = PaymentSendFailure_clone(orig_conv);
53409         int64_t ret_ref = tag_ptr(ret_copy, true);
53410         return ret_ref;
53411 }
53412
53413 int64_t  CS_LDK_PaymentSendFailure_parameter_error(int64_t a) {
53414         void* a_ptr = untag_ptr(a);
53415         CHECK_ACCESS(a_ptr);
53416         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
53417         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
53418         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53419         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
53420         int64_t ret_ref = tag_ptr(ret_copy, true);
53421         return ret_ref;
53422 }
53423
53424 int64_t  CS_LDK_PaymentSendFailure_path_parameter_error(int64_tArray a) {
53425         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
53426         a_constr.datalen = a->arr_len;
53427         if (a_constr.datalen > 0)
53428                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
53429         else
53430                 a_constr.data = NULL;
53431         int64_t* a_vals = a->elems;
53432         for (size_t w = 0; w < a_constr.datalen; w++) {
53433                 int64_t a_conv_22 = a_vals[w];
53434                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
53435                 CHECK_ACCESS(a_conv_22_ptr);
53436                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
53437                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
53438                 a_constr.data[w] = a_conv_22_conv;
53439         }
53440         FREE(a);
53441         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53442         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
53443         int64_t ret_ref = tag_ptr(ret_copy, true);
53444         return ret_ref;
53445 }
53446
53447 int64_t  CS_LDK_PaymentSendFailure_all_failed_resend_safe(int64_tArray a) {
53448         LDKCVec_APIErrorZ a_constr;
53449         a_constr.datalen = a->arr_len;
53450         if (a_constr.datalen > 0)
53451                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
53452         else
53453                 a_constr.data = NULL;
53454         int64_t* a_vals = a->elems;
53455         for (size_t k = 0; k < a_constr.datalen; k++) {
53456                 int64_t a_conv_10 = a_vals[k];
53457                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
53458                 CHECK_ACCESS(a_conv_10_ptr);
53459                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
53460                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
53461                 a_constr.data[k] = a_conv_10_conv;
53462         }
53463         FREE(a);
53464         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53465         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
53466         int64_t ret_ref = tag_ptr(ret_copy, true);
53467         return ret_ref;
53468 }
53469
53470 int64_t  CS_LDK_PaymentSendFailure_duplicate_payment() {
53471         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53472         *ret_copy = PaymentSendFailure_duplicate_payment();
53473         int64_t ret_ref = tag_ptr(ret_copy, true);
53474         return ret_ref;
53475 }
53476
53477 int64_t  CS_LDK_PaymentSendFailure_partial_failure(int64_tArray results, int64_t failed_paths_retry, int8_tArray payment_id) {
53478         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
53479         results_constr.datalen = results->arr_len;
53480         if (results_constr.datalen > 0)
53481                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
53482         else
53483                 results_constr.data = NULL;
53484         int64_t* results_vals = results->elems;
53485         for (size_t w = 0; w < results_constr.datalen; w++) {
53486                 int64_t results_conv_22 = results_vals[w];
53487                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
53488                 CHECK_ACCESS(results_conv_22_ptr);
53489                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
53490                 results_constr.data[w] = results_conv_22_conv;
53491         }
53492         FREE(results);
53493         LDKRouteParameters failed_paths_retry_conv;
53494         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
53495         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
53496         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
53497         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
53498         LDKThirtyTwoBytes payment_id_ref;
53499         CHECK(payment_id->arr_len == 32);
53500         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
53501         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
53502         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
53503         int64_t ret_ref = tag_ptr(ret_copy, true);
53504         return ret_ref;
53505 }
53506
53507 jboolean  CS_LDK_PaymentSendFailure_eq(int64_t a, int64_t b) {
53508         LDKPaymentSendFailure* a_conv = (LDKPaymentSendFailure*)untag_ptr(a);
53509         LDKPaymentSendFailure* b_conv = (LDKPaymentSendFailure*)untag_ptr(b);
53510         jboolean ret_conv = PaymentSendFailure_eq(a_conv, b_conv);
53511         return ret_conv;
53512 }
53513
53514 void  CS_LDK_ProbeSendFailure_free(int64_t this_ptr) {
53515         if (!ptr_is_owned(this_ptr)) return;
53516         void* this_ptr_ptr = untag_ptr(this_ptr);
53517         CHECK_ACCESS(this_ptr_ptr);
53518         LDKProbeSendFailure this_ptr_conv = *(LDKProbeSendFailure*)(this_ptr_ptr);
53519         FREE(untag_ptr(this_ptr));
53520         ProbeSendFailure_free(this_ptr_conv);
53521 }
53522
53523 static inline uint64_t ProbeSendFailure_clone_ptr(LDKProbeSendFailure *NONNULL_PTR arg) {
53524         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53525         *ret_copy = ProbeSendFailure_clone(arg);
53526         int64_t ret_ref = tag_ptr(ret_copy, true);
53527         return ret_ref;
53528 }
53529 int64_t  CS_LDK_ProbeSendFailure_clone_ptr(int64_t arg) {
53530         LDKProbeSendFailure* arg_conv = (LDKProbeSendFailure*)untag_ptr(arg);
53531         int64_t ret_conv = ProbeSendFailure_clone_ptr(arg_conv);
53532         return ret_conv;
53533 }
53534
53535 int64_t  CS_LDK_ProbeSendFailure_clone(int64_t orig) {
53536         LDKProbeSendFailure* orig_conv = (LDKProbeSendFailure*)untag_ptr(orig);
53537         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53538         *ret_copy = ProbeSendFailure_clone(orig_conv);
53539         int64_t ret_ref = tag_ptr(ret_copy, true);
53540         return ret_ref;
53541 }
53542
53543 int64_t  CS_LDK_ProbeSendFailure_route_not_found() {
53544         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53545         *ret_copy = ProbeSendFailure_route_not_found();
53546         int64_t ret_ref = tag_ptr(ret_copy, true);
53547         return ret_ref;
53548 }
53549
53550 int64_t  CS_LDK_ProbeSendFailure_sending_failed(int64_t a) {
53551         void* a_ptr = untag_ptr(a);
53552         CHECK_ACCESS(a_ptr);
53553         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
53554         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
53555         LDKProbeSendFailure *ret_copy = MALLOC(sizeof(LDKProbeSendFailure), "LDKProbeSendFailure");
53556         *ret_copy = ProbeSendFailure_sending_failed(a_conv);
53557         int64_t ret_ref = tag_ptr(ret_copy, true);
53558         return ret_ref;
53559 }
53560
53561 jboolean  CS_LDK_ProbeSendFailure_eq(int64_t a, int64_t b) {
53562         LDKProbeSendFailure* a_conv = (LDKProbeSendFailure*)untag_ptr(a);
53563         LDKProbeSendFailure* b_conv = (LDKProbeSendFailure*)untag_ptr(b);
53564         jboolean ret_conv = ProbeSendFailure_eq(a_conv, b_conv);
53565         return ret_conv;
53566 }
53567
53568 void  CS_LDK_RecipientOnionFields_free(int64_t this_obj) {
53569         LDKRecipientOnionFields this_obj_conv;
53570         this_obj_conv.inner = untag_ptr(this_obj);
53571         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53573         RecipientOnionFields_free(this_obj_conv);
53574 }
53575
53576 int64_t  CS_LDK_RecipientOnionFields_get_payment_secret(int64_t this_ptr) {
53577         LDKRecipientOnionFields this_ptr_conv;
53578         this_ptr_conv.inner = untag_ptr(this_ptr);
53579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53581         this_ptr_conv.is_owned = false;
53582         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
53583         *ret_copy = RecipientOnionFields_get_payment_secret(&this_ptr_conv);
53584         int64_t ret_ref = tag_ptr(ret_copy, true);
53585         return ret_ref;
53586 }
53587
53588 void  CS_LDK_RecipientOnionFields_set_payment_secret(int64_t this_ptr, int64_t val) {
53589         LDKRecipientOnionFields this_ptr_conv;
53590         this_ptr_conv.inner = untag_ptr(this_ptr);
53591         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53593         this_ptr_conv.is_owned = false;
53594         void* val_ptr = untag_ptr(val);
53595         CHECK_ACCESS(val_ptr);
53596         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
53597         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
53598         RecipientOnionFields_set_payment_secret(&this_ptr_conv, val_conv);
53599 }
53600
53601 int64_t  CS_LDK_RecipientOnionFields_get_payment_metadata(int64_t this_ptr) {
53602         LDKRecipientOnionFields this_ptr_conv;
53603         this_ptr_conv.inner = untag_ptr(this_ptr);
53604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53606         this_ptr_conv.is_owned = false;
53607         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
53608         *ret_copy = RecipientOnionFields_get_payment_metadata(&this_ptr_conv);
53609         int64_t ret_ref = tag_ptr(ret_copy, true);
53610         return ret_ref;
53611 }
53612
53613 void  CS_LDK_RecipientOnionFields_set_payment_metadata(int64_t this_ptr, int64_t val) {
53614         LDKRecipientOnionFields this_ptr_conv;
53615         this_ptr_conv.inner = untag_ptr(this_ptr);
53616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
53617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
53618         this_ptr_conv.is_owned = false;
53619         void* val_ptr = untag_ptr(val);
53620         CHECK_ACCESS(val_ptr);
53621         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
53622         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
53623         RecipientOnionFields_set_payment_metadata(&this_ptr_conv, val_conv);
53624 }
53625
53626 static inline uint64_t RecipientOnionFields_clone_ptr(LDKRecipientOnionFields *NONNULL_PTR arg) {
53627         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(arg);
53628         int64_t ret_ref = 0;
53629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53631         return ret_ref;
53632 }
53633 int64_t  CS_LDK_RecipientOnionFields_clone_ptr(int64_t arg) {
53634         LDKRecipientOnionFields arg_conv;
53635         arg_conv.inner = untag_ptr(arg);
53636         arg_conv.is_owned = ptr_is_owned(arg);
53637         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53638         arg_conv.is_owned = false;
53639         int64_t ret_conv = RecipientOnionFields_clone_ptr(&arg_conv);
53640         return ret_conv;
53641 }
53642
53643 int64_t  CS_LDK_RecipientOnionFields_clone(int64_t orig) {
53644         LDKRecipientOnionFields orig_conv;
53645         orig_conv.inner = untag_ptr(orig);
53646         orig_conv.is_owned = ptr_is_owned(orig);
53647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53648         orig_conv.is_owned = false;
53649         LDKRecipientOnionFields ret_var = RecipientOnionFields_clone(&orig_conv);
53650         int64_t ret_ref = 0;
53651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53652         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53653         return ret_ref;
53654 }
53655
53656 jboolean  CS_LDK_RecipientOnionFields_eq(int64_t a, int64_t b) {
53657         LDKRecipientOnionFields a_conv;
53658         a_conv.inner = untag_ptr(a);
53659         a_conv.is_owned = ptr_is_owned(a);
53660         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53661         a_conv.is_owned = false;
53662         LDKRecipientOnionFields b_conv;
53663         b_conv.inner = untag_ptr(b);
53664         b_conv.is_owned = ptr_is_owned(b);
53665         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
53666         b_conv.is_owned = false;
53667         jboolean ret_conv = RecipientOnionFields_eq(&a_conv, &b_conv);
53668         return ret_conv;
53669 }
53670
53671 int8_tArray  CS_LDK_RecipientOnionFields_write(int64_t obj) {
53672         LDKRecipientOnionFields obj_conv;
53673         obj_conv.inner = untag_ptr(obj);
53674         obj_conv.is_owned = ptr_is_owned(obj);
53675         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
53676         obj_conv.is_owned = false;
53677         LDKCVec_u8Z ret_var = RecipientOnionFields_write(&obj_conv);
53678         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
53679         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
53680         CVec_u8Z_free(ret_var);
53681         return ret_arr;
53682 }
53683
53684 int64_t  CS_LDK_RecipientOnionFields_read(int8_tArray ser) {
53685         LDKu8slice ser_ref;
53686         ser_ref.datalen = ser->arr_len;
53687         ser_ref.data = ser->elems;
53688         LDKCResult_RecipientOnionFieldsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsDecodeErrorZ), "LDKCResult_RecipientOnionFieldsDecodeErrorZ");
53689         *ret_conv = RecipientOnionFields_read(ser_ref);
53690         FREE(ser);
53691         return tag_ptr(ret_conv, true);
53692 }
53693
53694 int64_t  CS_LDK_RecipientOnionFields_secret_only(int8_tArray payment_secret) {
53695         LDKThirtyTwoBytes payment_secret_ref;
53696         CHECK(payment_secret->arr_len == 32);
53697         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
53698         LDKRecipientOnionFields ret_var = RecipientOnionFields_secret_only(payment_secret_ref);
53699         int64_t ret_ref = 0;
53700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53701         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53702         return ret_ref;
53703 }
53704
53705 int64_t  CS_LDK_RecipientOnionFields_spontaneous_empty() {
53706         LDKRecipientOnionFields ret_var = RecipientOnionFields_spontaneous_empty();
53707         int64_t ret_ref = 0;
53708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53710         return ret_ref;
53711 }
53712
53713 int64_t  CS_LDK_RecipientOnionFields_with_custom_tlvs(int64_t this_arg, int64_tArray custom_tlvs) {
53714         LDKRecipientOnionFields this_arg_conv;
53715         this_arg_conv.inner = untag_ptr(this_arg);
53716         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53718         this_arg_conv = RecipientOnionFields_clone(&this_arg_conv);
53719         LDKCVec_C2Tuple_u64CVec_u8ZZZ custom_tlvs_constr;
53720         custom_tlvs_constr.datalen = custom_tlvs->arr_len;
53721         if (custom_tlvs_constr.datalen > 0)
53722                 custom_tlvs_constr.data = MALLOC(custom_tlvs_constr.datalen * sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKCVec_C2Tuple_u64CVec_u8ZZZ Elements");
53723         else
53724                 custom_tlvs_constr.data = NULL;
53725         int64_t* custom_tlvs_vals = custom_tlvs->elems;
53726         for (size_t x = 0; x < custom_tlvs_constr.datalen; x++) {
53727                 int64_t custom_tlvs_conv_23 = custom_tlvs_vals[x];
53728                 void* custom_tlvs_conv_23_ptr = untag_ptr(custom_tlvs_conv_23);
53729                 CHECK_ACCESS(custom_tlvs_conv_23_ptr);
53730                 LDKC2Tuple_u64CVec_u8ZZ custom_tlvs_conv_23_conv = *(LDKC2Tuple_u64CVec_u8ZZ*)(custom_tlvs_conv_23_ptr);
53731                 custom_tlvs_conv_23_conv = C2Tuple_u64CVec_u8ZZ_clone((LDKC2Tuple_u64CVec_u8ZZ*)untag_ptr(custom_tlvs_conv_23));
53732                 custom_tlvs_constr.data[x] = custom_tlvs_conv_23_conv;
53733         }
53734         FREE(custom_tlvs);
53735         LDKCResult_RecipientOnionFieldsNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecipientOnionFieldsNoneZ), "LDKCResult_RecipientOnionFieldsNoneZ");
53736         *ret_conv = RecipientOnionFields_with_custom_tlvs(this_arg_conv, custom_tlvs_constr);
53737         return tag_ptr(ret_conv, true);
53738 }
53739
53740 int64_tArray  CS_LDK_RecipientOnionFields_custom_tlvs(int64_t this_arg) {
53741         LDKRecipientOnionFields this_arg_conv;
53742         this_arg_conv.inner = untag_ptr(this_arg);
53743         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53745         this_arg_conv.is_owned = false;
53746         LDKCVec_C2Tuple_u64CVec_u8ZZZ ret_var = RecipientOnionFields_custom_tlvs(&this_arg_conv);
53747         int64_tArray ret_arr = NULL;
53748         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
53749         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
53750         for (size_t x = 0; x < ret_var.datalen; x++) {
53751                 LDKC2Tuple_u64CVec_u8ZZ* ret_conv_23_conv = MALLOC(sizeof(LDKC2Tuple_u64CVec_u8ZZ), "LDKC2Tuple_u64CVec_u8ZZ");
53752                 *ret_conv_23_conv = ret_var.data[x];
53753                 ret_arr_ptr[x] = tag_ptr(ret_conv_23_conv, true);
53754         }
53755         
53756         FREE(ret_var.data);
53757         return ret_arr;
53758 }
53759
53760 void  CS_LDK_CustomMessageReader_free(int64_t this_ptr) {
53761         if (!ptr_is_owned(this_ptr)) return;
53762         void* this_ptr_ptr = untag_ptr(this_ptr);
53763         CHECK_ACCESS(this_ptr_ptr);
53764         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
53765         FREE(untag_ptr(this_ptr));
53766         CustomMessageReader_free(this_ptr_conv);
53767 }
53768
53769 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
53770         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
53771         *ret_ret = Type_clone(arg);
53772         return tag_ptr(ret_ret, true);
53773 }
53774 int64_t  CS_LDK_Type_clone_ptr(int64_t arg) {
53775         void* arg_ptr = untag_ptr(arg);
53776         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
53777         LDKType* arg_conv = (LDKType*)arg_ptr;
53778         int64_t ret_conv = Type_clone_ptr(arg_conv);
53779         return ret_conv;
53780 }
53781
53782 int64_t  CS_LDK_Type_clone(int64_t orig) {
53783         void* orig_ptr = untag_ptr(orig);
53784         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
53785         LDKType* orig_conv = (LDKType*)orig_ptr;
53786         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
53787         *ret_ret = Type_clone(orig_conv);
53788         return tag_ptr(ret_ret, true);
53789 }
53790
53791 void  CS_LDK_Type_free(int64_t this_ptr) {
53792         if (!ptr_is_owned(this_ptr)) return;
53793         void* this_ptr_ptr = untag_ptr(this_ptr);
53794         CHECK_ACCESS(this_ptr_ptr);
53795         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
53796         FREE(untag_ptr(this_ptr));
53797         Type_free(this_ptr_conv);
53798 }
53799
53800 void  CS_LDK_Offer_free(int64_t this_obj) {
53801         LDKOffer this_obj_conv;
53802         this_obj_conv.inner = untag_ptr(this_obj);
53803         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53805         Offer_free(this_obj_conv);
53806 }
53807
53808 static inline uint64_t Offer_clone_ptr(LDKOffer *NONNULL_PTR arg) {
53809         LDKOffer ret_var = Offer_clone(arg);
53810         int64_t ret_ref = 0;
53811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53813         return ret_ref;
53814 }
53815 int64_t  CS_LDK_Offer_clone_ptr(int64_t arg) {
53816         LDKOffer arg_conv;
53817         arg_conv.inner = untag_ptr(arg);
53818         arg_conv.is_owned = ptr_is_owned(arg);
53819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
53820         arg_conv.is_owned = false;
53821         int64_t ret_conv = Offer_clone_ptr(&arg_conv);
53822         return ret_conv;
53823 }
53824
53825 int64_t  CS_LDK_Offer_clone(int64_t orig) {
53826         LDKOffer orig_conv;
53827         orig_conv.inner = untag_ptr(orig);
53828         orig_conv.is_owned = ptr_is_owned(orig);
53829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
53830         orig_conv.is_owned = false;
53831         LDKOffer ret_var = Offer_clone(&orig_conv);
53832         int64_t ret_ref = 0;
53833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53835         return ret_ref;
53836 }
53837
53838 ptrArray  CS_LDK_Offer_chains(int64_t this_arg) {
53839         LDKOffer this_arg_conv;
53840         this_arg_conv.inner = untag_ptr(this_arg);
53841         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53843         this_arg_conv.is_owned = false;
53844         LDKCVec_ThirtyTwoBytesZ ret_var = Offer_chains(&this_arg_conv);
53845         ptrArray ret_arr = NULL;
53846         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
53847         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
53848         for (size_t i = 0; i < ret_var.datalen; i++) {
53849                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
53850                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
53851                 ret_arr_ptr[i] = ret_conv_8_arr;
53852         }
53853         
53854         FREE(ret_var.data);
53855         return ret_arr;
53856 }
53857
53858 int64_t  CS_LDK_Offer_metadata(int64_t this_arg) {
53859         LDKOffer this_arg_conv;
53860         this_arg_conv.inner = untag_ptr(this_arg);
53861         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53863         this_arg_conv.is_owned = false;
53864         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
53865         *ret_copy = Offer_metadata(&this_arg_conv);
53866         int64_t ret_ref = tag_ptr(ret_copy, true);
53867         return ret_ref;
53868 }
53869
53870 int64_t  CS_LDK_Offer_amount(int64_t this_arg) {
53871         LDKOffer this_arg_conv;
53872         this_arg_conv.inner = untag_ptr(this_arg);
53873         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53875         this_arg_conv.is_owned = false;
53876         LDKAmount ret_var = Offer_amount(&this_arg_conv);
53877         int64_t ret_ref = 0;
53878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53880         return ret_ref;
53881 }
53882
53883 int64_t  CS_LDK_Offer_description(int64_t this_arg) {
53884         LDKOffer this_arg_conv;
53885         this_arg_conv.inner = untag_ptr(this_arg);
53886         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53888         this_arg_conv.is_owned = false;
53889         LDKPrintableString ret_var = Offer_description(&this_arg_conv);
53890         int64_t ret_ref = 0;
53891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53892         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53893         return ret_ref;
53894 }
53895
53896 int64_t  CS_LDK_Offer_offer_features(int64_t this_arg) {
53897         LDKOffer this_arg_conv;
53898         this_arg_conv.inner = untag_ptr(this_arg);
53899         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53901         this_arg_conv.is_owned = false;
53902         LDKOfferFeatures ret_var = Offer_offer_features(&this_arg_conv);
53903         int64_t ret_ref = 0;
53904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53906         return ret_ref;
53907 }
53908
53909 int64_t  CS_LDK_Offer_absolute_expiry(int64_t this_arg) {
53910         LDKOffer this_arg_conv;
53911         this_arg_conv.inner = untag_ptr(this_arg);
53912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53914         this_arg_conv.is_owned = false;
53915         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
53916         *ret_copy = Offer_absolute_expiry(&this_arg_conv);
53917         int64_t ret_ref = tag_ptr(ret_copy, true);
53918         return ret_ref;
53919 }
53920
53921 int64_t  CS_LDK_Offer_issuer(int64_t this_arg) {
53922         LDKOffer this_arg_conv;
53923         this_arg_conv.inner = untag_ptr(this_arg);
53924         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53926         this_arg_conv.is_owned = false;
53927         LDKPrintableString ret_var = Offer_issuer(&this_arg_conv);
53928         int64_t ret_ref = 0;
53929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53931         return ret_ref;
53932 }
53933
53934 int64_tArray  CS_LDK_Offer_paths(int64_t this_arg) {
53935         LDKOffer this_arg_conv;
53936         this_arg_conv.inner = untag_ptr(this_arg);
53937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53939         this_arg_conv.is_owned = false;
53940         LDKCVec_BlindedPathZ ret_var = Offer_paths(&this_arg_conv);
53941         int64_tArray ret_arr = NULL;
53942         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
53943         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
53944         for (size_t n = 0; n < ret_var.datalen; n++) {
53945                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
53946                 int64_t ret_conv_13_ref = 0;
53947                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
53948                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
53949                 ret_arr_ptr[n] = ret_conv_13_ref;
53950         }
53951         
53952         FREE(ret_var.data);
53953         return ret_arr;
53954 }
53955
53956 int64_t  CS_LDK_Offer_supported_quantity(int64_t this_arg) {
53957         LDKOffer this_arg_conv;
53958         this_arg_conv.inner = untag_ptr(this_arg);
53959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53961         this_arg_conv.is_owned = false;
53962         LDKQuantity ret_var = Offer_supported_quantity(&this_arg_conv);
53963         int64_t ret_ref = 0;
53964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53965         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53966         return ret_ref;
53967 }
53968
53969 int8_tArray  CS_LDK_Offer_signing_pubkey(int64_t this_arg) {
53970         LDKOffer this_arg_conv;
53971         this_arg_conv.inner = untag_ptr(this_arg);
53972         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53974         this_arg_conv.is_owned = false;
53975         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
53976         memcpy(ret_arr->elems, Offer_signing_pubkey(&this_arg_conv).compressed_form, 33);
53977         return ret_arr;
53978 }
53979
53980 jboolean  CS_LDK_Offer_supports_chain(int64_t this_arg, int8_tArray chain) {
53981         LDKOffer this_arg_conv;
53982         this_arg_conv.inner = untag_ptr(this_arg);
53983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53985         this_arg_conv.is_owned = false;
53986         LDKThirtyTwoBytes chain_ref;
53987         CHECK(chain->arr_len == 32);
53988         memcpy(chain_ref.data, chain->elems, 32); FREE(chain);
53989         jboolean ret_conv = Offer_supports_chain(&this_arg_conv, chain_ref);
53990         return ret_conv;
53991 }
53992
53993 jboolean  CS_LDK_Offer_is_expired(int64_t this_arg) {
53994         LDKOffer this_arg_conv;
53995         this_arg_conv.inner = untag_ptr(this_arg);
53996         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53998         this_arg_conv.is_owned = false;
53999         jboolean ret_conv = Offer_is_expired(&this_arg_conv);
54000         return ret_conv;
54001 }
54002
54003 jboolean  CS_LDK_Offer_is_valid_quantity(int64_t this_arg, int64_t quantity) {
54004         LDKOffer this_arg_conv;
54005         this_arg_conv.inner = untag_ptr(this_arg);
54006         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54008         this_arg_conv.is_owned = false;
54009         jboolean ret_conv = Offer_is_valid_quantity(&this_arg_conv, quantity);
54010         return ret_conv;
54011 }
54012
54013 jboolean  CS_LDK_Offer_expects_quantity(int64_t this_arg) {
54014         LDKOffer this_arg_conv;
54015         this_arg_conv.inner = untag_ptr(this_arg);
54016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54018         this_arg_conv.is_owned = false;
54019         jboolean ret_conv = Offer_expects_quantity(&this_arg_conv);
54020         return ret_conv;
54021 }
54022
54023 int8_tArray  CS_LDK_Offer_write(int64_t obj) {
54024         LDKOffer obj_conv;
54025         obj_conv.inner = untag_ptr(obj);
54026         obj_conv.is_owned = ptr_is_owned(obj);
54027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54028         obj_conv.is_owned = false;
54029         LDKCVec_u8Z ret_var = Offer_write(&obj_conv);
54030         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54031         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54032         CVec_u8Z_free(ret_var);
54033         return ret_arr;
54034 }
54035
54036 void  CS_LDK_Amount_free(int64_t this_obj) {
54037         LDKAmount this_obj_conv;
54038         this_obj_conv.inner = untag_ptr(this_obj);
54039         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54041         Amount_free(this_obj_conv);
54042 }
54043
54044 static inline uint64_t Amount_clone_ptr(LDKAmount *NONNULL_PTR arg) {
54045         LDKAmount ret_var = Amount_clone(arg);
54046         int64_t ret_ref = 0;
54047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54049         return ret_ref;
54050 }
54051 int64_t  CS_LDK_Amount_clone_ptr(int64_t arg) {
54052         LDKAmount arg_conv;
54053         arg_conv.inner = untag_ptr(arg);
54054         arg_conv.is_owned = ptr_is_owned(arg);
54055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54056         arg_conv.is_owned = false;
54057         int64_t ret_conv = Amount_clone_ptr(&arg_conv);
54058         return ret_conv;
54059 }
54060
54061 int64_t  CS_LDK_Amount_clone(int64_t orig) {
54062         LDKAmount orig_conv;
54063         orig_conv.inner = untag_ptr(orig);
54064         orig_conv.is_owned = ptr_is_owned(orig);
54065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54066         orig_conv.is_owned = false;
54067         LDKAmount ret_var = Amount_clone(&orig_conv);
54068         int64_t ret_ref = 0;
54069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54070         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54071         return ret_ref;
54072 }
54073
54074 void  CS_LDK_Quantity_free(int64_t this_obj) {
54075         LDKQuantity this_obj_conv;
54076         this_obj_conv.inner = untag_ptr(this_obj);
54077         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54079         Quantity_free(this_obj_conv);
54080 }
54081
54082 static inline uint64_t Quantity_clone_ptr(LDKQuantity *NONNULL_PTR arg) {
54083         LDKQuantity ret_var = Quantity_clone(arg);
54084         int64_t ret_ref = 0;
54085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54087         return ret_ref;
54088 }
54089 int64_t  CS_LDK_Quantity_clone_ptr(int64_t arg) {
54090         LDKQuantity arg_conv;
54091         arg_conv.inner = untag_ptr(arg);
54092         arg_conv.is_owned = ptr_is_owned(arg);
54093         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54094         arg_conv.is_owned = false;
54095         int64_t ret_conv = Quantity_clone_ptr(&arg_conv);
54096         return ret_conv;
54097 }
54098
54099 int64_t  CS_LDK_Quantity_clone(int64_t orig) {
54100         LDKQuantity orig_conv;
54101         orig_conv.inner = untag_ptr(orig);
54102         orig_conv.is_owned = ptr_is_owned(orig);
54103         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54104         orig_conv.is_owned = false;
54105         LDKQuantity ret_var = Quantity_clone(&orig_conv);
54106         int64_t ret_ref = 0;
54107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54108         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54109         return ret_ref;
54110 }
54111
54112 int64_t  CS_LDK_Offer_from_str(jstring s) {
54113         LDKStr s_conv = str_ref_to_owned_c(s);
54114         LDKCResult_OfferBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferBolt12ParseErrorZ), "LDKCResult_OfferBolt12ParseErrorZ");
54115         *ret_conv = Offer_from_str(s_conv);
54116         return tag_ptr(ret_conv, true);
54117 }
54118
54119 void  CS_LDK_UnsignedBolt12Invoice_free(int64_t this_obj) {
54120         LDKUnsignedBolt12Invoice this_obj_conv;
54121         this_obj_conv.inner = untag_ptr(this_obj);
54122         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54124         UnsignedBolt12Invoice_free(this_obj_conv);
54125 }
54126
54127 int64_t  CS_LDK_UnsignedBolt12Invoice_tagged_hash(int64_t this_arg) {
54128         LDKUnsignedBolt12Invoice this_arg_conv;
54129         this_arg_conv.inner = untag_ptr(this_arg);
54130         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54132         this_arg_conv.is_owned = false;
54133         LDKTaggedHash ret_var = UnsignedBolt12Invoice_tagged_hash(&this_arg_conv);
54134         int64_t ret_ref = 0;
54135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54137         return ret_ref;
54138 }
54139
54140 void  CS_LDK_Bolt12Invoice_free(int64_t this_obj) {
54141         LDKBolt12Invoice this_obj_conv;
54142         this_obj_conv.inner = untag_ptr(this_obj);
54143         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54145         Bolt12Invoice_free(this_obj_conv);
54146 }
54147
54148 static inline uint64_t Bolt12Invoice_clone_ptr(LDKBolt12Invoice *NONNULL_PTR arg) {
54149         LDKBolt12Invoice ret_var = Bolt12Invoice_clone(arg);
54150         int64_t ret_ref = 0;
54151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54152         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54153         return ret_ref;
54154 }
54155 int64_t  CS_LDK_Bolt12Invoice_clone_ptr(int64_t arg) {
54156         LDKBolt12Invoice arg_conv;
54157         arg_conv.inner = untag_ptr(arg);
54158         arg_conv.is_owned = ptr_is_owned(arg);
54159         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54160         arg_conv.is_owned = false;
54161         int64_t ret_conv = Bolt12Invoice_clone_ptr(&arg_conv);
54162         return ret_conv;
54163 }
54164
54165 int64_t  CS_LDK_Bolt12Invoice_clone(int64_t orig) {
54166         LDKBolt12Invoice orig_conv;
54167         orig_conv.inner = untag_ptr(orig);
54168         orig_conv.is_owned = ptr_is_owned(orig);
54169         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54170         orig_conv.is_owned = false;
54171         LDKBolt12Invoice ret_var = Bolt12Invoice_clone(&orig_conv);
54172         int64_t ret_ref = 0;
54173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54175         return ret_ref;
54176 }
54177
54178 int64_t  CS_LDK_UnsignedBolt12Invoice_offer_chains(int64_t this_arg) {
54179         LDKUnsignedBolt12Invoice this_arg_conv;
54180         this_arg_conv.inner = untag_ptr(this_arg);
54181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54183         this_arg_conv.is_owned = false;
54184         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
54185         *ret_copy = UnsignedBolt12Invoice_offer_chains(&this_arg_conv);
54186         int64_t ret_ref = tag_ptr(ret_copy, true);
54187         return ret_ref;
54188 }
54189
54190 int8_tArray  CS_LDK_UnsignedBolt12Invoice_chain(int64_t this_arg) {
54191         LDKUnsignedBolt12Invoice this_arg_conv;
54192         this_arg_conv.inner = untag_ptr(this_arg);
54193         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54195         this_arg_conv.is_owned = false;
54196         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54197         memcpy(ret_arr->elems, UnsignedBolt12Invoice_chain(&this_arg_conv).data, 32);
54198         return ret_arr;
54199 }
54200
54201 int64_t  CS_LDK_UnsignedBolt12Invoice_metadata(int64_t this_arg) {
54202         LDKUnsignedBolt12Invoice this_arg_conv;
54203         this_arg_conv.inner = untag_ptr(this_arg);
54204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54206         this_arg_conv.is_owned = false;
54207         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
54208         *ret_copy = UnsignedBolt12Invoice_metadata(&this_arg_conv);
54209         int64_t ret_ref = tag_ptr(ret_copy, true);
54210         return ret_ref;
54211 }
54212
54213 int64_t  CS_LDK_UnsignedBolt12Invoice_amount(int64_t this_arg) {
54214         LDKUnsignedBolt12Invoice this_arg_conv;
54215         this_arg_conv.inner = untag_ptr(this_arg);
54216         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54218         this_arg_conv.is_owned = false;
54219         LDKAmount ret_var = UnsignedBolt12Invoice_amount(&this_arg_conv);
54220         int64_t ret_ref = 0;
54221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54223         return ret_ref;
54224 }
54225
54226 int64_t  CS_LDK_UnsignedBolt12Invoice_offer_features(int64_t this_arg) {
54227         LDKUnsignedBolt12Invoice this_arg_conv;
54228         this_arg_conv.inner = untag_ptr(this_arg);
54229         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54231         this_arg_conv.is_owned = false;
54232         LDKOfferFeatures ret_var = UnsignedBolt12Invoice_offer_features(&this_arg_conv);
54233         int64_t ret_ref = 0;
54234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54236         return ret_ref;
54237 }
54238
54239 int64_t  CS_LDK_UnsignedBolt12Invoice_description(int64_t this_arg) {
54240         LDKUnsignedBolt12Invoice this_arg_conv;
54241         this_arg_conv.inner = untag_ptr(this_arg);
54242         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54244         this_arg_conv.is_owned = false;
54245         LDKPrintableString ret_var = UnsignedBolt12Invoice_description(&this_arg_conv);
54246         int64_t ret_ref = 0;
54247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54248         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54249         return ret_ref;
54250 }
54251
54252 int64_t  CS_LDK_UnsignedBolt12Invoice_absolute_expiry(int64_t this_arg) {
54253         LDKUnsignedBolt12Invoice this_arg_conv;
54254         this_arg_conv.inner = untag_ptr(this_arg);
54255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54257         this_arg_conv.is_owned = false;
54258         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54259         *ret_copy = UnsignedBolt12Invoice_absolute_expiry(&this_arg_conv);
54260         int64_t ret_ref = tag_ptr(ret_copy, true);
54261         return ret_ref;
54262 }
54263
54264 int64_t  CS_LDK_UnsignedBolt12Invoice_issuer(int64_t this_arg) {
54265         LDKUnsignedBolt12Invoice this_arg_conv;
54266         this_arg_conv.inner = untag_ptr(this_arg);
54267         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54269         this_arg_conv.is_owned = false;
54270         LDKPrintableString ret_var = UnsignedBolt12Invoice_issuer(&this_arg_conv);
54271         int64_t ret_ref = 0;
54272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54273         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54274         return ret_ref;
54275 }
54276
54277 int64_tArray  CS_LDK_UnsignedBolt12Invoice_message_paths(int64_t this_arg) {
54278         LDKUnsignedBolt12Invoice this_arg_conv;
54279         this_arg_conv.inner = untag_ptr(this_arg);
54280         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54282         this_arg_conv.is_owned = false;
54283         LDKCVec_BlindedPathZ ret_var = UnsignedBolt12Invoice_message_paths(&this_arg_conv);
54284         int64_tArray ret_arr = NULL;
54285         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
54286         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
54287         for (size_t n = 0; n < ret_var.datalen; n++) {
54288                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
54289                 int64_t ret_conv_13_ref = 0;
54290                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
54291                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
54292                 ret_arr_ptr[n] = ret_conv_13_ref;
54293         }
54294         
54295         FREE(ret_var.data);
54296         return ret_arr;
54297 }
54298
54299 int64_t  CS_LDK_UnsignedBolt12Invoice_supported_quantity(int64_t this_arg) {
54300         LDKUnsignedBolt12Invoice this_arg_conv;
54301         this_arg_conv.inner = untag_ptr(this_arg);
54302         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54304         this_arg_conv.is_owned = false;
54305         LDKQuantity ret_var = UnsignedBolt12Invoice_supported_quantity(&this_arg_conv);
54306         int64_t ret_ref = 0;
54307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54308         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54309         return ret_ref;
54310 }
54311
54312 int8_tArray  CS_LDK_UnsignedBolt12Invoice_payer_metadata(int64_t this_arg) {
54313         LDKUnsignedBolt12Invoice this_arg_conv;
54314         this_arg_conv.inner = untag_ptr(this_arg);
54315         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54317         this_arg_conv.is_owned = false;
54318         LDKu8slice ret_var = UnsignedBolt12Invoice_payer_metadata(&this_arg_conv);
54319         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54320         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54321         return ret_arr;
54322 }
54323
54324 int64_t  CS_LDK_UnsignedBolt12Invoice_invoice_request_features(int64_t this_arg) {
54325         LDKUnsignedBolt12Invoice this_arg_conv;
54326         this_arg_conv.inner = untag_ptr(this_arg);
54327         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54329         this_arg_conv.is_owned = false;
54330         LDKInvoiceRequestFeatures ret_var = UnsignedBolt12Invoice_invoice_request_features(&this_arg_conv);
54331         int64_t ret_ref = 0;
54332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54334         return ret_ref;
54335 }
54336
54337 int64_t  CS_LDK_UnsignedBolt12Invoice_quantity(int64_t this_arg) {
54338         LDKUnsignedBolt12Invoice this_arg_conv;
54339         this_arg_conv.inner = untag_ptr(this_arg);
54340         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54342         this_arg_conv.is_owned = false;
54343         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54344         *ret_copy = UnsignedBolt12Invoice_quantity(&this_arg_conv);
54345         int64_t ret_ref = tag_ptr(ret_copy, true);
54346         return ret_ref;
54347 }
54348
54349 int8_tArray  CS_LDK_UnsignedBolt12Invoice_payer_id(int64_t this_arg) {
54350         LDKUnsignedBolt12Invoice this_arg_conv;
54351         this_arg_conv.inner = untag_ptr(this_arg);
54352         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54354         this_arg_conv.is_owned = false;
54355         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54356         memcpy(ret_arr->elems, UnsignedBolt12Invoice_payer_id(&this_arg_conv).compressed_form, 33);
54357         return ret_arr;
54358 }
54359
54360 int64_t  CS_LDK_UnsignedBolt12Invoice_payer_note(int64_t this_arg) {
54361         LDKUnsignedBolt12Invoice this_arg_conv;
54362         this_arg_conv.inner = untag_ptr(this_arg);
54363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54365         this_arg_conv.is_owned = false;
54366         LDKPrintableString ret_var = UnsignedBolt12Invoice_payer_note(&this_arg_conv);
54367         int64_t ret_ref = 0;
54368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54370         return ret_ref;
54371 }
54372
54373 int64_t  CS_LDK_UnsignedBolt12Invoice_created_at(int64_t this_arg) {
54374         LDKUnsignedBolt12Invoice this_arg_conv;
54375         this_arg_conv.inner = untag_ptr(this_arg);
54376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54378         this_arg_conv.is_owned = false;
54379         int64_t ret_conv = UnsignedBolt12Invoice_created_at(&this_arg_conv);
54380         return ret_conv;
54381 }
54382
54383 int64_t  CS_LDK_UnsignedBolt12Invoice_relative_expiry(int64_t this_arg) {
54384         LDKUnsignedBolt12Invoice this_arg_conv;
54385         this_arg_conv.inner = untag_ptr(this_arg);
54386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54388         this_arg_conv.is_owned = false;
54389         int64_t ret_conv = UnsignedBolt12Invoice_relative_expiry(&this_arg_conv);
54390         return ret_conv;
54391 }
54392
54393 jboolean  CS_LDK_UnsignedBolt12Invoice_is_expired(int64_t this_arg) {
54394         LDKUnsignedBolt12Invoice this_arg_conv;
54395         this_arg_conv.inner = untag_ptr(this_arg);
54396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54398         this_arg_conv.is_owned = false;
54399         jboolean ret_conv = UnsignedBolt12Invoice_is_expired(&this_arg_conv);
54400         return ret_conv;
54401 }
54402
54403 int8_tArray  CS_LDK_UnsignedBolt12Invoice_payment_hash(int64_t this_arg) {
54404         LDKUnsignedBolt12Invoice this_arg_conv;
54405         this_arg_conv.inner = untag_ptr(this_arg);
54406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54408         this_arg_conv.is_owned = false;
54409         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54410         memcpy(ret_arr->elems, UnsignedBolt12Invoice_payment_hash(&this_arg_conv).data, 32);
54411         return ret_arr;
54412 }
54413
54414 int64_t  CS_LDK_UnsignedBolt12Invoice_amount_msats(int64_t this_arg) {
54415         LDKUnsignedBolt12Invoice this_arg_conv;
54416         this_arg_conv.inner = untag_ptr(this_arg);
54417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54419         this_arg_conv.is_owned = false;
54420         int64_t ret_conv = UnsignedBolt12Invoice_amount_msats(&this_arg_conv);
54421         return ret_conv;
54422 }
54423
54424 int64_t  CS_LDK_UnsignedBolt12Invoice_invoice_features(int64_t this_arg) {
54425         LDKUnsignedBolt12Invoice this_arg_conv;
54426         this_arg_conv.inner = untag_ptr(this_arg);
54427         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54429         this_arg_conv.is_owned = false;
54430         LDKBolt12InvoiceFeatures ret_var = UnsignedBolt12Invoice_invoice_features(&this_arg_conv);
54431         int64_t ret_ref = 0;
54432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54434         return ret_ref;
54435 }
54436
54437 int8_tArray  CS_LDK_UnsignedBolt12Invoice_signing_pubkey(int64_t this_arg) {
54438         LDKUnsignedBolt12Invoice this_arg_conv;
54439         this_arg_conv.inner = untag_ptr(this_arg);
54440         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54442         this_arg_conv.is_owned = false;
54443         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54444         memcpy(ret_arr->elems, UnsignedBolt12Invoice_signing_pubkey(&this_arg_conv).compressed_form, 33);
54445         return ret_arr;
54446 }
54447
54448 int64_t  CS_LDK_Bolt12Invoice_offer_chains(int64_t this_arg) {
54449         LDKBolt12Invoice this_arg_conv;
54450         this_arg_conv.inner = untag_ptr(this_arg);
54451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54453         this_arg_conv.is_owned = false;
54454         LDKCOption_CVec_ThirtyTwoBytesZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_ThirtyTwoBytesZZ), "LDKCOption_CVec_ThirtyTwoBytesZZ");
54455         *ret_copy = Bolt12Invoice_offer_chains(&this_arg_conv);
54456         int64_t ret_ref = tag_ptr(ret_copy, true);
54457         return ret_ref;
54458 }
54459
54460 int8_tArray  CS_LDK_Bolt12Invoice_chain(int64_t this_arg) {
54461         LDKBolt12Invoice this_arg_conv;
54462         this_arg_conv.inner = untag_ptr(this_arg);
54463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54465         this_arg_conv.is_owned = false;
54466         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54467         memcpy(ret_arr->elems, Bolt12Invoice_chain(&this_arg_conv).data, 32);
54468         return ret_arr;
54469 }
54470
54471 int64_t  CS_LDK_Bolt12Invoice_metadata(int64_t this_arg) {
54472         LDKBolt12Invoice this_arg_conv;
54473         this_arg_conv.inner = untag_ptr(this_arg);
54474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54476         this_arg_conv.is_owned = false;
54477         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
54478         *ret_copy = Bolt12Invoice_metadata(&this_arg_conv);
54479         int64_t ret_ref = tag_ptr(ret_copy, true);
54480         return ret_ref;
54481 }
54482
54483 int64_t  CS_LDK_Bolt12Invoice_amount(int64_t this_arg) {
54484         LDKBolt12Invoice this_arg_conv;
54485         this_arg_conv.inner = untag_ptr(this_arg);
54486         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54488         this_arg_conv.is_owned = false;
54489         LDKAmount ret_var = Bolt12Invoice_amount(&this_arg_conv);
54490         int64_t ret_ref = 0;
54491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54493         return ret_ref;
54494 }
54495
54496 int64_t  CS_LDK_Bolt12Invoice_offer_features(int64_t this_arg) {
54497         LDKBolt12Invoice this_arg_conv;
54498         this_arg_conv.inner = untag_ptr(this_arg);
54499         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54501         this_arg_conv.is_owned = false;
54502         LDKOfferFeatures ret_var = Bolt12Invoice_offer_features(&this_arg_conv);
54503         int64_t ret_ref = 0;
54504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54506         return ret_ref;
54507 }
54508
54509 int64_t  CS_LDK_Bolt12Invoice_description(int64_t this_arg) {
54510         LDKBolt12Invoice this_arg_conv;
54511         this_arg_conv.inner = untag_ptr(this_arg);
54512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54514         this_arg_conv.is_owned = false;
54515         LDKPrintableString ret_var = Bolt12Invoice_description(&this_arg_conv);
54516         int64_t ret_ref = 0;
54517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54519         return ret_ref;
54520 }
54521
54522 int64_t  CS_LDK_Bolt12Invoice_absolute_expiry(int64_t this_arg) {
54523         LDKBolt12Invoice this_arg_conv;
54524         this_arg_conv.inner = untag_ptr(this_arg);
54525         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54527         this_arg_conv.is_owned = false;
54528         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54529         *ret_copy = Bolt12Invoice_absolute_expiry(&this_arg_conv);
54530         int64_t ret_ref = tag_ptr(ret_copy, true);
54531         return ret_ref;
54532 }
54533
54534 int64_t  CS_LDK_Bolt12Invoice_issuer(int64_t this_arg) {
54535         LDKBolt12Invoice this_arg_conv;
54536         this_arg_conv.inner = untag_ptr(this_arg);
54537         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54539         this_arg_conv.is_owned = false;
54540         LDKPrintableString ret_var = Bolt12Invoice_issuer(&this_arg_conv);
54541         int64_t ret_ref = 0;
54542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54544         return ret_ref;
54545 }
54546
54547 int64_tArray  CS_LDK_Bolt12Invoice_message_paths(int64_t this_arg) {
54548         LDKBolt12Invoice this_arg_conv;
54549         this_arg_conv.inner = untag_ptr(this_arg);
54550         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54552         this_arg_conv.is_owned = false;
54553         LDKCVec_BlindedPathZ ret_var = Bolt12Invoice_message_paths(&this_arg_conv);
54554         int64_tArray ret_arr = NULL;
54555         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
54556         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
54557         for (size_t n = 0; n < ret_var.datalen; n++) {
54558                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
54559                 int64_t ret_conv_13_ref = 0;
54560                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
54561                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
54562                 ret_arr_ptr[n] = ret_conv_13_ref;
54563         }
54564         
54565         FREE(ret_var.data);
54566         return ret_arr;
54567 }
54568
54569 int64_t  CS_LDK_Bolt12Invoice_supported_quantity(int64_t this_arg) {
54570         LDKBolt12Invoice this_arg_conv;
54571         this_arg_conv.inner = untag_ptr(this_arg);
54572         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54574         this_arg_conv.is_owned = false;
54575         LDKQuantity ret_var = Bolt12Invoice_supported_quantity(&this_arg_conv);
54576         int64_t ret_ref = 0;
54577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54579         return ret_ref;
54580 }
54581
54582 int8_tArray  CS_LDK_Bolt12Invoice_payer_metadata(int64_t this_arg) {
54583         LDKBolt12Invoice this_arg_conv;
54584         this_arg_conv.inner = untag_ptr(this_arg);
54585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54587         this_arg_conv.is_owned = false;
54588         LDKu8slice ret_var = Bolt12Invoice_payer_metadata(&this_arg_conv);
54589         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54590         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54591         return ret_arr;
54592 }
54593
54594 int64_t  CS_LDK_Bolt12Invoice_invoice_request_features(int64_t this_arg) {
54595         LDKBolt12Invoice this_arg_conv;
54596         this_arg_conv.inner = untag_ptr(this_arg);
54597         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54599         this_arg_conv.is_owned = false;
54600         LDKInvoiceRequestFeatures ret_var = Bolt12Invoice_invoice_request_features(&this_arg_conv);
54601         int64_t ret_ref = 0;
54602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54604         return ret_ref;
54605 }
54606
54607 int64_t  CS_LDK_Bolt12Invoice_quantity(int64_t this_arg) {
54608         LDKBolt12Invoice this_arg_conv;
54609         this_arg_conv.inner = untag_ptr(this_arg);
54610         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54612         this_arg_conv.is_owned = false;
54613         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
54614         *ret_copy = Bolt12Invoice_quantity(&this_arg_conv);
54615         int64_t ret_ref = tag_ptr(ret_copy, true);
54616         return ret_ref;
54617 }
54618
54619 int8_tArray  CS_LDK_Bolt12Invoice_payer_id(int64_t this_arg) {
54620         LDKBolt12Invoice this_arg_conv;
54621         this_arg_conv.inner = untag_ptr(this_arg);
54622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54624         this_arg_conv.is_owned = false;
54625         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54626         memcpy(ret_arr->elems, Bolt12Invoice_payer_id(&this_arg_conv).compressed_form, 33);
54627         return ret_arr;
54628 }
54629
54630 int64_t  CS_LDK_Bolt12Invoice_payer_note(int64_t this_arg) {
54631         LDKBolt12Invoice this_arg_conv;
54632         this_arg_conv.inner = untag_ptr(this_arg);
54633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54635         this_arg_conv.is_owned = false;
54636         LDKPrintableString ret_var = Bolt12Invoice_payer_note(&this_arg_conv);
54637         int64_t ret_ref = 0;
54638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54639         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54640         return ret_ref;
54641 }
54642
54643 int64_t  CS_LDK_Bolt12Invoice_created_at(int64_t this_arg) {
54644         LDKBolt12Invoice this_arg_conv;
54645         this_arg_conv.inner = untag_ptr(this_arg);
54646         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54648         this_arg_conv.is_owned = false;
54649         int64_t ret_conv = Bolt12Invoice_created_at(&this_arg_conv);
54650         return ret_conv;
54651 }
54652
54653 int64_t  CS_LDK_Bolt12Invoice_relative_expiry(int64_t this_arg) {
54654         LDKBolt12Invoice this_arg_conv;
54655         this_arg_conv.inner = untag_ptr(this_arg);
54656         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54658         this_arg_conv.is_owned = false;
54659         int64_t ret_conv = Bolt12Invoice_relative_expiry(&this_arg_conv);
54660         return ret_conv;
54661 }
54662
54663 jboolean  CS_LDK_Bolt12Invoice_is_expired(int64_t this_arg) {
54664         LDKBolt12Invoice this_arg_conv;
54665         this_arg_conv.inner = untag_ptr(this_arg);
54666         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54668         this_arg_conv.is_owned = false;
54669         jboolean ret_conv = Bolt12Invoice_is_expired(&this_arg_conv);
54670         return ret_conv;
54671 }
54672
54673 int8_tArray  CS_LDK_Bolt12Invoice_payment_hash(int64_t this_arg) {
54674         LDKBolt12Invoice this_arg_conv;
54675         this_arg_conv.inner = untag_ptr(this_arg);
54676         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54678         this_arg_conv.is_owned = false;
54679         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54680         memcpy(ret_arr->elems, Bolt12Invoice_payment_hash(&this_arg_conv).data, 32);
54681         return ret_arr;
54682 }
54683
54684 int64_t  CS_LDK_Bolt12Invoice_amount_msats(int64_t this_arg) {
54685         LDKBolt12Invoice this_arg_conv;
54686         this_arg_conv.inner = untag_ptr(this_arg);
54687         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54689         this_arg_conv.is_owned = false;
54690         int64_t ret_conv = Bolt12Invoice_amount_msats(&this_arg_conv);
54691         return ret_conv;
54692 }
54693
54694 int64_t  CS_LDK_Bolt12Invoice_invoice_features(int64_t this_arg) {
54695         LDKBolt12Invoice this_arg_conv;
54696         this_arg_conv.inner = untag_ptr(this_arg);
54697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54699         this_arg_conv.is_owned = false;
54700         LDKBolt12InvoiceFeatures ret_var = Bolt12Invoice_invoice_features(&this_arg_conv);
54701         int64_t ret_ref = 0;
54702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54704         return ret_ref;
54705 }
54706
54707 int8_tArray  CS_LDK_Bolt12Invoice_signing_pubkey(int64_t this_arg) {
54708         LDKBolt12Invoice this_arg_conv;
54709         this_arg_conv.inner = untag_ptr(this_arg);
54710         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54712         this_arg_conv.is_owned = false;
54713         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
54714         memcpy(ret_arr->elems, Bolt12Invoice_signing_pubkey(&this_arg_conv).compressed_form, 33);
54715         return ret_arr;
54716 }
54717
54718 int8_tArray  CS_LDK_Bolt12Invoice_signature(int64_t this_arg) {
54719         LDKBolt12Invoice this_arg_conv;
54720         this_arg_conv.inner = untag_ptr(this_arg);
54721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54723         this_arg_conv.is_owned = false;
54724         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
54725         memcpy(ret_arr->elems, Bolt12Invoice_signature(&this_arg_conv).compact_form, 64);
54726         return ret_arr;
54727 }
54728
54729 int8_tArray  CS_LDK_Bolt12Invoice_signable_hash(int64_t this_arg) {
54730         LDKBolt12Invoice this_arg_conv;
54731         this_arg_conv.inner = untag_ptr(this_arg);
54732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54734         this_arg_conv.is_owned = false;
54735         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
54736         memcpy(ret_arr->elems, Bolt12Invoice_signable_hash(&this_arg_conv).data, 32);
54737         return ret_arr;
54738 }
54739
54740 int64_t  CS_LDK_Bolt12Invoice_verify(int64_t this_arg, int64_t key) {
54741         LDKBolt12Invoice this_arg_conv;
54742         this_arg_conv.inner = untag_ptr(this_arg);
54743         this_arg_conv.is_owned = ptr_is_owned(this_arg);
54744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
54745         this_arg_conv.is_owned = false;
54746         LDKExpandedKey key_conv;
54747         key_conv.inner = untag_ptr(key);
54748         key_conv.is_owned = ptr_is_owned(key);
54749         CHECK_INNER_FIELD_ACCESS_OR_NULL(key_conv);
54750         key_conv.is_owned = false;
54751         LDKCResult_ThirtyTwoBytesNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesNoneZ), "LDKCResult_ThirtyTwoBytesNoneZ");
54752         *ret_conv = Bolt12Invoice_verify(&this_arg_conv, &key_conv);
54753         return tag_ptr(ret_conv, true);
54754 }
54755
54756 int8_tArray  CS_LDK_UnsignedBolt12Invoice_write(int64_t obj) {
54757         LDKUnsignedBolt12Invoice obj_conv;
54758         obj_conv.inner = untag_ptr(obj);
54759         obj_conv.is_owned = ptr_is_owned(obj);
54760         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54761         obj_conv.is_owned = false;
54762         LDKCVec_u8Z ret_var = UnsignedBolt12Invoice_write(&obj_conv);
54763         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54764         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54765         CVec_u8Z_free(ret_var);
54766         return ret_arr;
54767 }
54768
54769 int8_tArray  CS_LDK_Bolt12Invoice_write(int64_t obj) {
54770         LDKBolt12Invoice obj_conv;
54771         obj_conv.inner = untag_ptr(obj);
54772         obj_conv.is_owned = ptr_is_owned(obj);
54773         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54774         obj_conv.is_owned = false;
54775         LDKCVec_u8Z ret_var = Bolt12Invoice_write(&obj_conv);
54776         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54777         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54778         CVec_u8Z_free(ret_var);
54779         return ret_arr;
54780 }
54781
54782 void  CS_LDK_BlindedPayInfo_free(int64_t this_obj) {
54783         LDKBlindedPayInfo this_obj_conv;
54784         this_obj_conv.inner = untag_ptr(this_obj);
54785         this_obj_conv.is_owned = ptr_is_owned(this_obj);
54786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
54787         BlindedPayInfo_free(this_obj_conv);
54788 }
54789
54790 int32_t  CS_LDK_BlindedPayInfo_get_fee_base_msat(int64_t this_ptr) {
54791         LDKBlindedPayInfo this_ptr_conv;
54792         this_ptr_conv.inner = untag_ptr(this_ptr);
54793         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54795         this_ptr_conv.is_owned = false;
54796         int32_t ret_conv = BlindedPayInfo_get_fee_base_msat(&this_ptr_conv);
54797         return ret_conv;
54798 }
54799
54800 void  CS_LDK_BlindedPayInfo_set_fee_base_msat(int64_t this_ptr, int32_t val) {
54801         LDKBlindedPayInfo this_ptr_conv;
54802         this_ptr_conv.inner = untag_ptr(this_ptr);
54803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54805         this_ptr_conv.is_owned = false;
54806         BlindedPayInfo_set_fee_base_msat(&this_ptr_conv, val);
54807 }
54808
54809 int32_t  CS_LDK_BlindedPayInfo_get_fee_proportional_millionths(int64_t this_ptr) {
54810         LDKBlindedPayInfo this_ptr_conv;
54811         this_ptr_conv.inner = untag_ptr(this_ptr);
54812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54814         this_ptr_conv.is_owned = false;
54815         int32_t ret_conv = BlindedPayInfo_get_fee_proportional_millionths(&this_ptr_conv);
54816         return ret_conv;
54817 }
54818
54819 void  CS_LDK_BlindedPayInfo_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
54820         LDKBlindedPayInfo this_ptr_conv;
54821         this_ptr_conv.inner = untag_ptr(this_ptr);
54822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54824         this_ptr_conv.is_owned = false;
54825         BlindedPayInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
54826 }
54827
54828 int16_t  CS_LDK_BlindedPayInfo_get_cltv_expiry_delta(int64_t this_ptr) {
54829         LDKBlindedPayInfo this_ptr_conv;
54830         this_ptr_conv.inner = untag_ptr(this_ptr);
54831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54833         this_ptr_conv.is_owned = false;
54834         int16_t ret_conv = BlindedPayInfo_get_cltv_expiry_delta(&this_ptr_conv);
54835         return ret_conv;
54836 }
54837
54838 void  CS_LDK_BlindedPayInfo_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
54839         LDKBlindedPayInfo this_ptr_conv;
54840         this_ptr_conv.inner = untag_ptr(this_ptr);
54841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54843         this_ptr_conv.is_owned = false;
54844         BlindedPayInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
54845 }
54846
54847 int64_t  CS_LDK_BlindedPayInfo_get_htlc_minimum_msat(int64_t this_ptr) {
54848         LDKBlindedPayInfo this_ptr_conv;
54849         this_ptr_conv.inner = untag_ptr(this_ptr);
54850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54852         this_ptr_conv.is_owned = false;
54853         int64_t ret_conv = BlindedPayInfo_get_htlc_minimum_msat(&this_ptr_conv);
54854         return ret_conv;
54855 }
54856
54857 void  CS_LDK_BlindedPayInfo_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
54858         LDKBlindedPayInfo this_ptr_conv;
54859         this_ptr_conv.inner = untag_ptr(this_ptr);
54860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54862         this_ptr_conv.is_owned = false;
54863         BlindedPayInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
54864 }
54865
54866 int64_t  CS_LDK_BlindedPayInfo_get_htlc_maximum_msat(int64_t this_ptr) {
54867         LDKBlindedPayInfo this_ptr_conv;
54868         this_ptr_conv.inner = untag_ptr(this_ptr);
54869         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54871         this_ptr_conv.is_owned = false;
54872         int64_t ret_conv = BlindedPayInfo_get_htlc_maximum_msat(&this_ptr_conv);
54873         return ret_conv;
54874 }
54875
54876 void  CS_LDK_BlindedPayInfo_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
54877         LDKBlindedPayInfo this_ptr_conv;
54878         this_ptr_conv.inner = untag_ptr(this_ptr);
54879         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54881         this_ptr_conv.is_owned = false;
54882         BlindedPayInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
54883 }
54884
54885 int64_t  CS_LDK_BlindedPayInfo_get_features(int64_t this_ptr) {
54886         LDKBlindedPayInfo this_ptr_conv;
54887         this_ptr_conv.inner = untag_ptr(this_ptr);
54888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54890         this_ptr_conv.is_owned = false;
54891         LDKBlindedHopFeatures ret_var = BlindedPayInfo_get_features(&this_ptr_conv);
54892         int64_t ret_ref = 0;
54893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54895         return ret_ref;
54896 }
54897
54898 void  CS_LDK_BlindedPayInfo_set_features(int64_t this_ptr, int64_t val) {
54899         LDKBlindedPayInfo this_ptr_conv;
54900         this_ptr_conv.inner = untag_ptr(this_ptr);
54901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
54902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
54903         this_ptr_conv.is_owned = false;
54904         LDKBlindedHopFeatures val_conv;
54905         val_conv.inner = untag_ptr(val);
54906         val_conv.is_owned = ptr_is_owned(val);
54907         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
54908         val_conv = BlindedHopFeatures_clone(&val_conv);
54909         BlindedPayInfo_set_features(&this_ptr_conv, val_conv);
54910 }
54911
54912 int64_t  CS_LDK_BlindedPayInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t features_arg) {
54913         LDKBlindedHopFeatures features_arg_conv;
54914         features_arg_conv.inner = untag_ptr(features_arg);
54915         features_arg_conv.is_owned = ptr_is_owned(features_arg);
54916         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
54917         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
54918         LDKBlindedPayInfo ret_var = BlindedPayInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, features_arg_conv);
54919         int64_t ret_ref = 0;
54920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54922         return ret_ref;
54923 }
54924
54925 static inline uint64_t BlindedPayInfo_clone_ptr(LDKBlindedPayInfo *NONNULL_PTR arg) {
54926         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(arg);
54927         int64_t ret_ref = 0;
54928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54930         return ret_ref;
54931 }
54932 int64_t  CS_LDK_BlindedPayInfo_clone_ptr(int64_t arg) {
54933         LDKBlindedPayInfo arg_conv;
54934         arg_conv.inner = untag_ptr(arg);
54935         arg_conv.is_owned = ptr_is_owned(arg);
54936         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
54937         arg_conv.is_owned = false;
54938         int64_t ret_conv = BlindedPayInfo_clone_ptr(&arg_conv);
54939         return ret_conv;
54940 }
54941
54942 int64_t  CS_LDK_BlindedPayInfo_clone(int64_t orig) {
54943         LDKBlindedPayInfo orig_conv;
54944         orig_conv.inner = untag_ptr(orig);
54945         orig_conv.is_owned = ptr_is_owned(orig);
54946         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
54947         orig_conv.is_owned = false;
54948         LDKBlindedPayInfo ret_var = BlindedPayInfo_clone(&orig_conv);
54949         int64_t ret_ref = 0;
54950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
54951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
54952         return ret_ref;
54953 }
54954
54955 int64_t  CS_LDK_BlindedPayInfo_hash(int64_t o) {
54956         LDKBlindedPayInfo o_conv;
54957         o_conv.inner = untag_ptr(o);
54958         o_conv.is_owned = ptr_is_owned(o);
54959         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
54960         o_conv.is_owned = false;
54961         int64_t ret_conv = BlindedPayInfo_hash(&o_conv);
54962         return ret_conv;
54963 }
54964
54965 jboolean  CS_LDK_BlindedPayInfo_eq(int64_t a, int64_t b) {
54966         LDKBlindedPayInfo a_conv;
54967         a_conv.inner = untag_ptr(a);
54968         a_conv.is_owned = ptr_is_owned(a);
54969         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
54970         a_conv.is_owned = false;
54971         LDKBlindedPayInfo b_conv;
54972         b_conv.inner = untag_ptr(b);
54973         b_conv.is_owned = ptr_is_owned(b);
54974         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
54975         b_conv.is_owned = false;
54976         jboolean ret_conv = BlindedPayInfo_eq(&a_conv, &b_conv);
54977         return ret_conv;
54978 }
54979
54980 int8_tArray  CS_LDK_BlindedPayInfo_write(int64_t obj) {
54981         LDKBlindedPayInfo obj_conv;
54982         obj_conv.inner = untag_ptr(obj);
54983         obj_conv.is_owned = ptr_is_owned(obj);
54984         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
54985         obj_conv.is_owned = false;
54986         LDKCVec_u8Z ret_var = BlindedPayInfo_write(&obj_conv);
54987         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
54988         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
54989         CVec_u8Z_free(ret_var);
54990         return ret_arr;
54991 }
54992
54993 int64_t  CS_LDK_BlindedPayInfo_read(int8_tArray ser) {
54994         LDKu8slice ser_ref;
54995         ser_ref.datalen = ser->arr_len;
54996         ser_ref.data = ser->elems;
54997         LDKCResult_BlindedPayInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPayInfoDecodeErrorZ), "LDKCResult_BlindedPayInfoDecodeErrorZ");
54998         *ret_conv = BlindedPayInfo_read(ser_ref);
54999         FREE(ser);
55000         return tag_ptr(ret_conv, true);
55001 }
55002
55003 void  CS_LDK_InvoiceError_free(int64_t this_obj) {
55004         LDKInvoiceError this_obj_conv;
55005         this_obj_conv.inner = untag_ptr(this_obj);
55006         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55008         InvoiceError_free(this_obj_conv);
55009 }
55010
55011 int64_t  CS_LDK_InvoiceError_get_erroneous_field(int64_t this_ptr) {
55012         LDKInvoiceError this_ptr_conv;
55013         this_ptr_conv.inner = untag_ptr(this_ptr);
55014         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55016         this_ptr_conv.is_owned = false;
55017         LDKErroneousField ret_var = InvoiceError_get_erroneous_field(&this_ptr_conv);
55018         int64_t ret_ref = 0;
55019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55020         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55021         return ret_ref;
55022 }
55023
55024 void  CS_LDK_InvoiceError_set_erroneous_field(int64_t this_ptr, int64_t val) {
55025         LDKInvoiceError this_ptr_conv;
55026         this_ptr_conv.inner = untag_ptr(this_ptr);
55027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55029         this_ptr_conv.is_owned = false;
55030         LDKErroneousField val_conv;
55031         val_conv.inner = untag_ptr(val);
55032         val_conv.is_owned = ptr_is_owned(val);
55033         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55034         val_conv = ErroneousField_clone(&val_conv);
55035         InvoiceError_set_erroneous_field(&this_ptr_conv, val_conv);
55036 }
55037
55038 int64_t  CS_LDK_InvoiceError_get_message(int64_t this_ptr) {
55039         LDKInvoiceError this_ptr_conv;
55040         this_ptr_conv.inner = untag_ptr(this_ptr);
55041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55043         this_ptr_conv.is_owned = false;
55044         LDKUntrustedString ret_var = InvoiceError_get_message(&this_ptr_conv);
55045         int64_t ret_ref = 0;
55046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55047         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55048         return ret_ref;
55049 }
55050
55051 void  CS_LDK_InvoiceError_set_message(int64_t this_ptr, int64_t val) {
55052         LDKInvoiceError this_ptr_conv;
55053         this_ptr_conv.inner = untag_ptr(this_ptr);
55054         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55056         this_ptr_conv.is_owned = false;
55057         LDKUntrustedString val_conv;
55058         val_conv.inner = untag_ptr(val);
55059         val_conv.is_owned = ptr_is_owned(val);
55060         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
55061         val_conv = UntrustedString_clone(&val_conv);
55062         InvoiceError_set_message(&this_ptr_conv, val_conv);
55063 }
55064
55065 int64_t  CS_LDK_InvoiceError_new(int64_t erroneous_field_arg, int64_t message_arg) {
55066         LDKErroneousField erroneous_field_arg_conv;
55067         erroneous_field_arg_conv.inner = untag_ptr(erroneous_field_arg);
55068         erroneous_field_arg_conv.is_owned = ptr_is_owned(erroneous_field_arg);
55069         CHECK_INNER_FIELD_ACCESS_OR_NULL(erroneous_field_arg_conv);
55070         erroneous_field_arg_conv = ErroneousField_clone(&erroneous_field_arg_conv);
55071         LDKUntrustedString message_arg_conv;
55072         message_arg_conv.inner = untag_ptr(message_arg);
55073         message_arg_conv.is_owned = ptr_is_owned(message_arg);
55074         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_arg_conv);
55075         message_arg_conv = UntrustedString_clone(&message_arg_conv);
55076         LDKInvoiceError ret_var = InvoiceError_new(erroneous_field_arg_conv, message_arg_conv);
55077         int64_t ret_ref = 0;
55078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55080         return ret_ref;
55081 }
55082
55083 static inline uint64_t InvoiceError_clone_ptr(LDKInvoiceError *NONNULL_PTR arg) {
55084         LDKInvoiceError ret_var = InvoiceError_clone(arg);
55085         int64_t ret_ref = 0;
55086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55087         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55088         return ret_ref;
55089 }
55090 int64_t  CS_LDK_InvoiceError_clone_ptr(int64_t arg) {
55091         LDKInvoiceError arg_conv;
55092         arg_conv.inner = untag_ptr(arg);
55093         arg_conv.is_owned = ptr_is_owned(arg);
55094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55095         arg_conv.is_owned = false;
55096         int64_t ret_conv = InvoiceError_clone_ptr(&arg_conv);
55097         return ret_conv;
55098 }
55099
55100 int64_t  CS_LDK_InvoiceError_clone(int64_t orig) {
55101         LDKInvoiceError orig_conv;
55102         orig_conv.inner = untag_ptr(orig);
55103         orig_conv.is_owned = ptr_is_owned(orig);
55104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55105         orig_conv.is_owned = false;
55106         LDKInvoiceError ret_var = InvoiceError_clone(&orig_conv);
55107         int64_t ret_ref = 0;
55108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55110         return ret_ref;
55111 }
55112
55113 void  CS_LDK_ErroneousField_free(int64_t this_obj) {
55114         LDKErroneousField this_obj_conv;
55115         this_obj_conv.inner = untag_ptr(this_obj);
55116         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55118         ErroneousField_free(this_obj_conv);
55119 }
55120
55121 int64_t  CS_LDK_ErroneousField_get_tlv_fieldnum(int64_t this_ptr) {
55122         LDKErroneousField this_ptr_conv;
55123         this_ptr_conv.inner = untag_ptr(this_ptr);
55124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55126         this_ptr_conv.is_owned = false;
55127         int64_t ret_conv = ErroneousField_get_tlv_fieldnum(&this_ptr_conv);
55128         return ret_conv;
55129 }
55130
55131 void  CS_LDK_ErroneousField_set_tlv_fieldnum(int64_t this_ptr, int64_t val) {
55132         LDKErroneousField this_ptr_conv;
55133         this_ptr_conv.inner = untag_ptr(this_ptr);
55134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55136         this_ptr_conv.is_owned = false;
55137         ErroneousField_set_tlv_fieldnum(&this_ptr_conv, val);
55138 }
55139
55140 int64_t  CS_LDK_ErroneousField_get_suggested_value(int64_t this_ptr) {
55141         LDKErroneousField this_ptr_conv;
55142         this_ptr_conv.inner = untag_ptr(this_ptr);
55143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55145         this_ptr_conv.is_owned = false;
55146         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55147         *ret_copy = ErroneousField_get_suggested_value(&this_ptr_conv);
55148         int64_t ret_ref = tag_ptr(ret_copy, true);
55149         return ret_ref;
55150 }
55151
55152 void  CS_LDK_ErroneousField_set_suggested_value(int64_t this_ptr, int64_t val) {
55153         LDKErroneousField this_ptr_conv;
55154         this_ptr_conv.inner = untag_ptr(this_ptr);
55155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55157         this_ptr_conv.is_owned = false;
55158         void* val_ptr = untag_ptr(val);
55159         CHECK_ACCESS(val_ptr);
55160         LDKCOption_CVec_u8ZZ val_conv = *(LDKCOption_CVec_u8ZZ*)(val_ptr);
55161         val_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(val));
55162         ErroneousField_set_suggested_value(&this_ptr_conv, val_conv);
55163 }
55164
55165 int64_t  CS_LDK_ErroneousField_new(int64_t tlv_fieldnum_arg, int64_t suggested_value_arg) {
55166         void* suggested_value_arg_ptr = untag_ptr(suggested_value_arg);
55167         CHECK_ACCESS(suggested_value_arg_ptr);
55168         LDKCOption_CVec_u8ZZ suggested_value_arg_conv = *(LDKCOption_CVec_u8ZZ*)(suggested_value_arg_ptr);
55169         suggested_value_arg_conv = COption_CVec_u8ZZ_clone((LDKCOption_CVec_u8ZZ*)untag_ptr(suggested_value_arg));
55170         LDKErroneousField ret_var = ErroneousField_new(tlv_fieldnum_arg, suggested_value_arg_conv);
55171         int64_t ret_ref = 0;
55172         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55173         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55174         return ret_ref;
55175 }
55176
55177 static inline uint64_t ErroneousField_clone_ptr(LDKErroneousField *NONNULL_PTR arg) {
55178         LDKErroneousField ret_var = ErroneousField_clone(arg);
55179         int64_t ret_ref = 0;
55180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55182         return ret_ref;
55183 }
55184 int64_t  CS_LDK_ErroneousField_clone_ptr(int64_t arg) {
55185         LDKErroneousField arg_conv;
55186         arg_conv.inner = untag_ptr(arg);
55187         arg_conv.is_owned = ptr_is_owned(arg);
55188         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55189         arg_conv.is_owned = false;
55190         int64_t ret_conv = ErroneousField_clone_ptr(&arg_conv);
55191         return ret_conv;
55192 }
55193
55194 int64_t  CS_LDK_ErroneousField_clone(int64_t orig) {
55195         LDKErroneousField orig_conv;
55196         orig_conv.inner = untag_ptr(orig);
55197         orig_conv.is_owned = ptr_is_owned(orig);
55198         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55199         orig_conv.is_owned = false;
55200         LDKErroneousField ret_var = ErroneousField_clone(&orig_conv);
55201         int64_t ret_ref = 0;
55202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55204         return ret_ref;
55205 }
55206
55207 int64_t  CS_LDK_InvoiceError_from_string(jstring s) {
55208         LDKStr s_conv = str_ref_to_owned_c(s);
55209         LDKInvoiceError ret_var = InvoiceError_from_string(s_conv);
55210         int64_t ret_ref = 0;
55211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55212         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55213         return ret_ref;
55214 }
55215
55216 int8_tArray  CS_LDK_InvoiceError_write(int64_t obj) {
55217         LDKInvoiceError obj_conv;
55218         obj_conv.inner = untag_ptr(obj);
55219         obj_conv.is_owned = ptr_is_owned(obj);
55220         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
55221         obj_conv.is_owned = false;
55222         LDKCVec_u8Z ret_var = InvoiceError_write(&obj_conv);
55223         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55224         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55225         CVec_u8Z_free(ret_var);
55226         return ret_arr;
55227 }
55228
55229 int64_t  CS_LDK_InvoiceError_read(int8_tArray ser) {
55230         LDKu8slice ser_ref;
55231         ser_ref.datalen = ser->arr_len;
55232         ser_ref.data = ser->elems;
55233         LDKCResult_InvoiceErrorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceErrorDecodeErrorZ), "LDKCResult_InvoiceErrorDecodeErrorZ");
55234         *ret_conv = InvoiceError_read(ser_ref);
55235         FREE(ser);
55236         return tag_ptr(ret_conv, true);
55237 }
55238
55239 void  CS_LDK_UnsignedInvoiceRequest_free(int64_t this_obj) {
55240         LDKUnsignedInvoiceRequest this_obj_conv;
55241         this_obj_conv.inner = untag_ptr(this_obj);
55242         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55244         UnsignedInvoiceRequest_free(this_obj_conv);
55245 }
55246
55247 int64_t  CS_LDK_UnsignedInvoiceRequest_tagged_hash(int64_t this_arg) {
55248         LDKUnsignedInvoiceRequest this_arg_conv;
55249         this_arg_conv.inner = untag_ptr(this_arg);
55250         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55252         this_arg_conv.is_owned = false;
55253         LDKTaggedHash ret_var = UnsignedInvoiceRequest_tagged_hash(&this_arg_conv);
55254         int64_t ret_ref = 0;
55255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55257         return ret_ref;
55258 }
55259
55260 void  CS_LDK_InvoiceRequest_free(int64_t this_obj) {
55261         LDKInvoiceRequest this_obj_conv;
55262         this_obj_conv.inner = untag_ptr(this_obj);
55263         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55265         InvoiceRequest_free(this_obj_conv);
55266 }
55267
55268 static inline uint64_t InvoiceRequest_clone_ptr(LDKInvoiceRequest *NONNULL_PTR arg) {
55269         LDKInvoiceRequest ret_var = InvoiceRequest_clone(arg);
55270         int64_t ret_ref = 0;
55271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55273         return ret_ref;
55274 }
55275 int64_t  CS_LDK_InvoiceRequest_clone_ptr(int64_t arg) {
55276         LDKInvoiceRequest arg_conv;
55277         arg_conv.inner = untag_ptr(arg);
55278         arg_conv.is_owned = ptr_is_owned(arg);
55279         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55280         arg_conv.is_owned = false;
55281         int64_t ret_conv = InvoiceRequest_clone_ptr(&arg_conv);
55282         return ret_conv;
55283 }
55284
55285 int64_t  CS_LDK_InvoiceRequest_clone(int64_t orig) {
55286         LDKInvoiceRequest orig_conv;
55287         orig_conv.inner = untag_ptr(orig);
55288         orig_conv.is_owned = ptr_is_owned(orig);
55289         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55290         orig_conv.is_owned = false;
55291         LDKInvoiceRequest ret_var = InvoiceRequest_clone(&orig_conv);
55292         int64_t ret_ref = 0;
55293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55295         return ret_ref;
55296 }
55297
55298 void  CS_LDK_VerifiedInvoiceRequest_free(int64_t this_obj) {
55299         LDKVerifiedInvoiceRequest this_obj_conv;
55300         this_obj_conv.inner = untag_ptr(this_obj);
55301         this_obj_conv.is_owned = ptr_is_owned(this_obj);
55302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
55303         VerifiedInvoiceRequest_free(this_obj_conv);
55304 }
55305
55306 int64_t  CS_LDK_VerifiedInvoiceRequest_get_keys(int64_t this_ptr) {
55307         LDKVerifiedInvoiceRequest this_ptr_conv;
55308         this_ptr_conv.inner = untag_ptr(this_ptr);
55309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55311         this_ptr_conv.is_owned = false;
55312         LDKCOption_SecretKeyZ *ret_copy = MALLOC(sizeof(LDKCOption_SecretKeyZ), "LDKCOption_SecretKeyZ");
55313         *ret_copy = VerifiedInvoiceRequest_get_keys(&this_ptr_conv);
55314         int64_t ret_ref = tag_ptr(ret_copy, true);
55315         return ret_ref;
55316 }
55317
55318 void  CS_LDK_VerifiedInvoiceRequest_set_keys(int64_t this_ptr, int64_t val) {
55319         LDKVerifiedInvoiceRequest this_ptr_conv;
55320         this_ptr_conv.inner = untag_ptr(this_ptr);
55321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
55322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
55323         this_ptr_conv.is_owned = false;
55324         void* val_ptr = untag_ptr(val);
55325         CHECK_ACCESS(val_ptr);
55326         LDKCOption_SecretKeyZ val_conv = *(LDKCOption_SecretKeyZ*)(val_ptr);
55327         val_conv = COption_SecretKeyZ_clone((LDKCOption_SecretKeyZ*)untag_ptr(val));
55328         VerifiedInvoiceRequest_set_keys(&this_ptr_conv, val_conv);
55329 }
55330
55331 static inline uint64_t VerifiedInvoiceRequest_clone_ptr(LDKVerifiedInvoiceRequest *NONNULL_PTR arg) {
55332         LDKVerifiedInvoiceRequest ret_var = VerifiedInvoiceRequest_clone(arg);
55333         int64_t ret_ref = 0;
55334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55335         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55336         return ret_ref;
55337 }
55338 int64_t  CS_LDK_VerifiedInvoiceRequest_clone_ptr(int64_t arg) {
55339         LDKVerifiedInvoiceRequest arg_conv;
55340         arg_conv.inner = untag_ptr(arg);
55341         arg_conv.is_owned = ptr_is_owned(arg);
55342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
55343         arg_conv.is_owned = false;
55344         int64_t ret_conv = VerifiedInvoiceRequest_clone_ptr(&arg_conv);
55345         return ret_conv;
55346 }
55347
55348 int64_t  CS_LDK_VerifiedInvoiceRequest_clone(int64_t orig) {
55349         LDKVerifiedInvoiceRequest orig_conv;
55350         orig_conv.inner = untag_ptr(orig);
55351         orig_conv.is_owned = ptr_is_owned(orig);
55352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
55353         orig_conv.is_owned = false;
55354         LDKVerifiedInvoiceRequest ret_var = VerifiedInvoiceRequest_clone(&orig_conv);
55355         int64_t ret_ref = 0;
55356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55358         return ret_ref;
55359 }
55360
55361 ptrArray  CS_LDK_UnsignedInvoiceRequest_chains(int64_t this_arg) {
55362         LDKUnsignedInvoiceRequest this_arg_conv;
55363         this_arg_conv.inner = untag_ptr(this_arg);
55364         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55366         this_arg_conv.is_owned = false;
55367         LDKCVec_ThirtyTwoBytesZ ret_var = UnsignedInvoiceRequest_chains(&this_arg_conv);
55368         ptrArray ret_arr = NULL;
55369         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
55370         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
55371         for (size_t i = 0; i < ret_var.datalen; i++) {
55372                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
55373                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
55374                 ret_arr_ptr[i] = ret_conv_8_arr;
55375         }
55376         
55377         FREE(ret_var.data);
55378         return ret_arr;
55379 }
55380
55381 int64_t  CS_LDK_UnsignedInvoiceRequest_metadata(int64_t this_arg) {
55382         LDKUnsignedInvoiceRequest this_arg_conv;
55383         this_arg_conv.inner = untag_ptr(this_arg);
55384         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55386         this_arg_conv.is_owned = false;
55387         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55388         *ret_copy = UnsignedInvoiceRequest_metadata(&this_arg_conv);
55389         int64_t ret_ref = tag_ptr(ret_copy, true);
55390         return ret_ref;
55391 }
55392
55393 int64_t  CS_LDK_UnsignedInvoiceRequest_amount(int64_t this_arg) {
55394         LDKUnsignedInvoiceRequest this_arg_conv;
55395         this_arg_conv.inner = untag_ptr(this_arg);
55396         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55398         this_arg_conv.is_owned = false;
55399         LDKAmount ret_var = UnsignedInvoiceRequest_amount(&this_arg_conv);
55400         int64_t ret_ref = 0;
55401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55402         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55403         return ret_ref;
55404 }
55405
55406 int64_t  CS_LDK_UnsignedInvoiceRequest_description(int64_t this_arg) {
55407         LDKUnsignedInvoiceRequest this_arg_conv;
55408         this_arg_conv.inner = untag_ptr(this_arg);
55409         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55411         this_arg_conv.is_owned = false;
55412         LDKPrintableString ret_var = UnsignedInvoiceRequest_description(&this_arg_conv);
55413         int64_t ret_ref = 0;
55414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55415         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55416         return ret_ref;
55417 }
55418
55419 int64_t  CS_LDK_UnsignedInvoiceRequest_offer_features(int64_t this_arg) {
55420         LDKUnsignedInvoiceRequest this_arg_conv;
55421         this_arg_conv.inner = untag_ptr(this_arg);
55422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55424         this_arg_conv.is_owned = false;
55425         LDKOfferFeatures ret_var = UnsignedInvoiceRequest_offer_features(&this_arg_conv);
55426         int64_t ret_ref = 0;
55427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55428         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55429         return ret_ref;
55430 }
55431
55432 int64_t  CS_LDK_UnsignedInvoiceRequest_absolute_expiry(int64_t this_arg) {
55433         LDKUnsignedInvoiceRequest this_arg_conv;
55434         this_arg_conv.inner = untag_ptr(this_arg);
55435         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55437         this_arg_conv.is_owned = false;
55438         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55439         *ret_copy = UnsignedInvoiceRequest_absolute_expiry(&this_arg_conv);
55440         int64_t ret_ref = tag_ptr(ret_copy, true);
55441         return ret_ref;
55442 }
55443
55444 int64_t  CS_LDK_UnsignedInvoiceRequest_issuer(int64_t this_arg) {
55445         LDKUnsignedInvoiceRequest this_arg_conv;
55446         this_arg_conv.inner = untag_ptr(this_arg);
55447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55449         this_arg_conv.is_owned = false;
55450         LDKPrintableString ret_var = UnsignedInvoiceRequest_issuer(&this_arg_conv);
55451         int64_t ret_ref = 0;
55452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55453         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55454         return ret_ref;
55455 }
55456
55457 int64_tArray  CS_LDK_UnsignedInvoiceRequest_paths(int64_t this_arg) {
55458         LDKUnsignedInvoiceRequest this_arg_conv;
55459         this_arg_conv.inner = untag_ptr(this_arg);
55460         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55462         this_arg_conv.is_owned = false;
55463         LDKCVec_BlindedPathZ ret_var = UnsignedInvoiceRequest_paths(&this_arg_conv);
55464         int64_tArray ret_arr = NULL;
55465         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
55466         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
55467         for (size_t n = 0; n < ret_var.datalen; n++) {
55468                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
55469                 int64_t ret_conv_13_ref = 0;
55470                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
55471                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
55472                 ret_arr_ptr[n] = ret_conv_13_ref;
55473         }
55474         
55475         FREE(ret_var.data);
55476         return ret_arr;
55477 }
55478
55479 int64_t  CS_LDK_UnsignedInvoiceRequest_supported_quantity(int64_t this_arg) {
55480         LDKUnsignedInvoiceRequest this_arg_conv;
55481         this_arg_conv.inner = untag_ptr(this_arg);
55482         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55484         this_arg_conv.is_owned = false;
55485         LDKQuantity ret_var = UnsignedInvoiceRequest_supported_quantity(&this_arg_conv);
55486         int64_t ret_ref = 0;
55487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55489         return ret_ref;
55490 }
55491
55492 int8_tArray  CS_LDK_UnsignedInvoiceRequest_signing_pubkey(int64_t this_arg) {
55493         LDKUnsignedInvoiceRequest this_arg_conv;
55494         this_arg_conv.inner = untag_ptr(this_arg);
55495         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55497         this_arg_conv.is_owned = false;
55498         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55499         memcpy(ret_arr->elems, UnsignedInvoiceRequest_signing_pubkey(&this_arg_conv).compressed_form, 33);
55500         return ret_arr;
55501 }
55502
55503 int8_tArray  CS_LDK_UnsignedInvoiceRequest_payer_metadata(int64_t this_arg) {
55504         LDKUnsignedInvoiceRequest this_arg_conv;
55505         this_arg_conv.inner = untag_ptr(this_arg);
55506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55508         this_arg_conv.is_owned = false;
55509         LDKu8slice ret_var = UnsignedInvoiceRequest_payer_metadata(&this_arg_conv);
55510         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55511         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55512         return ret_arr;
55513 }
55514
55515 int8_tArray  CS_LDK_UnsignedInvoiceRequest_chain(int64_t this_arg) {
55516         LDKUnsignedInvoiceRequest this_arg_conv;
55517         this_arg_conv.inner = untag_ptr(this_arg);
55518         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55520         this_arg_conv.is_owned = false;
55521         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
55522         memcpy(ret_arr->elems, UnsignedInvoiceRequest_chain(&this_arg_conv).data, 32);
55523         return ret_arr;
55524 }
55525
55526 int64_t  CS_LDK_UnsignedInvoiceRequest_amount_msats(int64_t this_arg) {
55527         LDKUnsignedInvoiceRequest this_arg_conv;
55528         this_arg_conv.inner = untag_ptr(this_arg);
55529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55531         this_arg_conv.is_owned = false;
55532         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55533         *ret_copy = UnsignedInvoiceRequest_amount_msats(&this_arg_conv);
55534         int64_t ret_ref = tag_ptr(ret_copy, true);
55535         return ret_ref;
55536 }
55537
55538 int64_t  CS_LDK_UnsignedInvoiceRequest_invoice_request_features(int64_t this_arg) {
55539         LDKUnsignedInvoiceRequest this_arg_conv;
55540         this_arg_conv.inner = untag_ptr(this_arg);
55541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55543         this_arg_conv.is_owned = false;
55544         LDKInvoiceRequestFeatures ret_var = UnsignedInvoiceRequest_invoice_request_features(&this_arg_conv);
55545         int64_t ret_ref = 0;
55546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55548         return ret_ref;
55549 }
55550
55551 int64_t  CS_LDK_UnsignedInvoiceRequest_quantity(int64_t this_arg) {
55552         LDKUnsignedInvoiceRequest this_arg_conv;
55553         this_arg_conv.inner = untag_ptr(this_arg);
55554         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55556         this_arg_conv.is_owned = false;
55557         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55558         *ret_copy = UnsignedInvoiceRequest_quantity(&this_arg_conv);
55559         int64_t ret_ref = tag_ptr(ret_copy, true);
55560         return ret_ref;
55561 }
55562
55563 int8_tArray  CS_LDK_UnsignedInvoiceRequest_payer_id(int64_t this_arg) {
55564         LDKUnsignedInvoiceRequest this_arg_conv;
55565         this_arg_conv.inner = untag_ptr(this_arg);
55566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55568         this_arg_conv.is_owned = false;
55569         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55570         memcpy(ret_arr->elems, UnsignedInvoiceRequest_payer_id(&this_arg_conv).compressed_form, 33);
55571         return ret_arr;
55572 }
55573
55574 int64_t  CS_LDK_UnsignedInvoiceRequest_payer_note(int64_t this_arg) {
55575         LDKUnsignedInvoiceRequest this_arg_conv;
55576         this_arg_conv.inner = untag_ptr(this_arg);
55577         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55579         this_arg_conv.is_owned = false;
55580         LDKPrintableString ret_var = UnsignedInvoiceRequest_payer_note(&this_arg_conv);
55581         int64_t ret_ref = 0;
55582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55584         return ret_ref;
55585 }
55586
55587 ptrArray  CS_LDK_InvoiceRequest_chains(int64_t this_arg) {
55588         LDKInvoiceRequest this_arg_conv;
55589         this_arg_conv.inner = untag_ptr(this_arg);
55590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55592         this_arg_conv.is_owned = false;
55593         LDKCVec_ThirtyTwoBytesZ ret_var = InvoiceRequest_chains(&this_arg_conv);
55594         ptrArray ret_arr = NULL;
55595         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
55596         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
55597         for (size_t i = 0; i < ret_var.datalen; i++) {
55598                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
55599                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
55600                 ret_arr_ptr[i] = ret_conv_8_arr;
55601         }
55602         
55603         FREE(ret_var.data);
55604         return ret_arr;
55605 }
55606
55607 int64_t  CS_LDK_InvoiceRequest_metadata(int64_t this_arg) {
55608         LDKInvoiceRequest this_arg_conv;
55609         this_arg_conv.inner = untag_ptr(this_arg);
55610         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55612         this_arg_conv.is_owned = false;
55613         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55614         *ret_copy = InvoiceRequest_metadata(&this_arg_conv);
55615         int64_t ret_ref = tag_ptr(ret_copy, true);
55616         return ret_ref;
55617 }
55618
55619 int64_t  CS_LDK_InvoiceRequest_amount(int64_t this_arg) {
55620         LDKInvoiceRequest this_arg_conv;
55621         this_arg_conv.inner = untag_ptr(this_arg);
55622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55624         this_arg_conv.is_owned = false;
55625         LDKAmount ret_var = InvoiceRequest_amount(&this_arg_conv);
55626         int64_t ret_ref = 0;
55627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55628         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55629         return ret_ref;
55630 }
55631
55632 int64_t  CS_LDK_InvoiceRequest_description(int64_t this_arg) {
55633         LDKInvoiceRequest this_arg_conv;
55634         this_arg_conv.inner = untag_ptr(this_arg);
55635         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55637         this_arg_conv.is_owned = false;
55638         LDKPrintableString ret_var = InvoiceRequest_description(&this_arg_conv);
55639         int64_t ret_ref = 0;
55640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55642         return ret_ref;
55643 }
55644
55645 int64_t  CS_LDK_InvoiceRequest_offer_features(int64_t this_arg) {
55646         LDKInvoiceRequest this_arg_conv;
55647         this_arg_conv.inner = untag_ptr(this_arg);
55648         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55650         this_arg_conv.is_owned = false;
55651         LDKOfferFeatures ret_var = InvoiceRequest_offer_features(&this_arg_conv);
55652         int64_t ret_ref = 0;
55653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55655         return ret_ref;
55656 }
55657
55658 int64_t  CS_LDK_InvoiceRequest_absolute_expiry(int64_t this_arg) {
55659         LDKInvoiceRequest this_arg_conv;
55660         this_arg_conv.inner = untag_ptr(this_arg);
55661         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55663         this_arg_conv.is_owned = false;
55664         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55665         *ret_copy = InvoiceRequest_absolute_expiry(&this_arg_conv);
55666         int64_t ret_ref = tag_ptr(ret_copy, true);
55667         return ret_ref;
55668 }
55669
55670 int64_t  CS_LDK_InvoiceRequest_issuer(int64_t this_arg) {
55671         LDKInvoiceRequest this_arg_conv;
55672         this_arg_conv.inner = untag_ptr(this_arg);
55673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55675         this_arg_conv.is_owned = false;
55676         LDKPrintableString ret_var = InvoiceRequest_issuer(&this_arg_conv);
55677         int64_t ret_ref = 0;
55678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55680         return ret_ref;
55681 }
55682
55683 int64_tArray  CS_LDK_InvoiceRequest_paths(int64_t this_arg) {
55684         LDKInvoiceRequest this_arg_conv;
55685         this_arg_conv.inner = untag_ptr(this_arg);
55686         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55688         this_arg_conv.is_owned = false;
55689         LDKCVec_BlindedPathZ ret_var = InvoiceRequest_paths(&this_arg_conv);
55690         int64_tArray ret_arr = NULL;
55691         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
55692         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
55693         for (size_t n = 0; n < ret_var.datalen; n++) {
55694                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
55695                 int64_t ret_conv_13_ref = 0;
55696                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
55697                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
55698                 ret_arr_ptr[n] = ret_conv_13_ref;
55699         }
55700         
55701         FREE(ret_var.data);
55702         return ret_arr;
55703 }
55704
55705 int64_t  CS_LDK_InvoiceRequest_supported_quantity(int64_t this_arg) {
55706         LDKInvoiceRequest this_arg_conv;
55707         this_arg_conv.inner = untag_ptr(this_arg);
55708         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55710         this_arg_conv.is_owned = false;
55711         LDKQuantity ret_var = InvoiceRequest_supported_quantity(&this_arg_conv);
55712         int64_t ret_ref = 0;
55713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55715         return ret_ref;
55716 }
55717
55718 int8_tArray  CS_LDK_InvoiceRequest_signing_pubkey(int64_t this_arg) {
55719         LDKInvoiceRequest this_arg_conv;
55720         this_arg_conv.inner = untag_ptr(this_arg);
55721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55723         this_arg_conv.is_owned = false;
55724         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55725         memcpy(ret_arr->elems, InvoiceRequest_signing_pubkey(&this_arg_conv).compressed_form, 33);
55726         return ret_arr;
55727 }
55728
55729 int8_tArray  CS_LDK_InvoiceRequest_payer_metadata(int64_t this_arg) {
55730         LDKInvoiceRequest this_arg_conv;
55731         this_arg_conv.inner = untag_ptr(this_arg);
55732         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55734         this_arg_conv.is_owned = false;
55735         LDKu8slice ret_var = InvoiceRequest_payer_metadata(&this_arg_conv);
55736         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55737         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55738         return ret_arr;
55739 }
55740
55741 int8_tArray  CS_LDK_InvoiceRequest_chain(int64_t this_arg) {
55742         LDKInvoiceRequest this_arg_conv;
55743         this_arg_conv.inner = untag_ptr(this_arg);
55744         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55746         this_arg_conv.is_owned = false;
55747         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
55748         memcpy(ret_arr->elems, InvoiceRequest_chain(&this_arg_conv).data, 32);
55749         return ret_arr;
55750 }
55751
55752 int64_t  CS_LDK_InvoiceRequest_amount_msats(int64_t this_arg) {
55753         LDKInvoiceRequest this_arg_conv;
55754         this_arg_conv.inner = untag_ptr(this_arg);
55755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55757         this_arg_conv.is_owned = false;
55758         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55759         *ret_copy = InvoiceRequest_amount_msats(&this_arg_conv);
55760         int64_t ret_ref = tag_ptr(ret_copy, true);
55761         return ret_ref;
55762 }
55763
55764 int64_t  CS_LDK_InvoiceRequest_invoice_request_features(int64_t this_arg) {
55765         LDKInvoiceRequest this_arg_conv;
55766         this_arg_conv.inner = untag_ptr(this_arg);
55767         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55769         this_arg_conv.is_owned = false;
55770         LDKInvoiceRequestFeatures ret_var = InvoiceRequest_invoice_request_features(&this_arg_conv);
55771         int64_t ret_ref = 0;
55772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55774         return ret_ref;
55775 }
55776
55777 int64_t  CS_LDK_InvoiceRequest_quantity(int64_t this_arg) {
55778         LDKInvoiceRequest this_arg_conv;
55779         this_arg_conv.inner = untag_ptr(this_arg);
55780         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55782         this_arg_conv.is_owned = false;
55783         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55784         *ret_copy = InvoiceRequest_quantity(&this_arg_conv);
55785         int64_t ret_ref = tag_ptr(ret_copy, true);
55786         return ret_ref;
55787 }
55788
55789 int8_tArray  CS_LDK_InvoiceRequest_payer_id(int64_t this_arg) {
55790         LDKInvoiceRequest this_arg_conv;
55791         this_arg_conv.inner = untag_ptr(this_arg);
55792         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55794         this_arg_conv.is_owned = false;
55795         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55796         memcpy(ret_arr->elems, InvoiceRequest_payer_id(&this_arg_conv).compressed_form, 33);
55797         return ret_arr;
55798 }
55799
55800 int64_t  CS_LDK_InvoiceRequest_payer_note(int64_t this_arg) {
55801         LDKInvoiceRequest this_arg_conv;
55802         this_arg_conv.inner = untag_ptr(this_arg);
55803         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55805         this_arg_conv.is_owned = false;
55806         LDKPrintableString ret_var = InvoiceRequest_payer_note(&this_arg_conv);
55807         int64_t ret_ref = 0;
55808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55809         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55810         return ret_ref;
55811 }
55812
55813 int8_tArray  CS_LDK_InvoiceRequest_signature(int64_t this_arg) {
55814         LDKInvoiceRequest this_arg_conv;
55815         this_arg_conv.inner = untag_ptr(this_arg);
55816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55818         this_arg_conv.is_owned = false;
55819         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
55820         memcpy(ret_arr->elems, InvoiceRequest_signature(&this_arg_conv).compact_form, 64);
55821         return ret_arr;
55822 }
55823
55824 int64_t  CS_LDK_InvoiceRequest_verify(int64_t this_arg, int64_t key) {
55825         LDKInvoiceRequest this_arg_conv;
55826         this_arg_conv.inner = untag_ptr(this_arg);
55827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55829         this_arg_conv = InvoiceRequest_clone(&this_arg_conv);
55830         LDKExpandedKey key_conv;
55831         key_conv.inner = untag_ptr(key);
55832         key_conv.is_owned = ptr_is_owned(key);
55833         CHECK_INNER_FIELD_ACCESS_OR_NULL(key_conv);
55834         key_conv.is_owned = false;
55835         LDKCResult_VerifiedInvoiceRequestNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_VerifiedInvoiceRequestNoneZ), "LDKCResult_VerifiedInvoiceRequestNoneZ");
55836         *ret_conv = InvoiceRequest_verify(this_arg_conv, &key_conv);
55837         return tag_ptr(ret_conv, true);
55838 }
55839
55840 ptrArray  CS_LDK_VerifiedInvoiceRequest_chains(int64_t this_arg) {
55841         LDKVerifiedInvoiceRequest this_arg_conv;
55842         this_arg_conv.inner = untag_ptr(this_arg);
55843         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55845         this_arg_conv.is_owned = false;
55846         LDKCVec_ThirtyTwoBytesZ ret_var = VerifiedInvoiceRequest_chains(&this_arg_conv);
55847         ptrArray ret_arr = NULL;
55848         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
55849         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
55850         for (size_t i = 0; i < ret_var.datalen; i++) {
55851                 int8_tArray ret_conv_8_arr = init_int8_tArray(32, __LINE__);
55852                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].data, 32);
55853                 ret_arr_ptr[i] = ret_conv_8_arr;
55854         }
55855         
55856         FREE(ret_var.data);
55857         return ret_arr;
55858 }
55859
55860 int64_t  CS_LDK_VerifiedInvoiceRequest_metadata(int64_t this_arg) {
55861         LDKVerifiedInvoiceRequest this_arg_conv;
55862         this_arg_conv.inner = untag_ptr(this_arg);
55863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55865         this_arg_conv.is_owned = false;
55866         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
55867         *ret_copy = VerifiedInvoiceRequest_metadata(&this_arg_conv);
55868         int64_t ret_ref = tag_ptr(ret_copy, true);
55869         return ret_ref;
55870 }
55871
55872 int64_t  CS_LDK_VerifiedInvoiceRequest_amount(int64_t this_arg) {
55873         LDKVerifiedInvoiceRequest this_arg_conv;
55874         this_arg_conv.inner = untag_ptr(this_arg);
55875         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55877         this_arg_conv.is_owned = false;
55878         LDKAmount ret_var = VerifiedInvoiceRequest_amount(&this_arg_conv);
55879         int64_t ret_ref = 0;
55880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55881         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55882         return ret_ref;
55883 }
55884
55885 int64_t  CS_LDK_VerifiedInvoiceRequest_description(int64_t this_arg) {
55886         LDKVerifiedInvoiceRequest this_arg_conv;
55887         this_arg_conv.inner = untag_ptr(this_arg);
55888         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55890         this_arg_conv.is_owned = false;
55891         LDKPrintableString ret_var = VerifiedInvoiceRequest_description(&this_arg_conv);
55892         int64_t ret_ref = 0;
55893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55895         return ret_ref;
55896 }
55897
55898 int64_t  CS_LDK_VerifiedInvoiceRequest_offer_features(int64_t this_arg) {
55899         LDKVerifiedInvoiceRequest this_arg_conv;
55900         this_arg_conv.inner = untag_ptr(this_arg);
55901         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55903         this_arg_conv.is_owned = false;
55904         LDKOfferFeatures ret_var = VerifiedInvoiceRequest_offer_features(&this_arg_conv);
55905         int64_t ret_ref = 0;
55906         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55907         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55908         return ret_ref;
55909 }
55910
55911 int64_t  CS_LDK_VerifiedInvoiceRequest_absolute_expiry(int64_t this_arg) {
55912         LDKVerifiedInvoiceRequest this_arg_conv;
55913         this_arg_conv.inner = untag_ptr(this_arg);
55914         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55916         this_arg_conv.is_owned = false;
55917         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
55918         *ret_copy = VerifiedInvoiceRequest_absolute_expiry(&this_arg_conv);
55919         int64_t ret_ref = tag_ptr(ret_copy, true);
55920         return ret_ref;
55921 }
55922
55923 int64_t  CS_LDK_VerifiedInvoiceRequest_issuer(int64_t this_arg) {
55924         LDKVerifiedInvoiceRequest this_arg_conv;
55925         this_arg_conv.inner = untag_ptr(this_arg);
55926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55928         this_arg_conv.is_owned = false;
55929         LDKPrintableString ret_var = VerifiedInvoiceRequest_issuer(&this_arg_conv);
55930         int64_t ret_ref = 0;
55931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55933         return ret_ref;
55934 }
55935
55936 int64_tArray  CS_LDK_VerifiedInvoiceRequest_paths(int64_t this_arg) {
55937         LDKVerifiedInvoiceRequest this_arg_conv;
55938         this_arg_conv.inner = untag_ptr(this_arg);
55939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55941         this_arg_conv.is_owned = false;
55942         LDKCVec_BlindedPathZ ret_var = VerifiedInvoiceRequest_paths(&this_arg_conv);
55943         int64_tArray ret_arr = NULL;
55944         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
55945         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
55946         for (size_t n = 0; n < ret_var.datalen; n++) {
55947                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
55948                 int64_t ret_conv_13_ref = 0;
55949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
55950                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
55951                 ret_arr_ptr[n] = ret_conv_13_ref;
55952         }
55953         
55954         FREE(ret_var.data);
55955         return ret_arr;
55956 }
55957
55958 int64_t  CS_LDK_VerifiedInvoiceRequest_supported_quantity(int64_t this_arg) {
55959         LDKVerifiedInvoiceRequest this_arg_conv;
55960         this_arg_conv.inner = untag_ptr(this_arg);
55961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55963         this_arg_conv.is_owned = false;
55964         LDKQuantity ret_var = VerifiedInvoiceRequest_supported_quantity(&this_arg_conv);
55965         int64_t ret_ref = 0;
55966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
55967         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
55968         return ret_ref;
55969 }
55970
55971 int8_tArray  CS_LDK_VerifiedInvoiceRequest_signing_pubkey(int64_t this_arg) {
55972         LDKVerifiedInvoiceRequest this_arg_conv;
55973         this_arg_conv.inner = untag_ptr(this_arg);
55974         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55976         this_arg_conv.is_owned = false;
55977         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
55978         memcpy(ret_arr->elems, VerifiedInvoiceRequest_signing_pubkey(&this_arg_conv).compressed_form, 33);
55979         return ret_arr;
55980 }
55981
55982 int8_tArray  CS_LDK_VerifiedInvoiceRequest_payer_metadata(int64_t this_arg) {
55983         LDKVerifiedInvoiceRequest this_arg_conv;
55984         this_arg_conv.inner = untag_ptr(this_arg);
55985         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55987         this_arg_conv.is_owned = false;
55988         LDKu8slice ret_var = VerifiedInvoiceRequest_payer_metadata(&this_arg_conv);
55989         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
55990         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
55991         return ret_arr;
55992 }
55993
55994 int8_tArray  CS_LDK_VerifiedInvoiceRequest_chain(int64_t this_arg) {
55995         LDKVerifiedInvoiceRequest this_arg_conv;
55996         this_arg_conv.inner = untag_ptr(this_arg);
55997         this_arg_conv.is_owned = ptr_is_owned(this_arg);
55998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
55999         this_arg_conv.is_owned = false;
56000         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
56001         memcpy(ret_arr->elems, VerifiedInvoiceRequest_chain(&this_arg_conv).data, 32);
56002         return ret_arr;
56003 }
56004
56005 int64_t  CS_LDK_VerifiedInvoiceRequest_amount_msats(int64_t this_arg) {
56006         LDKVerifiedInvoiceRequest this_arg_conv;
56007         this_arg_conv.inner = untag_ptr(this_arg);
56008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56010         this_arg_conv.is_owned = false;
56011         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56012         *ret_copy = VerifiedInvoiceRequest_amount_msats(&this_arg_conv);
56013         int64_t ret_ref = tag_ptr(ret_copy, true);
56014         return ret_ref;
56015 }
56016
56017 int64_t  CS_LDK_VerifiedInvoiceRequest_invoice_request_features(int64_t this_arg) {
56018         LDKVerifiedInvoiceRequest this_arg_conv;
56019         this_arg_conv.inner = untag_ptr(this_arg);
56020         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56022         this_arg_conv.is_owned = false;
56023         LDKInvoiceRequestFeatures ret_var = VerifiedInvoiceRequest_invoice_request_features(&this_arg_conv);
56024         int64_t ret_ref = 0;
56025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56027         return ret_ref;
56028 }
56029
56030 int64_t  CS_LDK_VerifiedInvoiceRequest_quantity(int64_t this_arg) {
56031         LDKVerifiedInvoiceRequest this_arg_conv;
56032         this_arg_conv.inner = untag_ptr(this_arg);
56033         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56035         this_arg_conv.is_owned = false;
56036         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56037         *ret_copy = VerifiedInvoiceRequest_quantity(&this_arg_conv);
56038         int64_t ret_ref = tag_ptr(ret_copy, true);
56039         return ret_ref;
56040 }
56041
56042 int8_tArray  CS_LDK_VerifiedInvoiceRequest_payer_id(int64_t this_arg) {
56043         LDKVerifiedInvoiceRequest this_arg_conv;
56044         this_arg_conv.inner = untag_ptr(this_arg);
56045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56047         this_arg_conv.is_owned = false;
56048         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
56049         memcpy(ret_arr->elems, VerifiedInvoiceRequest_payer_id(&this_arg_conv).compressed_form, 33);
56050         return ret_arr;
56051 }
56052
56053 int64_t  CS_LDK_VerifiedInvoiceRequest_payer_note(int64_t this_arg) {
56054         LDKVerifiedInvoiceRequest this_arg_conv;
56055         this_arg_conv.inner = untag_ptr(this_arg);
56056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56058         this_arg_conv.is_owned = false;
56059         LDKPrintableString ret_var = VerifiedInvoiceRequest_payer_note(&this_arg_conv);
56060         int64_t ret_ref = 0;
56061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56062         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56063         return ret_ref;
56064 }
56065
56066 int8_tArray  CS_LDK_UnsignedInvoiceRequest_write(int64_t obj) {
56067         LDKUnsignedInvoiceRequest obj_conv;
56068         obj_conv.inner = untag_ptr(obj);
56069         obj_conv.is_owned = ptr_is_owned(obj);
56070         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56071         obj_conv.is_owned = false;
56072         LDKCVec_u8Z ret_var = UnsignedInvoiceRequest_write(&obj_conv);
56073         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56074         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56075         CVec_u8Z_free(ret_var);
56076         return ret_arr;
56077 }
56078
56079 int8_tArray  CS_LDK_InvoiceRequest_write(int64_t obj) {
56080         LDKInvoiceRequest obj_conv;
56081         obj_conv.inner = untag_ptr(obj);
56082         obj_conv.is_owned = ptr_is_owned(obj);
56083         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56084         obj_conv.is_owned = false;
56085         LDKCVec_u8Z ret_var = InvoiceRequest_write(&obj_conv);
56086         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56087         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56088         CVec_u8Z_free(ret_var);
56089         return ret_arr;
56090 }
56091
56092 void  CS_LDK_TaggedHash_free(int64_t this_obj) {
56093         LDKTaggedHash this_obj_conv;
56094         this_obj_conv.inner = untag_ptr(this_obj);
56095         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56097         TaggedHash_free(this_obj_conv);
56098 }
56099
56100 void  CS_LDK_Bolt12ParseError_free(int64_t this_obj) {
56101         LDKBolt12ParseError this_obj_conv;
56102         this_obj_conv.inner = untag_ptr(this_obj);
56103         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56105         Bolt12ParseError_free(this_obj_conv);
56106 }
56107
56108 static inline uint64_t Bolt12ParseError_clone_ptr(LDKBolt12ParseError *NONNULL_PTR arg) {
56109         LDKBolt12ParseError ret_var = Bolt12ParseError_clone(arg);
56110         int64_t ret_ref = 0;
56111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56113         return ret_ref;
56114 }
56115 int64_t  CS_LDK_Bolt12ParseError_clone_ptr(int64_t arg) {
56116         LDKBolt12ParseError arg_conv;
56117         arg_conv.inner = untag_ptr(arg);
56118         arg_conv.is_owned = ptr_is_owned(arg);
56119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56120         arg_conv.is_owned = false;
56121         int64_t ret_conv = Bolt12ParseError_clone_ptr(&arg_conv);
56122         return ret_conv;
56123 }
56124
56125 int64_t  CS_LDK_Bolt12ParseError_clone(int64_t orig) {
56126         LDKBolt12ParseError orig_conv;
56127         orig_conv.inner = untag_ptr(orig);
56128         orig_conv.is_owned = ptr_is_owned(orig);
56129         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56130         orig_conv.is_owned = false;
56131         LDKBolt12ParseError ret_var = Bolt12ParseError_clone(&orig_conv);
56132         int64_t ret_ref = 0;
56133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56134         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56135         return ret_ref;
56136 }
56137
56138 int32_t  CS_LDK_Bolt12SemanticError_clone(int64_t orig) {
56139         LDKBolt12SemanticError* orig_conv = (LDKBolt12SemanticError*)untag_ptr(orig);
56140         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_clone(orig_conv));
56141         return ret_conv;
56142 }
56143
56144 int32_t  CS_LDK_Bolt12SemanticError_already_expired() {
56145         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_already_expired());
56146         return ret_conv;
56147 }
56148
56149 int32_t  CS_LDK_Bolt12SemanticError_unsupported_chain() {
56150         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unsupported_chain());
56151         return ret_conv;
56152 }
56153
56154 int32_t  CS_LDK_Bolt12SemanticError_unexpected_chain() {
56155         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_chain());
56156         return ret_conv;
56157 }
56158
56159 int32_t  CS_LDK_Bolt12SemanticError_missing_amount() {
56160         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_amount());
56161         return ret_conv;
56162 }
56163
56164 int32_t  CS_LDK_Bolt12SemanticError_invalid_amount() {
56165         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_amount());
56166         return ret_conv;
56167 }
56168
56169 int32_t  CS_LDK_Bolt12SemanticError_insufficient_amount() {
56170         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_insufficient_amount());
56171         return ret_conv;
56172 }
56173
56174 int32_t  CS_LDK_Bolt12SemanticError_unexpected_amount() {
56175         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_amount());
56176         return ret_conv;
56177 }
56178
56179 int32_t  CS_LDK_Bolt12SemanticError_unsupported_currency() {
56180         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unsupported_currency());
56181         return ret_conv;
56182 }
56183
56184 int32_t  CS_LDK_Bolt12SemanticError_unknown_required_features() {
56185         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unknown_required_features());
56186         return ret_conv;
56187 }
56188
56189 int32_t  CS_LDK_Bolt12SemanticError_unexpected_features() {
56190         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_features());
56191         return ret_conv;
56192 }
56193
56194 int32_t  CS_LDK_Bolt12SemanticError_missing_description() {
56195         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_description());
56196         return ret_conv;
56197 }
56198
56199 int32_t  CS_LDK_Bolt12SemanticError_missing_signing_pubkey() {
56200         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_signing_pubkey());
56201         return ret_conv;
56202 }
56203
56204 int32_t  CS_LDK_Bolt12SemanticError_invalid_signing_pubkey() {
56205         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_signing_pubkey());
56206         return ret_conv;
56207 }
56208
56209 int32_t  CS_LDK_Bolt12SemanticError_unexpected_signing_pubkey() {
56210         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_signing_pubkey());
56211         return ret_conv;
56212 }
56213
56214 int32_t  CS_LDK_Bolt12SemanticError_missing_quantity() {
56215         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_quantity());
56216         return ret_conv;
56217 }
56218
56219 int32_t  CS_LDK_Bolt12SemanticError_invalid_quantity() {
56220         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_quantity());
56221         return ret_conv;
56222 }
56223
56224 int32_t  CS_LDK_Bolt12SemanticError_unexpected_quantity() {
56225         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_quantity());
56226         return ret_conv;
56227 }
56228
56229 int32_t  CS_LDK_Bolt12SemanticError_invalid_metadata() {
56230         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_metadata());
56231         return ret_conv;
56232 }
56233
56234 int32_t  CS_LDK_Bolt12SemanticError_unexpected_metadata() {
56235         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_unexpected_metadata());
56236         return ret_conv;
56237 }
56238
56239 int32_t  CS_LDK_Bolt12SemanticError_missing_payer_metadata() {
56240         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_payer_metadata());
56241         return ret_conv;
56242 }
56243
56244 int32_t  CS_LDK_Bolt12SemanticError_missing_payer_id() {
56245         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_payer_id());
56246         return ret_conv;
56247 }
56248
56249 int32_t  CS_LDK_Bolt12SemanticError_duplicate_payment_id() {
56250         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_duplicate_payment_id());
56251         return ret_conv;
56252 }
56253
56254 int32_t  CS_LDK_Bolt12SemanticError_missing_paths() {
56255         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_paths());
56256         return ret_conv;
56257 }
56258
56259 int32_t  CS_LDK_Bolt12SemanticError_invalid_pay_info() {
56260         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_invalid_pay_info());
56261         return ret_conv;
56262 }
56263
56264 int32_t  CS_LDK_Bolt12SemanticError_missing_creation_time() {
56265         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_creation_time());
56266         return ret_conv;
56267 }
56268
56269 int32_t  CS_LDK_Bolt12SemanticError_missing_payment_hash() {
56270         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_payment_hash());
56271         return ret_conv;
56272 }
56273
56274 int32_t  CS_LDK_Bolt12SemanticError_missing_signature() {
56275         int32_t ret_conv = LDKBolt12SemanticError_to_cs(Bolt12SemanticError_missing_signature());
56276         return ret_conv;
56277 }
56278
56279 void  CS_LDK_Refund_free(int64_t this_obj) {
56280         LDKRefund this_obj_conv;
56281         this_obj_conv.inner = untag_ptr(this_obj);
56282         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56284         Refund_free(this_obj_conv);
56285 }
56286
56287 static inline uint64_t Refund_clone_ptr(LDKRefund *NONNULL_PTR arg) {
56288         LDKRefund ret_var = Refund_clone(arg);
56289         int64_t ret_ref = 0;
56290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56292         return ret_ref;
56293 }
56294 int64_t  CS_LDK_Refund_clone_ptr(int64_t arg) {
56295         LDKRefund arg_conv;
56296         arg_conv.inner = untag_ptr(arg);
56297         arg_conv.is_owned = ptr_is_owned(arg);
56298         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56299         arg_conv.is_owned = false;
56300         int64_t ret_conv = Refund_clone_ptr(&arg_conv);
56301         return ret_conv;
56302 }
56303
56304 int64_t  CS_LDK_Refund_clone(int64_t orig) {
56305         LDKRefund orig_conv;
56306         orig_conv.inner = untag_ptr(orig);
56307         orig_conv.is_owned = ptr_is_owned(orig);
56308         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56309         orig_conv.is_owned = false;
56310         LDKRefund ret_var = Refund_clone(&orig_conv);
56311         int64_t ret_ref = 0;
56312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56314         return ret_ref;
56315 }
56316
56317 int64_t  CS_LDK_Refund_description(int64_t this_arg) {
56318         LDKRefund this_arg_conv;
56319         this_arg_conv.inner = untag_ptr(this_arg);
56320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56322         this_arg_conv.is_owned = false;
56323         LDKPrintableString ret_var = Refund_description(&this_arg_conv);
56324         int64_t ret_ref = 0;
56325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56326         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56327         return ret_ref;
56328 }
56329
56330 int64_t  CS_LDK_Refund_absolute_expiry(int64_t this_arg) {
56331         LDKRefund this_arg_conv;
56332         this_arg_conv.inner = untag_ptr(this_arg);
56333         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56335         this_arg_conv.is_owned = false;
56336         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56337         *ret_copy = Refund_absolute_expiry(&this_arg_conv);
56338         int64_t ret_ref = tag_ptr(ret_copy, true);
56339         return ret_ref;
56340 }
56341
56342 jboolean  CS_LDK_Refund_is_expired(int64_t this_arg) {
56343         LDKRefund this_arg_conv;
56344         this_arg_conv.inner = untag_ptr(this_arg);
56345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56347         this_arg_conv.is_owned = false;
56348         jboolean ret_conv = Refund_is_expired(&this_arg_conv);
56349         return ret_conv;
56350 }
56351
56352 int64_t  CS_LDK_Refund_issuer(int64_t this_arg) {
56353         LDKRefund this_arg_conv;
56354         this_arg_conv.inner = untag_ptr(this_arg);
56355         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56357         this_arg_conv.is_owned = false;
56358         LDKPrintableString ret_var = Refund_issuer(&this_arg_conv);
56359         int64_t ret_ref = 0;
56360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56362         return ret_ref;
56363 }
56364
56365 int64_tArray  CS_LDK_Refund_paths(int64_t this_arg) {
56366         LDKRefund this_arg_conv;
56367         this_arg_conv.inner = untag_ptr(this_arg);
56368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56370         this_arg_conv.is_owned = false;
56371         LDKCVec_BlindedPathZ ret_var = Refund_paths(&this_arg_conv);
56372         int64_tArray ret_arr = NULL;
56373         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
56374         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
56375         for (size_t n = 0; n < ret_var.datalen; n++) {
56376                 LDKBlindedPath ret_conv_13_var = ret_var.data[n];
56377                 int64_t ret_conv_13_ref = 0;
56378                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_13_var);
56379                 ret_conv_13_ref = tag_ptr(ret_conv_13_var.inner, ret_conv_13_var.is_owned);
56380                 ret_arr_ptr[n] = ret_conv_13_ref;
56381         }
56382         
56383         FREE(ret_var.data);
56384         return ret_arr;
56385 }
56386
56387 int8_tArray  CS_LDK_Refund_payer_metadata(int64_t this_arg) {
56388         LDKRefund this_arg_conv;
56389         this_arg_conv.inner = untag_ptr(this_arg);
56390         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56392         this_arg_conv.is_owned = false;
56393         LDKu8slice ret_var = Refund_payer_metadata(&this_arg_conv);
56394         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56395         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56396         return ret_arr;
56397 }
56398
56399 int8_tArray  CS_LDK_Refund_chain(int64_t this_arg) {
56400         LDKRefund this_arg_conv;
56401         this_arg_conv.inner = untag_ptr(this_arg);
56402         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56404         this_arg_conv.is_owned = false;
56405         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
56406         memcpy(ret_arr->elems, Refund_chain(&this_arg_conv).data, 32);
56407         return ret_arr;
56408 }
56409
56410 int64_t  CS_LDK_Refund_amount_msats(int64_t this_arg) {
56411         LDKRefund this_arg_conv;
56412         this_arg_conv.inner = untag_ptr(this_arg);
56413         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56415         this_arg_conv.is_owned = false;
56416         int64_t ret_conv = Refund_amount_msats(&this_arg_conv);
56417         return ret_conv;
56418 }
56419
56420 int64_t  CS_LDK_Refund_features(int64_t this_arg) {
56421         LDKRefund this_arg_conv;
56422         this_arg_conv.inner = untag_ptr(this_arg);
56423         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56425         this_arg_conv.is_owned = false;
56426         LDKInvoiceRequestFeatures ret_var = Refund_features(&this_arg_conv);
56427         int64_t ret_ref = 0;
56428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56429         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56430         return ret_ref;
56431 }
56432
56433 int64_t  CS_LDK_Refund_quantity(int64_t this_arg) {
56434         LDKRefund this_arg_conv;
56435         this_arg_conv.inner = untag_ptr(this_arg);
56436         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56438         this_arg_conv.is_owned = false;
56439         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
56440         *ret_copy = Refund_quantity(&this_arg_conv);
56441         int64_t ret_ref = tag_ptr(ret_copy, true);
56442         return ret_ref;
56443 }
56444
56445 int8_tArray  CS_LDK_Refund_payer_id(int64_t this_arg) {
56446         LDKRefund this_arg_conv;
56447         this_arg_conv.inner = untag_ptr(this_arg);
56448         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56450         this_arg_conv.is_owned = false;
56451         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
56452         memcpy(ret_arr->elems, Refund_payer_id(&this_arg_conv).compressed_form, 33);
56453         return ret_arr;
56454 }
56455
56456 int64_t  CS_LDK_Refund_payer_note(int64_t this_arg) {
56457         LDKRefund this_arg_conv;
56458         this_arg_conv.inner = untag_ptr(this_arg);
56459         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56461         this_arg_conv.is_owned = false;
56462         LDKPrintableString ret_var = Refund_payer_note(&this_arg_conv);
56463         int64_t ret_ref = 0;
56464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56465         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56466         return ret_ref;
56467 }
56468
56469 int8_tArray  CS_LDK_Refund_write(int64_t obj) {
56470         LDKRefund obj_conv;
56471         obj_conv.inner = untag_ptr(obj);
56472         obj_conv.is_owned = ptr_is_owned(obj);
56473         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56474         obj_conv.is_owned = false;
56475         LDKCVec_u8Z ret_var = Refund_write(&obj_conv);
56476         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56477         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56478         CVec_u8Z_free(ret_var);
56479         return ret_arr;
56480 }
56481
56482 int64_t  CS_LDK_Refund_from_str(jstring s) {
56483         LDKStr s_conv = str_ref_to_owned_c(s);
56484         LDKCResult_RefundBolt12ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RefundBolt12ParseErrorZ), "LDKCResult_RefundBolt12ParseErrorZ");
56485         *ret_conv = Refund_from_str(s_conv);
56486         return tag_ptr(ret_conv, true);
56487 }
56488
56489 int32_t  CS_LDK_UtxoLookupError_clone(int64_t orig) {
56490         LDKUtxoLookupError* orig_conv = (LDKUtxoLookupError*)untag_ptr(orig);
56491         int32_t ret_conv = LDKUtxoLookupError_to_cs(UtxoLookupError_clone(orig_conv));
56492         return ret_conv;
56493 }
56494
56495 int32_t  CS_LDK_UtxoLookupError_unknown_chain() {
56496         int32_t ret_conv = LDKUtxoLookupError_to_cs(UtxoLookupError_unknown_chain());
56497         return ret_conv;
56498 }
56499
56500 int32_t  CS_LDK_UtxoLookupError_unknown_tx() {
56501         int32_t ret_conv = LDKUtxoLookupError_to_cs(UtxoLookupError_unknown_tx());
56502         return ret_conv;
56503 }
56504
56505 void  CS_LDK_UtxoResult_free(int64_t this_ptr) {
56506         if (!ptr_is_owned(this_ptr)) return;
56507         void* this_ptr_ptr = untag_ptr(this_ptr);
56508         CHECK_ACCESS(this_ptr_ptr);
56509         LDKUtxoResult this_ptr_conv = *(LDKUtxoResult*)(this_ptr_ptr);
56510         FREE(untag_ptr(this_ptr));
56511         UtxoResult_free(this_ptr_conv);
56512 }
56513
56514 static inline uint64_t UtxoResult_clone_ptr(LDKUtxoResult *NONNULL_PTR arg) {
56515         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56516         *ret_copy = UtxoResult_clone(arg);
56517         int64_t ret_ref = tag_ptr(ret_copy, true);
56518         return ret_ref;
56519 }
56520 int64_t  CS_LDK_UtxoResult_clone_ptr(int64_t arg) {
56521         LDKUtxoResult* arg_conv = (LDKUtxoResult*)untag_ptr(arg);
56522         int64_t ret_conv = UtxoResult_clone_ptr(arg_conv);
56523         return ret_conv;
56524 }
56525
56526 int64_t  CS_LDK_UtxoResult_clone(int64_t orig) {
56527         LDKUtxoResult* orig_conv = (LDKUtxoResult*)untag_ptr(orig);
56528         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56529         *ret_copy = UtxoResult_clone(orig_conv);
56530         int64_t ret_ref = tag_ptr(ret_copy, true);
56531         return ret_ref;
56532 }
56533
56534 int64_t  CS_LDK_UtxoResult_sync(int64_t a) {
56535         void* a_ptr = untag_ptr(a);
56536         CHECK_ACCESS(a_ptr);
56537         LDKCResult_TxOutUtxoLookupErrorZ a_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(a_ptr);
56538         a_conv = CResult_TxOutUtxoLookupErrorZ_clone((LDKCResult_TxOutUtxoLookupErrorZ*)untag_ptr(a));
56539         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56540         *ret_copy = UtxoResult_sync(a_conv);
56541         int64_t ret_ref = tag_ptr(ret_copy, true);
56542         return ret_ref;
56543 }
56544
56545 int64_t  CS_LDK_UtxoResult_async(int64_t a) {
56546         LDKUtxoFuture a_conv;
56547         a_conv.inner = untag_ptr(a);
56548         a_conv.is_owned = ptr_is_owned(a);
56549         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
56550         a_conv = UtxoFuture_clone(&a_conv);
56551         LDKUtxoResult *ret_copy = MALLOC(sizeof(LDKUtxoResult), "LDKUtxoResult");
56552         *ret_copy = UtxoResult_async(a_conv);
56553         int64_t ret_ref = tag_ptr(ret_copy, true);
56554         return ret_ref;
56555 }
56556
56557 void  CS_LDK_UtxoLookup_free(int64_t this_ptr) {
56558         if (!ptr_is_owned(this_ptr)) return;
56559         void* this_ptr_ptr = untag_ptr(this_ptr);
56560         CHECK_ACCESS(this_ptr_ptr);
56561         LDKUtxoLookup this_ptr_conv = *(LDKUtxoLookup*)(this_ptr_ptr);
56562         FREE(untag_ptr(this_ptr));
56563         UtxoLookup_free(this_ptr_conv);
56564 }
56565
56566 void  CS_LDK_UtxoFuture_free(int64_t this_obj) {
56567         LDKUtxoFuture this_obj_conv;
56568         this_obj_conv.inner = untag_ptr(this_obj);
56569         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56571         UtxoFuture_free(this_obj_conv);
56572 }
56573
56574 static inline uint64_t UtxoFuture_clone_ptr(LDKUtxoFuture *NONNULL_PTR arg) {
56575         LDKUtxoFuture ret_var = UtxoFuture_clone(arg);
56576         int64_t ret_ref = 0;
56577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56578         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56579         return ret_ref;
56580 }
56581 int64_t  CS_LDK_UtxoFuture_clone_ptr(int64_t arg) {
56582         LDKUtxoFuture arg_conv;
56583         arg_conv.inner = untag_ptr(arg);
56584         arg_conv.is_owned = ptr_is_owned(arg);
56585         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56586         arg_conv.is_owned = false;
56587         int64_t ret_conv = UtxoFuture_clone_ptr(&arg_conv);
56588         return ret_conv;
56589 }
56590
56591 int64_t  CS_LDK_UtxoFuture_clone(int64_t orig) {
56592         LDKUtxoFuture orig_conv;
56593         orig_conv.inner = untag_ptr(orig);
56594         orig_conv.is_owned = ptr_is_owned(orig);
56595         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56596         orig_conv.is_owned = false;
56597         LDKUtxoFuture ret_var = UtxoFuture_clone(&orig_conv);
56598         int64_t ret_ref = 0;
56599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56601         return ret_ref;
56602 }
56603
56604 int64_t  CS_LDK_UtxoFuture_new() {
56605         LDKUtxoFuture ret_var = UtxoFuture_new();
56606         int64_t ret_ref = 0;
56607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56609         return ret_ref;
56610 }
56611
56612 void  CS_LDK_UtxoFuture_resolve_without_forwarding(int64_t this_arg, int64_t graph, int64_t result) {
56613         LDKUtxoFuture this_arg_conv;
56614         this_arg_conv.inner = untag_ptr(this_arg);
56615         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56617         this_arg_conv.is_owned = false;
56618         LDKNetworkGraph graph_conv;
56619         graph_conv.inner = untag_ptr(graph);
56620         graph_conv.is_owned = ptr_is_owned(graph);
56621         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
56622         graph_conv.is_owned = false;
56623         void* result_ptr = untag_ptr(result);
56624         CHECK_ACCESS(result_ptr);
56625         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
56626         UtxoFuture_resolve_without_forwarding(&this_arg_conv, &graph_conv, result_conv);
56627 }
56628
56629 void  CS_LDK_UtxoFuture_resolve(int64_t this_arg, int64_t graph, int64_t gossip, int64_t result) {
56630         LDKUtxoFuture this_arg_conv;
56631         this_arg_conv.inner = untag_ptr(this_arg);
56632         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56634         this_arg_conv.is_owned = false;
56635         LDKNetworkGraph graph_conv;
56636         graph_conv.inner = untag_ptr(graph);
56637         graph_conv.is_owned = ptr_is_owned(graph);
56638         CHECK_INNER_FIELD_ACCESS_OR_NULL(graph_conv);
56639         graph_conv.is_owned = false;
56640         LDKP2PGossipSync gossip_conv;
56641         gossip_conv.inner = untag_ptr(gossip);
56642         gossip_conv.is_owned = ptr_is_owned(gossip);
56643         CHECK_INNER_FIELD_ACCESS_OR_NULL(gossip_conv);
56644         gossip_conv.is_owned = false;
56645         void* result_ptr = untag_ptr(result);
56646         CHECK_ACCESS(result_ptr);
56647         LDKCResult_TxOutUtxoLookupErrorZ result_conv = *(LDKCResult_TxOutUtxoLookupErrorZ*)(result_ptr);
56648         UtxoFuture_resolve(&this_arg_conv, &graph_conv, &gossip_conv, result_conv);
56649 }
56650
56651 void  CS_LDK_NodeId_free(int64_t this_obj) {
56652         LDKNodeId this_obj_conv;
56653         this_obj_conv.inner = untag_ptr(this_obj);
56654         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56656         NodeId_free(this_obj_conv);
56657 }
56658
56659 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
56660         LDKNodeId ret_var = NodeId_clone(arg);
56661         int64_t ret_ref = 0;
56662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56664         return ret_ref;
56665 }
56666 int64_t  CS_LDK_NodeId_clone_ptr(int64_t arg) {
56667         LDKNodeId arg_conv;
56668         arg_conv.inner = untag_ptr(arg);
56669         arg_conv.is_owned = ptr_is_owned(arg);
56670         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
56671         arg_conv.is_owned = false;
56672         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
56673         return ret_conv;
56674 }
56675
56676 int64_t  CS_LDK_NodeId_clone(int64_t orig) {
56677         LDKNodeId orig_conv;
56678         orig_conv.inner = untag_ptr(orig);
56679         orig_conv.is_owned = ptr_is_owned(orig);
56680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
56681         orig_conv.is_owned = false;
56682         LDKNodeId ret_var = NodeId_clone(&orig_conv);
56683         int64_t ret_ref = 0;
56684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56686         return ret_ref;
56687 }
56688
56689 int64_t  CS_LDK_NodeId_from_pubkey(int8_tArray pubkey) {
56690         LDKPublicKey pubkey_ref;
56691         CHECK(pubkey->arr_len == 33);
56692         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
56693         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
56694         int64_t ret_ref = 0;
56695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56696         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56697         return ret_ref;
56698 }
56699
56700 int8_tArray  CS_LDK_NodeId_as_slice(int64_t this_arg) {
56701         LDKNodeId this_arg_conv;
56702         this_arg_conv.inner = untag_ptr(this_arg);
56703         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56705         this_arg_conv.is_owned = false;
56706         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
56707         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56708         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56709         return ret_arr;
56710 }
56711
56712 int64_t  CS_LDK_NodeId_as_pubkey(int64_t this_arg) {
56713         LDKNodeId this_arg_conv;
56714         this_arg_conv.inner = untag_ptr(this_arg);
56715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56717         this_arg_conv.is_owned = false;
56718         LDKCResult_PublicKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecp256k1ErrorZ), "LDKCResult_PublicKeySecp256k1ErrorZ");
56719         *ret_conv = NodeId_as_pubkey(&this_arg_conv);
56720         return tag_ptr(ret_conv, true);
56721 }
56722
56723 int64_t  CS_LDK_NodeId_hash(int64_t o) {
56724         LDKNodeId o_conv;
56725         o_conv.inner = untag_ptr(o);
56726         o_conv.is_owned = ptr_is_owned(o);
56727         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
56728         o_conv.is_owned = false;
56729         int64_t ret_conv = NodeId_hash(&o_conv);
56730         return ret_conv;
56731 }
56732
56733 int8_tArray  CS_LDK_NodeId_write(int64_t obj) {
56734         LDKNodeId obj_conv;
56735         obj_conv.inner = untag_ptr(obj);
56736         obj_conv.is_owned = ptr_is_owned(obj);
56737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
56738         obj_conv.is_owned = false;
56739         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
56740         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56741         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56742         CVec_u8Z_free(ret_var);
56743         return ret_arr;
56744 }
56745
56746 int64_t  CS_LDK_NodeId_read(int8_tArray ser) {
56747         LDKu8slice ser_ref;
56748         ser_ref.datalen = ser->arr_len;
56749         ser_ref.data = ser->elems;
56750         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
56751         *ret_conv = NodeId_read(ser_ref);
56752         FREE(ser);
56753         return tag_ptr(ret_conv, true);
56754 }
56755
56756 void  CS_LDK_NetworkGraph_free(int64_t this_obj) {
56757         LDKNetworkGraph this_obj_conv;
56758         this_obj_conv.inner = untag_ptr(this_obj);
56759         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56761         NetworkGraph_free(this_obj_conv);
56762 }
56763
56764 void  CS_LDK_ReadOnlyNetworkGraph_free(int64_t this_obj) {
56765         LDKReadOnlyNetworkGraph this_obj_conv;
56766         this_obj_conv.inner = untag_ptr(this_obj);
56767         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56769         ReadOnlyNetworkGraph_free(this_obj_conv);
56770 }
56771
56772 void  CS_LDK_NetworkUpdate_free(int64_t this_ptr) {
56773         if (!ptr_is_owned(this_ptr)) return;
56774         void* this_ptr_ptr = untag_ptr(this_ptr);
56775         CHECK_ACCESS(this_ptr_ptr);
56776         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
56777         FREE(untag_ptr(this_ptr));
56778         NetworkUpdate_free(this_ptr_conv);
56779 }
56780
56781 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
56782         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56783         *ret_copy = NetworkUpdate_clone(arg);
56784         int64_t ret_ref = tag_ptr(ret_copy, true);
56785         return ret_ref;
56786 }
56787 int64_t  CS_LDK_NetworkUpdate_clone_ptr(int64_t arg) {
56788         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
56789         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
56790         return ret_conv;
56791 }
56792
56793 int64_t  CS_LDK_NetworkUpdate_clone(int64_t orig) {
56794         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
56795         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56796         *ret_copy = NetworkUpdate_clone(orig_conv);
56797         int64_t ret_ref = tag_ptr(ret_copy, true);
56798         return ret_ref;
56799 }
56800
56801 int64_t  CS_LDK_NetworkUpdate_channel_update_message(int64_t msg) {
56802         LDKChannelUpdate msg_conv;
56803         msg_conv.inner = untag_ptr(msg);
56804         msg_conv.is_owned = ptr_is_owned(msg);
56805         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
56806         msg_conv = ChannelUpdate_clone(&msg_conv);
56807         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56808         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
56809         int64_t ret_ref = tag_ptr(ret_copy, true);
56810         return ret_ref;
56811 }
56812
56813 int64_t  CS_LDK_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
56814         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56815         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
56816         int64_t ret_ref = tag_ptr(ret_copy, true);
56817         return ret_ref;
56818 }
56819
56820 int64_t  CS_LDK_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
56821         LDKPublicKey node_id_ref;
56822         CHECK(node_id->arr_len == 33);
56823         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
56824         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
56825         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
56826         int64_t ret_ref = tag_ptr(ret_copy, true);
56827         return ret_ref;
56828 }
56829
56830 jboolean  CS_LDK_NetworkUpdate_eq(int64_t a, int64_t b) {
56831         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
56832         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
56833         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
56834         return ret_conv;
56835 }
56836
56837 int8_tArray  CS_LDK_NetworkUpdate_write(int64_t obj) {
56838         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
56839         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
56840         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
56841         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
56842         CVec_u8Z_free(ret_var);
56843         return ret_arr;
56844 }
56845
56846 int64_t  CS_LDK_NetworkUpdate_read(int8_tArray ser) {
56847         LDKu8slice ser_ref;
56848         ser_ref.datalen = ser->arr_len;
56849         ser_ref.data = ser->elems;
56850         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
56851         *ret_conv = NetworkUpdate_read(ser_ref);
56852         FREE(ser);
56853         return tag_ptr(ret_conv, true);
56854 }
56855
56856 void  CS_LDK_P2PGossipSync_free(int64_t this_obj) {
56857         LDKP2PGossipSync this_obj_conv;
56858         this_obj_conv.inner = untag_ptr(this_obj);
56859         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56861         P2PGossipSync_free(this_obj_conv);
56862 }
56863
56864 int64_t  CS_LDK_P2PGossipSync_new(int64_t network_graph, int64_t utxo_lookup, int64_t logger) {
56865         LDKNetworkGraph network_graph_conv;
56866         network_graph_conv.inner = untag_ptr(network_graph);
56867         network_graph_conv.is_owned = ptr_is_owned(network_graph);
56868         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
56869         network_graph_conv.is_owned = false;
56870         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
56871         CHECK_ACCESS(utxo_lookup_ptr);
56872         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
56873         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
56874         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
56875                 // Manually implement clone for Java trait instances
56876                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
56877                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
56878                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
56879                 }
56880         }
56881         void* logger_ptr = untag_ptr(logger);
56882         CHECK_ACCESS(logger_ptr);
56883         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
56884         if (logger_conv.free == LDKLogger_JCalls_free) {
56885                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
56886                 LDKLogger_JCalls_cloned(&logger_conv);
56887         }
56888         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, utxo_lookup_conv, logger_conv);
56889         int64_t ret_ref = 0;
56890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
56891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
56892         return ret_ref;
56893 }
56894
56895 void  CS_LDK_P2PGossipSync_add_utxo_lookup(int64_t this_arg, int64_t utxo_lookup) {
56896         LDKP2PGossipSync this_arg_conv;
56897         this_arg_conv.inner = untag_ptr(this_arg);
56898         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56900         this_arg_conv.is_owned = false;
56901         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
56902         CHECK_ACCESS(utxo_lookup_ptr);
56903         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
56904         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
56905         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
56906                 // Manually implement clone for Java trait instances
56907                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
56908                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
56909                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
56910                 }
56911         }
56912         P2PGossipSync_add_utxo_lookup(&this_arg_conv, utxo_lookup_conv);
56913 }
56914
56915 void  CS_LDK_NetworkGraph_handle_network_update(int64_t this_arg, int64_t network_update) {
56916         LDKNetworkGraph this_arg_conv;
56917         this_arg_conv.inner = untag_ptr(this_arg);
56918         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56920         this_arg_conv.is_owned = false;
56921         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
56922         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
56923 }
56924
56925 int8_tArray  CS_LDK_NetworkGraph_get_chain_hash(int64_t this_arg) {
56926         LDKNetworkGraph this_arg_conv;
56927         this_arg_conv.inner = untag_ptr(this_arg);
56928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56930         this_arg_conv.is_owned = false;
56931         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
56932         memcpy(ret_arr->elems, NetworkGraph_get_chain_hash(&this_arg_conv).data, 32);
56933         return ret_arr;
56934 }
56935
56936 int64_t  CS_LDK_verify_node_announcement(int64_t msg) {
56937         LDKNodeAnnouncement msg_conv;
56938         msg_conv.inner = untag_ptr(msg);
56939         msg_conv.is_owned = ptr_is_owned(msg);
56940         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
56941         msg_conv.is_owned = false;
56942         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
56943         *ret_conv = verify_node_announcement(&msg_conv);
56944         return tag_ptr(ret_conv, true);
56945 }
56946
56947 int64_t  CS_LDK_verify_channel_announcement(int64_t msg) {
56948         LDKChannelAnnouncement msg_conv;
56949         msg_conv.inner = untag_ptr(msg);
56950         msg_conv.is_owned = ptr_is_owned(msg);
56951         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
56952         msg_conv.is_owned = false;
56953         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
56954         *ret_conv = verify_channel_announcement(&msg_conv);
56955         return tag_ptr(ret_conv, true);
56956 }
56957
56958 int64_t  CS_LDK_P2PGossipSync_as_RoutingMessageHandler(int64_t this_arg) {
56959         LDKP2PGossipSync this_arg_conv;
56960         this_arg_conv.inner = untag_ptr(this_arg);
56961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56963         this_arg_conv.is_owned = false;
56964         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
56965         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
56966         return tag_ptr(ret_ret, true);
56967 }
56968
56969 int64_t  CS_LDK_P2PGossipSync_as_MessageSendEventsProvider(int64_t this_arg) {
56970         LDKP2PGossipSync this_arg_conv;
56971         this_arg_conv.inner = untag_ptr(this_arg);
56972         this_arg_conv.is_owned = ptr_is_owned(this_arg);
56973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
56974         this_arg_conv.is_owned = false;
56975         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
56976         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
56977         return tag_ptr(ret_ret, true);
56978 }
56979
56980 void  CS_LDK_ChannelUpdateInfo_free(int64_t this_obj) {
56981         LDKChannelUpdateInfo this_obj_conv;
56982         this_obj_conv.inner = untag_ptr(this_obj);
56983         this_obj_conv.is_owned = ptr_is_owned(this_obj);
56984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
56985         ChannelUpdateInfo_free(this_obj_conv);
56986 }
56987
56988 int32_t  CS_LDK_ChannelUpdateInfo_get_last_update(int64_t this_ptr) {
56989         LDKChannelUpdateInfo this_ptr_conv;
56990         this_ptr_conv.inner = untag_ptr(this_ptr);
56991         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
56992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
56993         this_ptr_conv.is_owned = false;
56994         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
56995         return ret_conv;
56996 }
56997
56998 void  CS_LDK_ChannelUpdateInfo_set_last_update(int64_t this_ptr, int32_t val) {
56999         LDKChannelUpdateInfo this_ptr_conv;
57000         this_ptr_conv.inner = untag_ptr(this_ptr);
57001         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57003         this_ptr_conv.is_owned = false;
57004         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
57005 }
57006
57007 jboolean  CS_LDK_ChannelUpdateInfo_get_enabled(int64_t this_ptr) {
57008         LDKChannelUpdateInfo this_ptr_conv;
57009         this_ptr_conv.inner = untag_ptr(this_ptr);
57010         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57012         this_ptr_conv.is_owned = false;
57013         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
57014         return ret_conv;
57015 }
57016
57017 void  CS_LDK_ChannelUpdateInfo_set_enabled(int64_t this_ptr, jboolean val) {
57018         LDKChannelUpdateInfo this_ptr_conv;
57019         this_ptr_conv.inner = untag_ptr(this_ptr);
57020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57022         this_ptr_conv.is_owned = false;
57023         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
57024 }
57025
57026 int16_t  CS_LDK_ChannelUpdateInfo_get_cltv_expiry_delta(int64_t this_ptr) {
57027         LDKChannelUpdateInfo this_ptr_conv;
57028         this_ptr_conv.inner = untag_ptr(this_ptr);
57029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57031         this_ptr_conv.is_owned = false;
57032         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
57033         return ret_conv;
57034 }
57035
57036 void  CS_LDK_ChannelUpdateInfo_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
57037         LDKChannelUpdateInfo this_ptr_conv;
57038         this_ptr_conv.inner = untag_ptr(this_ptr);
57039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57041         this_ptr_conv.is_owned = false;
57042         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
57043 }
57044
57045 int64_t  CS_LDK_ChannelUpdateInfo_get_htlc_minimum_msat(int64_t this_ptr) {
57046         LDKChannelUpdateInfo this_ptr_conv;
57047         this_ptr_conv.inner = untag_ptr(this_ptr);
57048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57050         this_ptr_conv.is_owned = false;
57051         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
57052         return ret_conv;
57053 }
57054
57055 void  CS_LDK_ChannelUpdateInfo_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
57056         LDKChannelUpdateInfo this_ptr_conv;
57057         this_ptr_conv.inner = untag_ptr(this_ptr);
57058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57060         this_ptr_conv.is_owned = false;
57061         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
57062 }
57063
57064 int64_t  CS_LDK_ChannelUpdateInfo_get_htlc_maximum_msat(int64_t this_ptr) {
57065         LDKChannelUpdateInfo this_ptr_conv;
57066         this_ptr_conv.inner = untag_ptr(this_ptr);
57067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57069         this_ptr_conv.is_owned = false;
57070         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
57071         return ret_conv;
57072 }
57073
57074 void  CS_LDK_ChannelUpdateInfo_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
57075         LDKChannelUpdateInfo this_ptr_conv;
57076         this_ptr_conv.inner = untag_ptr(this_ptr);
57077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57079         this_ptr_conv.is_owned = false;
57080         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
57081 }
57082
57083 int64_t  CS_LDK_ChannelUpdateInfo_get_fees(int64_t this_ptr) {
57084         LDKChannelUpdateInfo this_ptr_conv;
57085         this_ptr_conv.inner = untag_ptr(this_ptr);
57086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57088         this_ptr_conv.is_owned = false;
57089         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
57090         int64_t ret_ref = 0;
57091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57092         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57093         return ret_ref;
57094 }
57095
57096 void  CS_LDK_ChannelUpdateInfo_set_fees(int64_t this_ptr, int64_t val) {
57097         LDKChannelUpdateInfo this_ptr_conv;
57098         this_ptr_conv.inner = untag_ptr(this_ptr);
57099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57101         this_ptr_conv.is_owned = false;
57102         LDKRoutingFees val_conv;
57103         val_conv.inner = untag_ptr(val);
57104         val_conv.is_owned = ptr_is_owned(val);
57105         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57106         val_conv = RoutingFees_clone(&val_conv);
57107         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
57108 }
57109
57110 int64_t  CS_LDK_ChannelUpdateInfo_get_last_update_message(int64_t this_ptr) {
57111         LDKChannelUpdateInfo this_ptr_conv;
57112         this_ptr_conv.inner = untag_ptr(this_ptr);
57113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57115         this_ptr_conv.is_owned = false;
57116         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
57117         int64_t ret_ref = 0;
57118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57120         return ret_ref;
57121 }
57122
57123 void  CS_LDK_ChannelUpdateInfo_set_last_update_message(int64_t this_ptr, int64_t val) {
57124         LDKChannelUpdateInfo this_ptr_conv;
57125         this_ptr_conv.inner = untag_ptr(this_ptr);
57126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57128         this_ptr_conv.is_owned = false;
57129         LDKChannelUpdate val_conv;
57130         val_conv.inner = untag_ptr(val);
57131         val_conv.is_owned = ptr_is_owned(val);
57132         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57133         val_conv = ChannelUpdate_clone(&val_conv);
57134         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
57135 }
57136
57137 int64_t  CS_LDK_ChannelUpdateInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int64_t fees_arg, int64_t last_update_message_arg) {
57138         LDKRoutingFees fees_arg_conv;
57139         fees_arg_conv.inner = untag_ptr(fees_arg);
57140         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
57141         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
57142         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
57143         LDKChannelUpdate last_update_message_arg_conv;
57144         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
57145         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
57146         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
57147         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
57148         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
57149         int64_t ret_ref = 0;
57150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57151         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57152         return ret_ref;
57153 }
57154
57155 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
57156         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
57157         int64_t ret_ref = 0;
57158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57160         return ret_ref;
57161 }
57162 int64_t  CS_LDK_ChannelUpdateInfo_clone_ptr(int64_t arg) {
57163         LDKChannelUpdateInfo arg_conv;
57164         arg_conv.inner = untag_ptr(arg);
57165         arg_conv.is_owned = ptr_is_owned(arg);
57166         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57167         arg_conv.is_owned = false;
57168         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
57169         return ret_conv;
57170 }
57171
57172 int64_t  CS_LDK_ChannelUpdateInfo_clone(int64_t orig) {
57173         LDKChannelUpdateInfo orig_conv;
57174         orig_conv.inner = untag_ptr(orig);
57175         orig_conv.is_owned = ptr_is_owned(orig);
57176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57177         orig_conv.is_owned = false;
57178         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
57179         int64_t ret_ref = 0;
57180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57182         return ret_ref;
57183 }
57184
57185 jboolean  CS_LDK_ChannelUpdateInfo_eq(int64_t a, int64_t b) {
57186         LDKChannelUpdateInfo a_conv;
57187         a_conv.inner = untag_ptr(a);
57188         a_conv.is_owned = ptr_is_owned(a);
57189         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57190         a_conv.is_owned = false;
57191         LDKChannelUpdateInfo b_conv;
57192         b_conv.inner = untag_ptr(b);
57193         b_conv.is_owned = ptr_is_owned(b);
57194         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57195         b_conv.is_owned = false;
57196         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
57197         return ret_conv;
57198 }
57199
57200 int8_tArray  CS_LDK_ChannelUpdateInfo_write(int64_t obj) {
57201         LDKChannelUpdateInfo obj_conv;
57202         obj_conv.inner = untag_ptr(obj);
57203         obj_conv.is_owned = ptr_is_owned(obj);
57204         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
57205         obj_conv.is_owned = false;
57206         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
57207         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
57208         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
57209         CVec_u8Z_free(ret_var);
57210         return ret_arr;
57211 }
57212
57213 int64_t  CS_LDK_ChannelUpdateInfo_read(int8_tArray ser) {
57214         LDKu8slice ser_ref;
57215         ser_ref.datalen = ser->arr_len;
57216         ser_ref.data = ser->elems;
57217         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
57218         *ret_conv = ChannelUpdateInfo_read(ser_ref);
57219         FREE(ser);
57220         return tag_ptr(ret_conv, true);
57221 }
57222
57223 void  CS_LDK_ChannelInfo_free(int64_t this_obj) {
57224         LDKChannelInfo this_obj_conv;
57225         this_obj_conv.inner = untag_ptr(this_obj);
57226         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57228         ChannelInfo_free(this_obj_conv);
57229 }
57230
57231 int64_t  CS_LDK_ChannelInfo_get_features(int64_t this_ptr) {
57232         LDKChannelInfo this_ptr_conv;
57233         this_ptr_conv.inner = untag_ptr(this_ptr);
57234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57236         this_ptr_conv.is_owned = false;
57237         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
57238         int64_t ret_ref = 0;
57239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57241         return ret_ref;
57242 }
57243
57244 void  CS_LDK_ChannelInfo_set_features(int64_t this_ptr, int64_t val) {
57245         LDKChannelInfo this_ptr_conv;
57246         this_ptr_conv.inner = untag_ptr(this_ptr);
57247         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57249         this_ptr_conv.is_owned = false;
57250         LDKChannelFeatures val_conv;
57251         val_conv.inner = untag_ptr(val);
57252         val_conv.is_owned = ptr_is_owned(val);
57253         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57254         val_conv = ChannelFeatures_clone(&val_conv);
57255         ChannelInfo_set_features(&this_ptr_conv, val_conv);
57256 }
57257
57258 int64_t  CS_LDK_ChannelInfo_get_node_one(int64_t this_ptr) {
57259         LDKChannelInfo this_ptr_conv;
57260         this_ptr_conv.inner = untag_ptr(this_ptr);
57261         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57263         this_ptr_conv.is_owned = false;
57264         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
57265         int64_t ret_ref = 0;
57266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57268         return ret_ref;
57269 }
57270
57271 void  CS_LDK_ChannelInfo_set_node_one(int64_t this_ptr, int64_t val) {
57272         LDKChannelInfo this_ptr_conv;
57273         this_ptr_conv.inner = untag_ptr(this_ptr);
57274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57276         this_ptr_conv.is_owned = false;
57277         LDKNodeId val_conv;
57278         val_conv.inner = untag_ptr(val);
57279         val_conv.is_owned = ptr_is_owned(val);
57280         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57281         val_conv = NodeId_clone(&val_conv);
57282         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
57283 }
57284
57285 int64_t  CS_LDK_ChannelInfo_get_one_to_two(int64_t this_ptr) {
57286         LDKChannelInfo this_ptr_conv;
57287         this_ptr_conv.inner = untag_ptr(this_ptr);
57288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57290         this_ptr_conv.is_owned = false;
57291         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
57292         int64_t ret_ref = 0;
57293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57295         return ret_ref;
57296 }
57297
57298 void  CS_LDK_ChannelInfo_set_one_to_two(int64_t this_ptr, int64_t val) {
57299         LDKChannelInfo this_ptr_conv;
57300         this_ptr_conv.inner = untag_ptr(this_ptr);
57301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57303         this_ptr_conv.is_owned = false;
57304         LDKChannelUpdateInfo val_conv;
57305         val_conv.inner = untag_ptr(val);
57306         val_conv.is_owned = ptr_is_owned(val);
57307         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57308         val_conv = ChannelUpdateInfo_clone(&val_conv);
57309         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
57310 }
57311
57312 int64_t  CS_LDK_ChannelInfo_get_node_two(int64_t this_ptr) {
57313         LDKChannelInfo this_ptr_conv;
57314         this_ptr_conv.inner = untag_ptr(this_ptr);
57315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57317         this_ptr_conv.is_owned = false;
57318         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
57319         int64_t ret_ref = 0;
57320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57322         return ret_ref;
57323 }
57324
57325 void  CS_LDK_ChannelInfo_set_node_two(int64_t this_ptr, int64_t val) {
57326         LDKChannelInfo this_ptr_conv;
57327         this_ptr_conv.inner = untag_ptr(this_ptr);
57328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57330         this_ptr_conv.is_owned = false;
57331         LDKNodeId val_conv;
57332         val_conv.inner = untag_ptr(val);
57333         val_conv.is_owned = ptr_is_owned(val);
57334         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57335         val_conv = NodeId_clone(&val_conv);
57336         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
57337 }
57338
57339 int64_t  CS_LDK_ChannelInfo_get_two_to_one(int64_t this_ptr) {
57340         LDKChannelInfo this_ptr_conv;
57341         this_ptr_conv.inner = untag_ptr(this_ptr);
57342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57344         this_ptr_conv.is_owned = false;
57345         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
57346         int64_t ret_ref = 0;
57347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57349         return ret_ref;
57350 }
57351
57352 void  CS_LDK_ChannelInfo_set_two_to_one(int64_t this_ptr, int64_t val) {
57353         LDKChannelInfo this_ptr_conv;
57354         this_ptr_conv.inner = untag_ptr(this_ptr);
57355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57357         this_ptr_conv.is_owned = false;
57358         LDKChannelUpdateInfo val_conv;
57359         val_conv.inner = untag_ptr(val);
57360         val_conv.is_owned = ptr_is_owned(val);
57361         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57362         val_conv = ChannelUpdateInfo_clone(&val_conv);
57363         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
57364 }
57365
57366 int64_t  CS_LDK_ChannelInfo_get_capacity_sats(int64_t this_ptr) {
57367         LDKChannelInfo this_ptr_conv;
57368         this_ptr_conv.inner = untag_ptr(this_ptr);
57369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57371         this_ptr_conv.is_owned = false;
57372         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
57373         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
57374         int64_t ret_ref = tag_ptr(ret_copy, true);
57375         return ret_ref;
57376 }
57377
57378 void  CS_LDK_ChannelInfo_set_capacity_sats(int64_t this_ptr, int64_t val) {
57379         LDKChannelInfo this_ptr_conv;
57380         this_ptr_conv.inner = untag_ptr(this_ptr);
57381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57383         this_ptr_conv.is_owned = false;
57384         void* val_ptr = untag_ptr(val);
57385         CHECK_ACCESS(val_ptr);
57386         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
57387         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
57388         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
57389 }
57390
57391 int64_t  CS_LDK_ChannelInfo_get_announcement_message(int64_t this_ptr) {
57392         LDKChannelInfo this_ptr_conv;
57393         this_ptr_conv.inner = untag_ptr(this_ptr);
57394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57396         this_ptr_conv.is_owned = false;
57397         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
57398         int64_t ret_ref = 0;
57399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57401         return ret_ref;
57402 }
57403
57404 void  CS_LDK_ChannelInfo_set_announcement_message(int64_t this_ptr, int64_t val) {
57405         LDKChannelInfo this_ptr_conv;
57406         this_ptr_conv.inner = untag_ptr(this_ptr);
57407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57409         this_ptr_conv.is_owned = false;
57410         LDKChannelAnnouncement val_conv;
57411         val_conv.inner = untag_ptr(val);
57412         val_conv.is_owned = ptr_is_owned(val);
57413         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57414         val_conv = ChannelAnnouncement_clone(&val_conv);
57415         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
57416 }
57417
57418 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
57419         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
57420         int64_t ret_ref = 0;
57421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57423         return ret_ref;
57424 }
57425 int64_t  CS_LDK_ChannelInfo_clone_ptr(int64_t arg) {
57426         LDKChannelInfo arg_conv;
57427         arg_conv.inner = untag_ptr(arg);
57428         arg_conv.is_owned = ptr_is_owned(arg);
57429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57430         arg_conv.is_owned = false;
57431         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
57432         return ret_conv;
57433 }
57434
57435 int64_t  CS_LDK_ChannelInfo_clone(int64_t orig) {
57436         LDKChannelInfo orig_conv;
57437         orig_conv.inner = untag_ptr(orig);
57438         orig_conv.is_owned = ptr_is_owned(orig);
57439         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57440         orig_conv.is_owned = false;
57441         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
57442         int64_t ret_ref = 0;
57443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57445         return ret_ref;
57446 }
57447
57448 jboolean  CS_LDK_ChannelInfo_eq(int64_t a, int64_t b) {
57449         LDKChannelInfo a_conv;
57450         a_conv.inner = untag_ptr(a);
57451         a_conv.is_owned = ptr_is_owned(a);
57452         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57453         a_conv.is_owned = false;
57454         LDKChannelInfo b_conv;
57455         b_conv.inner = untag_ptr(b);
57456         b_conv.is_owned = ptr_is_owned(b);
57457         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57458         b_conv.is_owned = false;
57459         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
57460         return ret_conv;
57461 }
57462
57463 int64_t  CS_LDK_ChannelInfo_get_directional_info(int64_t this_arg, int8_t channel_flags) {
57464         LDKChannelInfo this_arg_conv;
57465         this_arg_conv.inner = untag_ptr(this_arg);
57466         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57468         this_arg_conv.is_owned = false;
57469         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
57470         int64_t ret_ref = 0;
57471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57473         return ret_ref;
57474 }
57475
57476 int8_tArray  CS_LDK_ChannelInfo_write(int64_t obj) {
57477         LDKChannelInfo obj_conv;
57478         obj_conv.inner = untag_ptr(obj);
57479         obj_conv.is_owned = ptr_is_owned(obj);
57480         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
57481         obj_conv.is_owned = false;
57482         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
57483         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
57484         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
57485         CVec_u8Z_free(ret_var);
57486         return ret_arr;
57487 }
57488
57489 int64_t  CS_LDK_ChannelInfo_read(int8_tArray ser) {
57490         LDKu8slice ser_ref;
57491         ser_ref.datalen = ser->arr_len;
57492         ser_ref.data = ser->elems;
57493         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
57494         *ret_conv = ChannelInfo_read(ser_ref);
57495         FREE(ser);
57496         return tag_ptr(ret_conv, true);
57497 }
57498
57499 void  CS_LDK_DirectedChannelInfo_free(int64_t this_obj) {
57500         LDKDirectedChannelInfo this_obj_conv;
57501         this_obj_conv.inner = untag_ptr(this_obj);
57502         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57504         DirectedChannelInfo_free(this_obj_conv);
57505 }
57506
57507 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
57508         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
57509         int64_t ret_ref = 0;
57510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57512         return ret_ref;
57513 }
57514 int64_t  CS_LDK_DirectedChannelInfo_clone_ptr(int64_t arg) {
57515         LDKDirectedChannelInfo arg_conv;
57516         arg_conv.inner = untag_ptr(arg);
57517         arg_conv.is_owned = ptr_is_owned(arg);
57518         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57519         arg_conv.is_owned = false;
57520         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
57521         return ret_conv;
57522 }
57523
57524 int64_t  CS_LDK_DirectedChannelInfo_clone(int64_t orig) {
57525         LDKDirectedChannelInfo orig_conv;
57526         orig_conv.inner = untag_ptr(orig);
57527         orig_conv.is_owned = ptr_is_owned(orig);
57528         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57529         orig_conv.is_owned = false;
57530         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
57531         int64_t ret_ref = 0;
57532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57533         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57534         return ret_ref;
57535 }
57536
57537 int64_t  CS_LDK_DirectedChannelInfo_channel(int64_t this_arg) {
57538         LDKDirectedChannelInfo this_arg_conv;
57539         this_arg_conv.inner = untag_ptr(this_arg);
57540         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57542         this_arg_conv.is_owned = false;
57543         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
57544         int64_t ret_ref = 0;
57545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57546         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57547         return ret_ref;
57548 }
57549
57550 int64_t  CS_LDK_DirectedChannelInfo_htlc_maximum_msat(int64_t this_arg) {
57551         LDKDirectedChannelInfo this_arg_conv;
57552         this_arg_conv.inner = untag_ptr(this_arg);
57553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57555         this_arg_conv.is_owned = false;
57556         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
57557         return ret_conv;
57558 }
57559
57560 int64_t  CS_LDK_DirectedChannelInfo_effective_capacity(int64_t this_arg) {
57561         LDKDirectedChannelInfo this_arg_conv;
57562         this_arg_conv.inner = untag_ptr(this_arg);
57563         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57565         this_arg_conv.is_owned = false;
57566         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57567         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
57568         int64_t ret_ref = tag_ptr(ret_copy, true);
57569         return ret_ref;
57570 }
57571
57572 void  CS_LDK_EffectiveCapacity_free(int64_t this_ptr) {
57573         if (!ptr_is_owned(this_ptr)) return;
57574         void* this_ptr_ptr = untag_ptr(this_ptr);
57575         CHECK_ACCESS(this_ptr_ptr);
57576         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
57577         FREE(untag_ptr(this_ptr));
57578         EffectiveCapacity_free(this_ptr_conv);
57579 }
57580
57581 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
57582         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57583         *ret_copy = EffectiveCapacity_clone(arg);
57584         int64_t ret_ref = tag_ptr(ret_copy, true);
57585         return ret_ref;
57586 }
57587 int64_t  CS_LDK_EffectiveCapacity_clone_ptr(int64_t arg) {
57588         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
57589         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
57590         return ret_conv;
57591 }
57592
57593 int64_t  CS_LDK_EffectiveCapacity_clone(int64_t orig) {
57594         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
57595         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57596         *ret_copy = EffectiveCapacity_clone(orig_conv);
57597         int64_t ret_ref = tag_ptr(ret_copy, true);
57598         return ret_ref;
57599 }
57600
57601 int64_t  CS_LDK_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
57602         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57603         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
57604         int64_t ret_ref = tag_ptr(ret_copy, true);
57605         return ret_ref;
57606 }
57607
57608 int64_t  CS_LDK_EffectiveCapacity_advertised_max_htlc(int64_t amount_msat) {
57609         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57610         *ret_copy = EffectiveCapacity_advertised_max_htlc(amount_msat);
57611         int64_t ret_ref = tag_ptr(ret_copy, true);
57612         return ret_ref;
57613 }
57614
57615 int64_t  CS_LDK_EffectiveCapacity_total(int64_t capacity_msat, int64_t htlc_maximum_msat) {
57616         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57617         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
57618         int64_t ret_ref = tag_ptr(ret_copy, true);
57619         return ret_ref;
57620 }
57621
57622 int64_t  CS_LDK_EffectiveCapacity_infinite() {
57623         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57624         *ret_copy = EffectiveCapacity_infinite();
57625         int64_t ret_ref = tag_ptr(ret_copy, true);
57626         return ret_ref;
57627 }
57628
57629 int64_t  CS_LDK_EffectiveCapacity_hint_max_htlc(int64_t amount_msat) {
57630         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57631         *ret_copy = EffectiveCapacity_hint_max_htlc(amount_msat);
57632         int64_t ret_ref = tag_ptr(ret_copy, true);
57633         return ret_ref;
57634 }
57635
57636 int64_t  CS_LDK_EffectiveCapacity_unknown() {
57637         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
57638         *ret_copy = EffectiveCapacity_unknown();
57639         int64_t ret_ref = tag_ptr(ret_copy, true);
57640         return ret_ref;
57641 }
57642
57643 int64_t  CS_LDK_EffectiveCapacity_as_msat(int64_t this_arg) {
57644         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
57645         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
57646         return ret_conv;
57647 }
57648
57649 void  CS_LDK_RoutingFees_free(int64_t this_obj) {
57650         LDKRoutingFees this_obj_conv;
57651         this_obj_conv.inner = untag_ptr(this_obj);
57652         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57654         RoutingFees_free(this_obj_conv);
57655 }
57656
57657 int32_t  CS_LDK_RoutingFees_get_base_msat(int64_t this_ptr) {
57658         LDKRoutingFees this_ptr_conv;
57659         this_ptr_conv.inner = untag_ptr(this_ptr);
57660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57662         this_ptr_conv.is_owned = false;
57663         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
57664         return ret_conv;
57665 }
57666
57667 void  CS_LDK_RoutingFees_set_base_msat(int64_t this_ptr, int32_t val) {
57668         LDKRoutingFees this_ptr_conv;
57669         this_ptr_conv.inner = untag_ptr(this_ptr);
57670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57672         this_ptr_conv.is_owned = false;
57673         RoutingFees_set_base_msat(&this_ptr_conv, val);
57674 }
57675
57676 int32_t  CS_LDK_RoutingFees_get_proportional_millionths(int64_t this_ptr) {
57677         LDKRoutingFees this_ptr_conv;
57678         this_ptr_conv.inner = untag_ptr(this_ptr);
57679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57681         this_ptr_conv.is_owned = false;
57682         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
57683         return ret_conv;
57684 }
57685
57686 void  CS_LDK_RoutingFees_set_proportional_millionths(int64_t this_ptr, int32_t val) {
57687         LDKRoutingFees this_ptr_conv;
57688         this_ptr_conv.inner = untag_ptr(this_ptr);
57689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57691         this_ptr_conv.is_owned = false;
57692         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
57693 }
57694
57695 int64_t  CS_LDK_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
57696         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
57697         int64_t ret_ref = 0;
57698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57699         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57700         return ret_ref;
57701 }
57702
57703 jboolean  CS_LDK_RoutingFees_eq(int64_t a, int64_t b) {
57704         LDKRoutingFees a_conv;
57705         a_conv.inner = untag_ptr(a);
57706         a_conv.is_owned = ptr_is_owned(a);
57707         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57708         a_conv.is_owned = false;
57709         LDKRoutingFees b_conv;
57710         b_conv.inner = untag_ptr(b);
57711         b_conv.is_owned = ptr_is_owned(b);
57712         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57713         b_conv.is_owned = false;
57714         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
57715         return ret_conv;
57716 }
57717
57718 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
57719         LDKRoutingFees ret_var = RoutingFees_clone(arg);
57720         int64_t ret_ref = 0;
57721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57723         return ret_ref;
57724 }
57725 int64_t  CS_LDK_RoutingFees_clone_ptr(int64_t arg) {
57726         LDKRoutingFees arg_conv;
57727         arg_conv.inner = untag_ptr(arg);
57728         arg_conv.is_owned = ptr_is_owned(arg);
57729         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57730         arg_conv.is_owned = false;
57731         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
57732         return ret_conv;
57733 }
57734
57735 int64_t  CS_LDK_RoutingFees_clone(int64_t orig) {
57736         LDKRoutingFees orig_conv;
57737         orig_conv.inner = untag_ptr(orig);
57738         orig_conv.is_owned = ptr_is_owned(orig);
57739         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57740         orig_conv.is_owned = false;
57741         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
57742         int64_t ret_ref = 0;
57743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57745         return ret_ref;
57746 }
57747
57748 int64_t  CS_LDK_RoutingFees_hash(int64_t o) {
57749         LDKRoutingFees o_conv;
57750         o_conv.inner = untag_ptr(o);
57751         o_conv.is_owned = ptr_is_owned(o);
57752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
57753         o_conv.is_owned = false;
57754         int64_t ret_conv = RoutingFees_hash(&o_conv);
57755         return ret_conv;
57756 }
57757
57758 int8_tArray  CS_LDK_RoutingFees_write(int64_t obj) {
57759         LDKRoutingFees obj_conv;
57760         obj_conv.inner = untag_ptr(obj);
57761         obj_conv.is_owned = ptr_is_owned(obj);
57762         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
57763         obj_conv.is_owned = false;
57764         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
57765         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
57766         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
57767         CVec_u8Z_free(ret_var);
57768         return ret_arr;
57769 }
57770
57771 int64_t  CS_LDK_RoutingFees_read(int8_tArray ser) {
57772         LDKu8slice ser_ref;
57773         ser_ref.datalen = ser->arr_len;
57774         ser_ref.data = ser->elems;
57775         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
57776         *ret_conv = RoutingFees_read(ser_ref);
57777         FREE(ser);
57778         return tag_ptr(ret_conv, true);
57779 }
57780
57781 void  CS_LDK_NodeAnnouncementInfo_free(int64_t this_obj) {
57782         LDKNodeAnnouncementInfo this_obj_conv;
57783         this_obj_conv.inner = untag_ptr(this_obj);
57784         this_obj_conv.is_owned = ptr_is_owned(this_obj);
57785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
57786         NodeAnnouncementInfo_free(this_obj_conv);
57787 }
57788
57789 int64_t  CS_LDK_NodeAnnouncementInfo_get_features(int64_t this_ptr) {
57790         LDKNodeAnnouncementInfo this_ptr_conv;
57791         this_ptr_conv.inner = untag_ptr(this_ptr);
57792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57794         this_ptr_conv.is_owned = false;
57795         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
57796         int64_t ret_ref = 0;
57797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57798         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57799         return ret_ref;
57800 }
57801
57802 void  CS_LDK_NodeAnnouncementInfo_set_features(int64_t this_ptr, int64_t val) {
57803         LDKNodeAnnouncementInfo this_ptr_conv;
57804         this_ptr_conv.inner = untag_ptr(this_ptr);
57805         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57807         this_ptr_conv.is_owned = false;
57808         LDKNodeFeatures val_conv;
57809         val_conv.inner = untag_ptr(val);
57810         val_conv.is_owned = ptr_is_owned(val);
57811         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57812         val_conv = NodeFeatures_clone(&val_conv);
57813         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
57814 }
57815
57816 int32_t  CS_LDK_NodeAnnouncementInfo_get_last_update(int64_t this_ptr) {
57817         LDKNodeAnnouncementInfo this_ptr_conv;
57818         this_ptr_conv.inner = untag_ptr(this_ptr);
57819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57821         this_ptr_conv.is_owned = false;
57822         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
57823         return ret_conv;
57824 }
57825
57826 void  CS_LDK_NodeAnnouncementInfo_set_last_update(int64_t this_ptr, int32_t val) {
57827         LDKNodeAnnouncementInfo this_ptr_conv;
57828         this_ptr_conv.inner = untag_ptr(this_ptr);
57829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57831         this_ptr_conv.is_owned = false;
57832         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
57833 }
57834
57835 int8_tArray  CS_LDK_NodeAnnouncementInfo_get_rgb(int64_t this_ptr) {
57836         LDKNodeAnnouncementInfo this_ptr_conv;
57837         this_ptr_conv.inner = untag_ptr(this_ptr);
57838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57840         this_ptr_conv.is_owned = false;
57841         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
57842         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
57843         return ret_arr;
57844 }
57845
57846 void  CS_LDK_NodeAnnouncementInfo_set_rgb(int64_t this_ptr, int8_tArray val) {
57847         LDKNodeAnnouncementInfo this_ptr_conv;
57848         this_ptr_conv.inner = untag_ptr(this_ptr);
57849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57851         this_ptr_conv.is_owned = false;
57852         LDKThreeBytes val_ref;
57853         CHECK(val->arr_len == 3);
57854         memcpy(val_ref.data, val->elems, 3); FREE(val);
57855         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
57856 }
57857
57858 int64_t  CS_LDK_NodeAnnouncementInfo_get_alias(int64_t this_ptr) {
57859         LDKNodeAnnouncementInfo this_ptr_conv;
57860         this_ptr_conv.inner = untag_ptr(this_ptr);
57861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57863         this_ptr_conv.is_owned = false;
57864         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
57865         int64_t ret_ref = 0;
57866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57868         return ret_ref;
57869 }
57870
57871 void  CS_LDK_NodeAnnouncementInfo_set_alias(int64_t this_ptr, int64_t val) {
57872         LDKNodeAnnouncementInfo this_ptr_conv;
57873         this_ptr_conv.inner = untag_ptr(this_ptr);
57874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57876         this_ptr_conv.is_owned = false;
57877         LDKNodeAlias val_conv;
57878         val_conv.inner = untag_ptr(val);
57879         val_conv.is_owned = ptr_is_owned(val);
57880         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57881         val_conv = NodeAlias_clone(&val_conv);
57882         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
57883 }
57884
57885 int64_t  CS_LDK_NodeAnnouncementInfo_get_announcement_message(int64_t this_ptr) {
57886         LDKNodeAnnouncementInfo this_ptr_conv;
57887         this_ptr_conv.inner = untag_ptr(this_ptr);
57888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57890         this_ptr_conv.is_owned = false;
57891         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
57892         int64_t ret_ref = 0;
57893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57895         return ret_ref;
57896 }
57897
57898 void  CS_LDK_NodeAnnouncementInfo_set_announcement_message(int64_t this_ptr, int64_t val) {
57899         LDKNodeAnnouncementInfo this_ptr_conv;
57900         this_ptr_conv.inner = untag_ptr(this_ptr);
57901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
57902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
57903         this_ptr_conv.is_owned = false;
57904         LDKNodeAnnouncement val_conv;
57905         val_conv.inner = untag_ptr(val);
57906         val_conv.is_owned = ptr_is_owned(val);
57907         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
57908         val_conv = NodeAnnouncement_clone(&val_conv);
57909         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
57910 }
57911
57912 int64_t  CS_LDK_NodeAnnouncementInfo_new(int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_t announcement_message_arg) {
57913         LDKNodeFeatures features_arg_conv;
57914         features_arg_conv.inner = untag_ptr(features_arg);
57915         features_arg_conv.is_owned = ptr_is_owned(features_arg);
57916         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
57917         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
57918         LDKThreeBytes rgb_arg_ref;
57919         CHECK(rgb_arg->arr_len == 3);
57920         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
57921         LDKNodeAlias alias_arg_conv;
57922         alias_arg_conv.inner = untag_ptr(alias_arg);
57923         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
57924         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
57925         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
57926         LDKNodeAnnouncement announcement_message_arg_conv;
57927         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
57928         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
57929         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
57930         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
57931         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, announcement_message_arg_conv);
57932         int64_t ret_ref = 0;
57933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57935         return ret_ref;
57936 }
57937
57938 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
57939         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
57940         int64_t ret_ref = 0;
57941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57942         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57943         return ret_ref;
57944 }
57945 int64_t  CS_LDK_NodeAnnouncementInfo_clone_ptr(int64_t arg) {
57946         LDKNodeAnnouncementInfo arg_conv;
57947         arg_conv.inner = untag_ptr(arg);
57948         arg_conv.is_owned = ptr_is_owned(arg);
57949         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
57950         arg_conv.is_owned = false;
57951         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
57952         return ret_conv;
57953 }
57954
57955 int64_t  CS_LDK_NodeAnnouncementInfo_clone(int64_t orig) {
57956         LDKNodeAnnouncementInfo orig_conv;
57957         orig_conv.inner = untag_ptr(orig);
57958         orig_conv.is_owned = ptr_is_owned(orig);
57959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
57960         orig_conv.is_owned = false;
57961         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
57962         int64_t ret_ref = 0;
57963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
57964         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
57965         return ret_ref;
57966 }
57967
57968 jboolean  CS_LDK_NodeAnnouncementInfo_eq(int64_t a, int64_t b) {
57969         LDKNodeAnnouncementInfo a_conv;
57970         a_conv.inner = untag_ptr(a);
57971         a_conv.is_owned = ptr_is_owned(a);
57972         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
57973         a_conv.is_owned = false;
57974         LDKNodeAnnouncementInfo b_conv;
57975         b_conv.inner = untag_ptr(b);
57976         b_conv.is_owned = ptr_is_owned(b);
57977         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
57978         b_conv.is_owned = false;
57979         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
57980         return ret_conv;
57981 }
57982
57983 int64_tArray  CS_LDK_NodeAnnouncementInfo_addresses(int64_t this_arg) {
57984         LDKNodeAnnouncementInfo this_arg_conv;
57985         this_arg_conv.inner = untag_ptr(this_arg);
57986         this_arg_conv.is_owned = ptr_is_owned(this_arg);
57987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
57988         this_arg_conv.is_owned = false;
57989         LDKCVec_SocketAddressZ ret_var = NodeAnnouncementInfo_addresses(&this_arg_conv);
57990         int64_tArray ret_arr = NULL;
57991         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
57992         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
57993         for (size_t p = 0; p < ret_var.datalen; p++) {
57994                 LDKSocketAddress *ret_conv_15_copy = MALLOC(sizeof(LDKSocketAddress), "LDKSocketAddress");
57995                 *ret_conv_15_copy = ret_var.data[p];
57996                 int64_t ret_conv_15_ref = tag_ptr(ret_conv_15_copy, true);
57997                 ret_arr_ptr[p] = ret_conv_15_ref;
57998         }
57999         
58000         FREE(ret_var.data);
58001         return ret_arr;
58002 }
58003
58004 int8_tArray  CS_LDK_NodeAnnouncementInfo_write(int64_t obj) {
58005         LDKNodeAnnouncementInfo obj_conv;
58006         obj_conv.inner = untag_ptr(obj);
58007         obj_conv.is_owned = ptr_is_owned(obj);
58008         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58009         obj_conv.is_owned = false;
58010         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
58011         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58012         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58013         CVec_u8Z_free(ret_var);
58014         return ret_arr;
58015 }
58016
58017 int64_t  CS_LDK_NodeAnnouncementInfo_read(int8_tArray ser) {
58018         LDKu8slice ser_ref;
58019         ser_ref.datalen = ser->arr_len;
58020         ser_ref.data = ser->elems;
58021         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
58022         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
58023         FREE(ser);
58024         return tag_ptr(ret_conv, true);
58025 }
58026
58027 void  CS_LDK_NodeAlias_free(int64_t this_obj) {
58028         LDKNodeAlias this_obj_conv;
58029         this_obj_conv.inner = untag_ptr(this_obj);
58030         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58032         NodeAlias_free(this_obj_conv);
58033 }
58034
58035 int8_tArray  CS_LDK_NodeAlias_get_a(int64_t this_ptr) {
58036         LDKNodeAlias this_ptr_conv;
58037         this_ptr_conv.inner = untag_ptr(this_ptr);
58038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58040         this_ptr_conv.is_owned = false;
58041         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
58042         memcpy(ret_arr->elems, *NodeAlias_get_a(&this_ptr_conv), 32);
58043         return ret_arr;
58044 }
58045
58046 void  CS_LDK_NodeAlias_set_a(int64_t this_ptr, int8_tArray val) {
58047         LDKNodeAlias this_ptr_conv;
58048         this_ptr_conv.inner = untag_ptr(this_ptr);
58049         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58051         this_ptr_conv.is_owned = false;
58052         LDKThirtyTwoBytes val_ref;
58053         CHECK(val->arr_len == 32);
58054         memcpy(val_ref.data, val->elems, 32); FREE(val);
58055         NodeAlias_set_a(&this_ptr_conv, val_ref);
58056 }
58057
58058 int64_t  CS_LDK_NodeAlias_new(int8_tArray a_arg) {
58059         LDKThirtyTwoBytes a_arg_ref;
58060         CHECK(a_arg->arr_len == 32);
58061         memcpy(a_arg_ref.data, a_arg->elems, 32); FREE(a_arg);
58062         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
58063         int64_t ret_ref = 0;
58064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58066         return ret_ref;
58067 }
58068
58069 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
58070         LDKNodeAlias ret_var = NodeAlias_clone(arg);
58071         int64_t ret_ref = 0;
58072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58074         return ret_ref;
58075 }
58076 int64_t  CS_LDK_NodeAlias_clone_ptr(int64_t arg) {
58077         LDKNodeAlias arg_conv;
58078         arg_conv.inner = untag_ptr(arg);
58079         arg_conv.is_owned = ptr_is_owned(arg);
58080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
58081         arg_conv.is_owned = false;
58082         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
58083         return ret_conv;
58084 }
58085
58086 int64_t  CS_LDK_NodeAlias_clone(int64_t orig) {
58087         LDKNodeAlias orig_conv;
58088         orig_conv.inner = untag_ptr(orig);
58089         orig_conv.is_owned = ptr_is_owned(orig);
58090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
58091         orig_conv.is_owned = false;
58092         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
58093         int64_t ret_ref = 0;
58094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58095         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58096         return ret_ref;
58097 }
58098
58099 jboolean  CS_LDK_NodeAlias_eq(int64_t a, int64_t b) {
58100         LDKNodeAlias a_conv;
58101         a_conv.inner = untag_ptr(a);
58102         a_conv.is_owned = ptr_is_owned(a);
58103         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
58104         a_conv.is_owned = false;
58105         LDKNodeAlias b_conv;
58106         b_conv.inner = untag_ptr(b);
58107         b_conv.is_owned = ptr_is_owned(b);
58108         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
58109         b_conv.is_owned = false;
58110         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
58111         return ret_conv;
58112 }
58113
58114 int8_tArray  CS_LDK_NodeAlias_write(int64_t obj) {
58115         LDKNodeAlias obj_conv;
58116         obj_conv.inner = untag_ptr(obj);
58117         obj_conv.is_owned = ptr_is_owned(obj);
58118         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58119         obj_conv.is_owned = false;
58120         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
58121         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58122         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58123         CVec_u8Z_free(ret_var);
58124         return ret_arr;
58125 }
58126
58127 int64_t  CS_LDK_NodeAlias_read(int8_tArray ser) {
58128         LDKu8slice ser_ref;
58129         ser_ref.datalen = ser->arr_len;
58130         ser_ref.data = ser->elems;
58131         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
58132         *ret_conv = NodeAlias_read(ser_ref);
58133         FREE(ser);
58134         return tag_ptr(ret_conv, true);
58135 }
58136
58137 void  CS_LDK_NodeInfo_free(int64_t this_obj) {
58138         LDKNodeInfo this_obj_conv;
58139         this_obj_conv.inner = untag_ptr(this_obj);
58140         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58142         NodeInfo_free(this_obj_conv);
58143 }
58144
58145 int64_tArray  CS_LDK_NodeInfo_get_channels(int64_t this_ptr) {
58146         LDKNodeInfo this_ptr_conv;
58147         this_ptr_conv.inner = untag_ptr(this_ptr);
58148         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58150         this_ptr_conv.is_owned = false;
58151         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
58152         int64_tArray ret_arr = NULL;
58153         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
58154         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
58155         for (size_t g = 0; g < ret_var.datalen; g++) {
58156                 int64_t ret_conv_6_conv = ret_var.data[g];
58157                 ret_arr_ptr[g] = ret_conv_6_conv;
58158         }
58159         
58160         FREE(ret_var.data);
58161         return ret_arr;
58162 }
58163
58164 void  CS_LDK_NodeInfo_set_channels(int64_t this_ptr, int64_tArray val) {
58165         LDKNodeInfo this_ptr_conv;
58166         this_ptr_conv.inner = untag_ptr(this_ptr);
58167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58169         this_ptr_conv.is_owned = false;
58170         LDKCVec_u64Z val_constr;
58171         val_constr.datalen = val->arr_len;
58172         if (val_constr.datalen > 0)
58173                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
58174         else
58175                 val_constr.data = NULL;
58176         int64_t* val_vals = val->elems;
58177         for (size_t g = 0; g < val_constr.datalen; g++) {
58178                 int64_t val_conv_6 = val_vals[g];
58179                 val_constr.data[g] = val_conv_6;
58180         }
58181         FREE(val);
58182         NodeInfo_set_channels(&this_ptr_conv, val_constr);
58183 }
58184
58185 int64_t  CS_LDK_NodeInfo_get_announcement_info(int64_t this_ptr) {
58186         LDKNodeInfo this_ptr_conv;
58187         this_ptr_conv.inner = untag_ptr(this_ptr);
58188         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58190         this_ptr_conv.is_owned = false;
58191         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
58192         int64_t ret_ref = 0;
58193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58195         return ret_ref;
58196 }
58197
58198 void  CS_LDK_NodeInfo_set_announcement_info(int64_t this_ptr, int64_t val) {
58199         LDKNodeInfo this_ptr_conv;
58200         this_ptr_conv.inner = untag_ptr(this_ptr);
58201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58203         this_ptr_conv.is_owned = false;
58204         LDKNodeAnnouncementInfo val_conv;
58205         val_conv.inner = untag_ptr(val);
58206         val_conv.is_owned = ptr_is_owned(val);
58207         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
58208         val_conv = NodeAnnouncementInfo_clone(&val_conv);
58209         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
58210 }
58211
58212 int64_t  CS_LDK_NodeInfo_new(int64_tArray channels_arg, int64_t announcement_info_arg) {
58213         LDKCVec_u64Z channels_arg_constr;
58214         channels_arg_constr.datalen = channels_arg->arr_len;
58215         if (channels_arg_constr.datalen > 0)
58216                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
58217         else
58218                 channels_arg_constr.data = NULL;
58219         int64_t* channels_arg_vals = channels_arg->elems;
58220         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
58221                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
58222                 channels_arg_constr.data[g] = channels_arg_conv_6;
58223         }
58224         FREE(channels_arg);
58225         LDKNodeAnnouncementInfo announcement_info_arg_conv;
58226         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
58227         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
58228         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
58229         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
58230         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, announcement_info_arg_conv);
58231         int64_t ret_ref = 0;
58232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58233         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58234         return ret_ref;
58235 }
58236
58237 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
58238         LDKNodeInfo ret_var = NodeInfo_clone(arg);
58239         int64_t ret_ref = 0;
58240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58241         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58242         return ret_ref;
58243 }
58244 int64_t  CS_LDK_NodeInfo_clone_ptr(int64_t arg) {
58245         LDKNodeInfo arg_conv;
58246         arg_conv.inner = untag_ptr(arg);
58247         arg_conv.is_owned = ptr_is_owned(arg);
58248         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
58249         arg_conv.is_owned = false;
58250         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
58251         return ret_conv;
58252 }
58253
58254 int64_t  CS_LDK_NodeInfo_clone(int64_t orig) {
58255         LDKNodeInfo orig_conv;
58256         orig_conv.inner = untag_ptr(orig);
58257         orig_conv.is_owned = ptr_is_owned(orig);
58258         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
58259         orig_conv.is_owned = false;
58260         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
58261         int64_t ret_ref = 0;
58262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58264         return ret_ref;
58265 }
58266
58267 jboolean  CS_LDK_NodeInfo_eq(int64_t a, int64_t b) {
58268         LDKNodeInfo a_conv;
58269         a_conv.inner = untag_ptr(a);
58270         a_conv.is_owned = ptr_is_owned(a);
58271         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
58272         a_conv.is_owned = false;
58273         LDKNodeInfo b_conv;
58274         b_conv.inner = untag_ptr(b);
58275         b_conv.is_owned = ptr_is_owned(b);
58276         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
58277         b_conv.is_owned = false;
58278         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
58279         return ret_conv;
58280 }
58281
58282 int8_tArray  CS_LDK_NodeInfo_write(int64_t obj) {
58283         LDKNodeInfo obj_conv;
58284         obj_conv.inner = untag_ptr(obj);
58285         obj_conv.is_owned = ptr_is_owned(obj);
58286         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58287         obj_conv.is_owned = false;
58288         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
58289         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58290         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58291         CVec_u8Z_free(ret_var);
58292         return ret_arr;
58293 }
58294
58295 int64_t  CS_LDK_NodeInfo_read(int8_tArray ser) {
58296         LDKu8slice ser_ref;
58297         ser_ref.datalen = ser->arr_len;
58298         ser_ref.data = ser->elems;
58299         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
58300         *ret_conv = NodeInfo_read(ser_ref);
58301         FREE(ser);
58302         return tag_ptr(ret_conv, true);
58303 }
58304
58305 int8_tArray  CS_LDK_NetworkGraph_write(int64_t obj) {
58306         LDKNetworkGraph obj_conv;
58307         obj_conv.inner = untag_ptr(obj);
58308         obj_conv.is_owned = ptr_is_owned(obj);
58309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58310         obj_conv.is_owned = false;
58311         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
58312         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58313         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58314         CVec_u8Z_free(ret_var);
58315         return ret_arr;
58316 }
58317
58318 int64_t  CS_LDK_NetworkGraph_read(int8_tArray ser, int64_t arg) {
58319         LDKu8slice ser_ref;
58320         ser_ref.datalen = ser->arr_len;
58321         ser_ref.data = ser->elems;
58322         void* arg_ptr = untag_ptr(arg);
58323         CHECK_ACCESS(arg_ptr);
58324         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
58325         if (arg_conv.free == LDKLogger_JCalls_free) {
58326                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58327                 LDKLogger_JCalls_cloned(&arg_conv);
58328         }
58329         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
58330         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
58331         FREE(ser);
58332         return tag_ptr(ret_conv, true);
58333 }
58334
58335 int64_t  CS_LDK_NetworkGraph_new(int32_t network, int64_t logger) {
58336         LDKNetwork network_conv = LDKNetwork_from_cs(network);
58337         void* logger_ptr = untag_ptr(logger);
58338         CHECK_ACCESS(logger_ptr);
58339         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
58340         if (logger_conv.free == LDKLogger_JCalls_free) {
58341                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58342                 LDKLogger_JCalls_cloned(&logger_conv);
58343         }
58344         LDKNetworkGraph ret_var = NetworkGraph_new(network_conv, logger_conv);
58345         int64_t ret_ref = 0;
58346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58348         return ret_ref;
58349 }
58350
58351 int64_t  CS_LDK_NetworkGraph_read_only(int64_t this_arg) {
58352         LDKNetworkGraph this_arg_conv;
58353         this_arg_conv.inner = untag_ptr(this_arg);
58354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58356         this_arg_conv.is_owned = false;
58357         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
58358         int64_t ret_ref = 0;
58359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58360         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58361         return ret_ref;
58362 }
58363
58364 int64_t  CS_LDK_NetworkGraph_get_last_rapid_gossip_sync_timestamp(int64_t this_arg) {
58365         LDKNetworkGraph this_arg_conv;
58366         this_arg_conv.inner = untag_ptr(this_arg);
58367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58369         this_arg_conv.is_owned = false;
58370         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
58371         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
58372         int64_t ret_ref = tag_ptr(ret_copy, true);
58373         return ret_ref;
58374 }
58375
58376 void  CS_LDK_NetworkGraph_set_last_rapid_gossip_sync_timestamp(int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
58377         LDKNetworkGraph this_arg_conv;
58378         this_arg_conv.inner = untag_ptr(this_arg);
58379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58381         this_arg_conv.is_owned = false;
58382         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
58383 }
58384
58385 int64_t  CS_LDK_NetworkGraph_update_node_from_announcement(int64_t this_arg, int64_t msg) {
58386         LDKNetworkGraph this_arg_conv;
58387         this_arg_conv.inner = untag_ptr(this_arg);
58388         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58390         this_arg_conv.is_owned = false;
58391         LDKNodeAnnouncement msg_conv;
58392         msg_conv.inner = untag_ptr(msg);
58393         msg_conv.is_owned = ptr_is_owned(msg);
58394         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58395         msg_conv.is_owned = false;
58396         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58397         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
58398         return tag_ptr(ret_conv, true);
58399 }
58400
58401 int64_t  CS_LDK_NetworkGraph_update_node_from_unsigned_announcement(int64_t this_arg, int64_t msg) {
58402         LDKNetworkGraph this_arg_conv;
58403         this_arg_conv.inner = untag_ptr(this_arg);
58404         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58406         this_arg_conv.is_owned = false;
58407         LDKUnsignedNodeAnnouncement msg_conv;
58408         msg_conv.inner = untag_ptr(msg);
58409         msg_conv.is_owned = ptr_is_owned(msg);
58410         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58411         msg_conv.is_owned = false;
58412         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58413         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
58414         return tag_ptr(ret_conv, true);
58415 }
58416
58417 int64_t  CS_LDK_NetworkGraph_update_channel_from_announcement(int64_t this_arg, int64_t msg, int64_t utxo_lookup) {
58418         LDKNetworkGraph this_arg_conv;
58419         this_arg_conv.inner = untag_ptr(this_arg);
58420         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58422         this_arg_conv.is_owned = false;
58423         LDKChannelAnnouncement msg_conv;
58424         msg_conv.inner = untag_ptr(msg);
58425         msg_conv.is_owned = ptr_is_owned(msg);
58426         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58427         msg_conv.is_owned = false;
58428         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
58429         CHECK_ACCESS(utxo_lookup_ptr);
58430         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
58431         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
58432         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
58433                 // Manually implement clone for Java trait instances
58434                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
58435                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58436                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
58437                 }
58438         }
58439         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58440         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
58441         return tag_ptr(ret_conv, true);
58442 }
58443
58444 int64_t  CS_LDK_NetworkGraph_update_channel_from_announcement_no_lookup(int64_t this_arg, int64_t msg) {
58445         LDKNetworkGraph this_arg_conv;
58446         this_arg_conv.inner = untag_ptr(this_arg);
58447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58449         this_arg_conv.is_owned = false;
58450         LDKChannelAnnouncement msg_conv;
58451         msg_conv.inner = untag_ptr(msg);
58452         msg_conv.is_owned = ptr_is_owned(msg);
58453         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58454         msg_conv.is_owned = false;
58455         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58456         *ret_conv = NetworkGraph_update_channel_from_announcement_no_lookup(&this_arg_conv, &msg_conv);
58457         return tag_ptr(ret_conv, true);
58458 }
58459
58460 int64_t  CS_LDK_NetworkGraph_update_channel_from_unsigned_announcement(int64_t this_arg, int64_t msg, int64_t utxo_lookup) {
58461         LDKNetworkGraph this_arg_conv;
58462         this_arg_conv.inner = untag_ptr(this_arg);
58463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58465         this_arg_conv.is_owned = false;
58466         LDKUnsignedChannelAnnouncement msg_conv;
58467         msg_conv.inner = untag_ptr(msg);
58468         msg_conv.is_owned = ptr_is_owned(msg);
58469         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58470         msg_conv.is_owned = false;
58471         void* utxo_lookup_ptr = untag_ptr(utxo_lookup);
58472         CHECK_ACCESS(utxo_lookup_ptr);
58473         LDKCOption_UtxoLookupZ utxo_lookup_conv = *(LDKCOption_UtxoLookupZ*)(utxo_lookup_ptr);
58474         // WARNING: we may need a move here but no clone is available for LDKCOption_UtxoLookupZ
58475         if (utxo_lookup_conv.tag == LDKCOption_UtxoLookupZ_Some) {
58476                 // Manually implement clone for Java trait instances
58477                 if (utxo_lookup_conv.some.free == LDKUtxoLookup_JCalls_free) {
58478                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58479                         LDKUtxoLookup_JCalls_cloned(&utxo_lookup_conv.some);
58480                 }
58481         }
58482         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58483         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, utxo_lookup_conv);
58484         return tag_ptr(ret_conv, true);
58485 }
58486
58487 int64_t  CS_LDK_NetworkGraph_add_channel_from_partial_announcement(int64_t this_arg, int64_t short_channel_id, int64_t timestamp, int64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
58488         LDKNetworkGraph this_arg_conv;
58489         this_arg_conv.inner = untag_ptr(this_arg);
58490         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58492         this_arg_conv.is_owned = false;
58493         LDKChannelFeatures features_conv;
58494         features_conv.inner = untag_ptr(features);
58495         features_conv.is_owned = ptr_is_owned(features);
58496         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
58497         features_conv = ChannelFeatures_clone(&features_conv);
58498         LDKPublicKey node_id_1_ref;
58499         CHECK(node_id_1->arr_len == 33);
58500         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
58501         LDKPublicKey node_id_2_ref;
58502         CHECK(node_id_2->arr_len == 33);
58503         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
58504         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58505         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
58506         return tag_ptr(ret_conv, true);
58507 }
58508
58509 void  CS_LDK_NetworkGraph_channel_failed_permanent(int64_t this_arg, int64_t short_channel_id) {
58510         LDKNetworkGraph this_arg_conv;
58511         this_arg_conv.inner = untag_ptr(this_arg);
58512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58514         this_arg_conv.is_owned = false;
58515         NetworkGraph_channel_failed_permanent(&this_arg_conv, short_channel_id);
58516 }
58517
58518 void  CS_LDK_NetworkGraph_node_failed_permanent(int64_t this_arg, int8_tArray node_id) {
58519         LDKNetworkGraph this_arg_conv;
58520         this_arg_conv.inner = untag_ptr(this_arg);
58521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58523         this_arg_conv.is_owned = false;
58524         LDKPublicKey node_id_ref;
58525         CHECK(node_id->arr_len == 33);
58526         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
58527         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
58528 }
58529
58530 void  CS_LDK_NetworkGraph_remove_stale_channels_and_tracking(int64_t this_arg) {
58531         LDKNetworkGraph this_arg_conv;
58532         this_arg_conv.inner = untag_ptr(this_arg);
58533         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58535         this_arg_conv.is_owned = false;
58536         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
58537 }
58538
58539 void  CS_LDK_NetworkGraph_remove_stale_channels_and_tracking_with_time(int64_t this_arg, int64_t current_time_unix) {
58540         LDKNetworkGraph this_arg_conv;
58541         this_arg_conv.inner = untag_ptr(this_arg);
58542         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58544         this_arg_conv.is_owned = false;
58545         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
58546 }
58547
58548 int64_t  CS_LDK_NetworkGraph_update_channel(int64_t this_arg, int64_t msg) {
58549         LDKNetworkGraph this_arg_conv;
58550         this_arg_conv.inner = untag_ptr(this_arg);
58551         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58553         this_arg_conv.is_owned = false;
58554         LDKChannelUpdate msg_conv;
58555         msg_conv.inner = untag_ptr(msg);
58556         msg_conv.is_owned = ptr_is_owned(msg);
58557         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58558         msg_conv.is_owned = false;
58559         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58560         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
58561         return tag_ptr(ret_conv, true);
58562 }
58563
58564 int64_t  CS_LDK_NetworkGraph_update_channel_unsigned(int64_t this_arg, int64_t msg) {
58565         LDKNetworkGraph this_arg_conv;
58566         this_arg_conv.inner = untag_ptr(this_arg);
58567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58569         this_arg_conv.is_owned = false;
58570         LDKUnsignedChannelUpdate msg_conv;
58571         msg_conv.inner = untag_ptr(msg);
58572         msg_conv.is_owned = ptr_is_owned(msg);
58573         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58574         msg_conv.is_owned = false;
58575         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58576         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
58577         return tag_ptr(ret_conv, true);
58578 }
58579
58580 int64_t  CS_LDK_NetworkGraph_verify_channel_update(int64_t this_arg, int64_t msg) {
58581         LDKNetworkGraph this_arg_conv;
58582         this_arg_conv.inner = untag_ptr(this_arg);
58583         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58585         this_arg_conv.is_owned = false;
58586         LDKChannelUpdate msg_conv;
58587         msg_conv.inner = untag_ptr(msg);
58588         msg_conv.is_owned = ptr_is_owned(msg);
58589         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
58590         msg_conv.is_owned = false;
58591         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
58592         *ret_conv = NetworkGraph_verify_channel_update(&this_arg_conv, &msg_conv);
58593         return tag_ptr(ret_conv, true);
58594 }
58595
58596 int64_t  CS_LDK_ReadOnlyNetworkGraph_channel(int64_t this_arg, int64_t short_channel_id) {
58597         LDKReadOnlyNetworkGraph this_arg_conv;
58598         this_arg_conv.inner = untag_ptr(this_arg);
58599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58601         this_arg_conv.is_owned = false;
58602         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
58603         int64_t ret_ref = 0;
58604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58606         return ret_ref;
58607 }
58608
58609 int64_tArray  CS_LDK_ReadOnlyNetworkGraph_list_channels(int64_t this_arg) {
58610         LDKReadOnlyNetworkGraph this_arg_conv;
58611         this_arg_conv.inner = untag_ptr(this_arg);
58612         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58614         this_arg_conv.is_owned = false;
58615         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
58616         int64_tArray ret_arr = NULL;
58617         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
58618         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
58619         for (size_t g = 0; g < ret_var.datalen; g++) {
58620                 int64_t ret_conv_6_conv = ret_var.data[g];
58621                 ret_arr_ptr[g] = ret_conv_6_conv;
58622         }
58623         
58624         FREE(ret_var.data);
58625         return ret_arr;
58626 }
58627
58628 int64_t  CS_LDK_ReadOnlyNetworkGraph_node(int64_t this_arg, int64_t node_id) {
58629         LDKReadOnlyNetworkGraph this_arg_conv;
58630         this_arg_conv.inner = untag_ptr(this_arg);
58631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58633         this_arg_conv.is_owned = false;
58634         LDKNodeId node_id_conv;
58635         node_id_conv.inner = untag_ptr(node_id);
58636         node_id_conv.is_owned = ptr_is_owned(node_id);
58637         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
58638         node_id_conv.is_owned = false;
58639         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
58640         int64_t ret_ref = 0;
58641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58642         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58643         return ret_ref;
58644 }
58645
58646 int64_tArray  CS_LDK_ReadOnlyNetworkGraph_list_nodes(int64_t this_arg) {
58647         LDKReadOnlyNetworkGraph this_arg_conv;
58648         this_arg_conv.inner = untag_ptr(this_arg);
58649         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58651         this_arg_conv.is_owned = false;
58652         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
58653         int64_tArray ret_arr = NULL;
58654         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
58655         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
58656         for (size_t i = 0; i < ret_var.datalen; i++) {
58657                 LDKNodeId ret_conv_8_var = ret_var.data[i];
58658                 int64_t ret_conv_8_ref = 0;
58659                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
58660                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
58661                 ret_arr_ptr[i] = ret_conv_8_ref;
58662         }
58663         
58664         FREE(ret_var.data);
58665         return ret_arr;
58666 }
58667
58668 int64_t  CS_LDK_ReadOnlyNetworkGraph_get_addresses(int64_t this_arg, int8_tArray pubkey) {
58669         LDKReadOnlyNetworkGraph this_arg_conv;
58670         this_arg_conv.inner = untag_ptr(this_arg);
58671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58673         this_arg_conv.is_owned = false;
58674         LDKPublicKey pubkey_ref;
58675         CHECK(pubkey->arr_len == 33);
58676         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
58677         LDKCOption_CVec_SocketAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_SocketAddressZZ), "LDKCOption_CVec_SocketAddressZZ");
58678         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
58679         int64_t ret_ref = tag_ptr(ret_copy, true);
58680         return ret_ref;
58681 }
58682
58683 void  CS_LDK_DefaultRouter_free(int64_t this_obj) {
58684         LDKDefaultRouter this_obj_conv;
58685         this_obj_conv.inner = untag_ptr(this_obj);
58686         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58688         DefaultRouter_free(this_obj_conv);
58689 }
58690
58691 int64_t  CS_LDK_DefaultRouter_new(int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes, int64_t scorer, int64_t score_params) {
58692         LDKNetworkGraph network_graph_conv;
58693         network_graph_conv.inner = untag_ptr(network_graph);
58694         network_graph_conv.is_owned = ptr_is_owned(network_graph);
58695         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
58696         network_graph_conv.is_owned = false;
58697         void* logger_ptr = untag_ptr(logger);
58698         CHECK_ACCESS(logger_ptr);
58699         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
58700         if (logger_conv.free == LDKLogger_JCalls_free) {
58701                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58702                 LDKLogger_JCalls_cloned(&logger_conv);
58703         }
58704         LDKThirtyTwoBytes random_seed_bytes_ref;
58705         CHECK(random_seed_bytes->arr_len == 32);
58706         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
58707         void* scorer_ptr = untag_ptr(scorer);
58708         CHECK_ACCESS(scorer_ptr);
58709         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
58710         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
58711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58712                 LDKLockableScore_JCalls_cloned(&scorer_conv);
58713         }
58714         LDKProbabilisticScoringFeeParameters score_params_conv;
58715         score_params_conv.inner = untag_ptr(score_params);
58716         score_params_conv.is_owned = ptr_is_owned(score_params);
58717         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_conv);
58718         score_params_conv = ProbabilisticScoringFeeParameters_clone(&score_params_conv);
58719         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv, score_params_conv);
58720         int64_t ret_ref = 0;
58721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58722         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58723         return ret_ref;
58724 }
58725
58726 int64_t  CS_LDK_DefaultRouter_as_Router(int64_t this_arg) {
58727         LDKDefaultRouter this_arg_conv;
58728         this_arg_conv.inner = untag_ptr(this_arg);
58729         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58731         this_arg_conv.is_owned = false;
58732         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
58733         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
58734         return tag_ptr(ret_ret, true);
58735 }
58736
58737 void  CS_LDK_Router_free(int64_t this_ptr) {
58738         if (!ptr_is_owned(this_ptr)) return;
58739         void* this_ptr_ptr = untag_ptr(this_ptr);
58740         CHECK_ACCESS(this_ptr_ptr);
58741         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
58742         FREE(untag_ptr(this_ptr));
58743         Router_free(this_ptr_conv);
58744 }
58745
58746 void  CS_LDK_ScorerAccountingForInFlightHtlcs_free(int64_t this_obj) {
58747         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
58748         this_obj_conv.inner = untag_ptr(this_obj);
58749         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58751         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
58752 }
58753
58754 int64_t  CS_LDK_ScorerAccountingForInFlightHtlcs_new(int64_t scorer, int64_t inflight_htlcs) {
58755         void* scorer_ptr = untag_ptr(scorer);
58756         CHECK_ACCESS(scorer_ptr);
58757         LDKScoreLookUp scorer_conv = *(LDKScoreLookUp*)(scorer_ptr);
58758         if (scorer_conv.free == LDKScoreLookUp_JCalls_free) {
58759                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
58760                 LDKScoreLookUp_JCalls_cloned(&scorer_conv);
58761         }
58762         LDKInFlightHtlcs inflight_htlcs_conv;
58763         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
58764         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
58765         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
58766         inflight_htlcs_conv.is_owned = false;
58767         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, &inflight_htlcs_conv);
58768         int64_t ret_ref = 0;
58769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58770         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58771         return ret_ref;
58772 }
58773
58774 int64_t  CS_LDK_ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(int64_t this_arg) {
58775         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
58776         this_arg_conv.inner = untag_ptr(this_arg);
58777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58779         this_arg_conv.is_owned = false;
58780         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
58781         *ret_ret = ScorerAccountingForInFlightHtlcs_as_ScoreLookUp(&this_arg_conv);
58782         return tag_ptr(ret_ret, true);
58783 }
58784
58785 void  CS_LDK_InFlightHtlcs_free(int64_t this_obj) {
58786         LDKInFlightHtlcs this_obj_conv;
58787         this_obj_conv.inner = untag_ptr(this_obj);
58788         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58790         InFlightHtlcs_free(this_obj_conv);
58791 }
58792
58793 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
58794         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
58795         int64_t ret_ref = 0;
58796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58797         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58798         return ret_ref;
58799 }
58800 int64_t  CS_LDK_InFlightHtlcs_clone_ptr(int64_t arg) {
58801         LDKInFlightHtlcs arg_conv;
58802         arg_conv.inner = untag_ptr(arg);
58803         arg_conv.is_owned = ptr_is_owned(arg);
58804         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
58805         arg_conv.is_owned = false;
58806         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
58807         return ret_conv;
58808 }
58809
58810 int64_t  CS_LDK_InFlightHtlcs_clone(int64_t orig) {
58811         LDKInFlightHtlcs orig_conv;
58812         orig_conv.inner = untag_ptr(orig);
58813         orig_conv.is_owned = ptr_is_owned(orig);
58814         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
58815         orig_conv.is_owned = false;
58816         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
58817         int64_t ret_ref = 0;
58818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58819         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58820         return ret_ref;
58821 }
58822
58823 int64_t  CS_LDK_InFlightHtlcs_new() {
58824         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
58825         int64_t ret_ref = 0;
58826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58827         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58828         return ret_ref;
58829 }
58830
58831 void  CS_LDK_InFlightHtlcs_process_path(int64_t this_arg, int64_t path, int8_tArray payer_node_id) {
58832         LDKInFlightHtlcs this_arg_conv;
58833         this_arg_conv.inner = untag_ptr(this_arg);
58834         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58836         this_arg_conv.is_owned = false;
58837         LDKPath path_conv;
58838         path_conv.inner = untag_ptr(path);
58839         path_conv.is_owned = ptr_is_owned(path);
58840         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
58841         path_conv.is_owned = false;
58842         LDKPublicKey payer_node_id_ref;
58843         CHECK(payer_node_id->arr_len == 33);
58844         memcpy(payer_node_id_ref.compressed_form, payer_node_id->elems, 33); FREE(payer_node_id);
58845         InFlightHtlcs_process_path(&this_arg_conv, &path_conv, payer_node_id_ref);
58846 }
58847
58848 void  CS_LDK_InFlightHtlcs_add_inflight_htlc(int64_t this_arg, int64_t source, int64_t target, int64_t channel_scid, int64_t used_msat) {
58849         LDKInFlightHtlcs this_arg_conv;
58850         this_arg_conv.inner = untag_ptr(this_arg);
58851         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58853         this_arg_conv.is_owned = false;
58854         LDKNodeId source_conv;
58855         source_conv.inner = untag_ptr(source);
58856         source_conv.is_owned = ptr_is_owned(source);
58857         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
58858         source_conv.is_owned = false;
58859         LDKNodeId target_conv;
58860         target_conv.inner = untag_ptr(target);
58861         target_conv.is_owned = ptr_is_owned(target);
58862         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
58863         target_conv.is_owned = false;
58864         InFlightHtlcs_add_inflight_htlc(&this_arg_conv, &source_conv, &target_conv, channel_scid, used_msat);
58865 }
58866
58867 int64_t  CS_LDK_InFlightHtlcs_used_liquidity_msat(int64_t this_arg, int64_t source, int64_t target, int64_t channel_scid) {
58868         LDKInFlightHtlcs this_arg_conv;
58869         this_arg_conv.inner = untag_ptr(this_arg);
58870         this_arg_conv.is_owned = ptr_is_owned(this_arg);
58871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
58872         this_arg_conv.is_owned = false;
58873         LDKNodeId source_conv;
58874         source_conv.inner = untag_ptr(source);
58875         source_conv.is_owned = ptr_is_owned(source);
58876         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
58877         source_conv.is_owned = false;
58878         LDKNodeId target_conv;
58879         target_conv.inner = untag_ptr(target);
58880         target_conv.is_owned = ptr_is_owned(target);
58881         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
58882         target_conv.is_owned = false;
58883         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
58884         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
58885         int64_t ret_ref = tag_ptr(ret_copy, true);
58886         return ret_ref;
58887 }
58888
58889 int8_tArray  CS_LDK_InFlightHtlcs_write(int64_t obj) {
58890         LDKInFlightHtlcs obj_conv;
58891         obj_conv.inner = untag_ptr(obj);
58892         obj_conv.is_owned = ptr_is_owned(obj);
58893         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
58894         obj_conv.is_owned = false;
58895         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
58896         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
58897         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
58898         CVec_u8Z_free(ret_var);
58899         return ret_arr;
58900 }
58901
58902 int64_t  CS_LDK_InFlightHtlcs_read(int8_tArray ser) {
58903         LDKu8slice ser_ref;
58904         ser_ref.datalen = ser->arr_len;
58905         ser_ref.data = ser->elems;
58906         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
58907         *ret_conv = InFlightHtlcs_read(ser_ref);
58908         FREE(ser);
58909         return tag_ptr(ret_conv, true);
58910 }
58911
58912 void  CS_LDK_RouteHop_free(int64_t this_obj) {
58913         LDKRouteHop this_obj_conv;
58914         this_obj_conv.inner = untag_ptr(this_obj);
58915         this_obj_conv.is_owned = ptr_is_owned(this_obj);
58916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
58917         RouteHop_free(this_obj_conv);
58918 }
58919
58920 int8_tArray  CS_LDK_RouteHop_get_pubkey(int64_t this_ptr) {
58921         LDKRouteHop this_ptr_conv;
58922         this_ptr_conv.inner = untag_ptr(this_ptr);
58923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58925         this_ptr_conv.is_owned = false;
58926         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
58927         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
58928         return ret_arr;
58929 }
58930
58931 void  CS_LDK_RouteHop_set_pubkey(int64_t this_ptr, int8_tArray val) {
58932         LDKRouteHop this_ptr_conv;
58933         this_ptr_conv.inner = untag_ptr(this_ptr);
58934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58936         this_ptr_conv.is_owned = false;
58937         LDKPublicKey val_ref;
58938         CHECK(val->arr_len == 33);
58939         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
58940         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
58941 }
58942
58943 int64_t  CS_LDK_RouteHop_get_node_features(int64_t this_ptr) {
58944         LDKRouteHop this_ptr_conv;
58945         this_ptr_conv.inner = untag_ptr(this_ptr);
58946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58948         this_ptr_conv.is_owned = false;
58949         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
58950         int64_t ret_ref = 0;
58951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58953         return ret_ref;
58954 }
58955
58956 void  CS_LDK_RouteHop_set_node_features(int64_t this_ptr, int64_t val) {
58957         LDKRouteHop this_ptr_conv;
58958         this_ptr_conv.inner = untag_ptr(this_ptr);
58959         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58961         this_ptr_conv.is_owned = false;
58962         LDKNodeFeatures val_conv;
58963         val_conv.inner = untag_ptr(val);
58964         val_conv.is_owned = ptr_is_owned(val);
58965         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
58966         val_conv = NodeFeatures_clone(&val_conv);
58967         RouteHop_set_node_features(&this_ptr_conv, val_conv);
58968 }
58969
58970 int64_t  CS_LDK_RouteHop_get_short_channel_id(int64_t this_ptr) {
58971         LDKRouteHop this_ptr_conv;
58972         this_ptr_conv.inner = untag_ptr(this_ptr);
58973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58975         this_ptr_conv.is_owned = false;
58976         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
58977         return ret_conv;
58978 }
58979
58980 void  CS_LDK_RouteHop_set_short_channel_id(int64_t this_ptr, int64_t val) {
58981         LDKRouteHop this_ptr_conv;
58982         this_ptr_conv.inner = untag_ptr(this_ptr);
58983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58985         this_ptr_conv.is_owned = false;
58986         RouteHop_set_short_channel_id(&this_ptr_conv, val);
58987 }
58988
58989 int64_t  CS_LDK_RouteHop_get_channel_features(int64_t this_ptr) {
58990         LDKRouteHop this_ptr_conv;
58991         this_ptr_conv.inner = untag_ptr(this_ptr);
58992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
58993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
58994         this_ptr_conv.is_owned = false;
58995         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
58996         int64_t ret_ref = 0;
58997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
58998         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
58999         return ret_ref;
59000 }
59001
59002 void  CS_LDK_RouteHop_set_channel_features(int64_t this_ptr, int64_t val) {
59003         LDKRouteHop this_ptr_conv;
59004         this_ptr_conv.inner = untag_ptr(this_ptr);
59005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59007         this_ptr_conv.is_owned = false;
59008         LDKChannelFeatures val_conv;
59009         val_conv.inner = untag_ptr(val);
59010         val_conv.is_owned = ptr_is_owned(val);
59011         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59012         val_conv = ChannelFeatures_clone(&val_conv);
59013         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
59014 }
59015
59016 int64_t  CS_LDK_RouteHop_get_fee_msat(int64_t this_ptr) {
59017         LDKRouteHop this_ptr_conv;
59018         this_ptr_conv.inner = untag_ptr(this_ptr);
59019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59021         this_ptr_conv.is_owned = false;
59022         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
59023         return ret_conv;
59024 }
59025
59026 void  CS_LDK_RouteHop_set_fee_msat(int64_t this_ptr, int64_t val) {
59027         LDKRouteHop this_ptr_conv;
59028         this_ptr_conv.inner = untag_ptr(this_ptr);
59029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59031         this_ptr_conv.is_owned = false;
59032         RouteHop_set_fee_msat(&this_ptr_conv, val);
59033 }
59034
59035 int32_t  CS_LDK_RouteHop_get_cltv_expiry_delta(int64_t this_ptr) {
59036         LDKRouteHop this_ptr_conv;
59037         this_ptr_conv.inner = untag_ptr(this_ptr);
59038         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59040         this_ptr_conv.is_owned = false;
59041         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
59042         return ret_conv;
59043 }
59044
59045 void  CS_LDK_RouteHop_set_cltv_expiry_delta(int64_t this_ptr, int32_t val) {
59046         LDKRouteHop this_ptr_conv;
59047         this_ptr_conv.inner = untag_ptr(this_ptr);
59048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59050         this_ptr_conv.is_owned = false;
59051         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
59052 }
59053
59054 jboolean  CS_LDK_RouteHop_get_maybe_announced_channel(int64_t this_ptr) {
59055         LDKRouteHop this_ptr_conv;
59056         this_ptr_conv.inner = untag_ptr(this_ptr);
59057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59059         this_ptr_conv.is_owned = false;
59060         jboolean ret_conv = RouteHop_get_maybe_announced_channel(&this_ptr_conv);
59061         return ret_conv;
59062 }
59063
59064 void  CS_LDK_RouteHop_set_maybe_announced_channel(int64_t this_ptr, jboolean val) {
59065         LDKRouteHop this_ptr_conv;
59066         this_ptr_conv.inner = untag_ptr(this_ptr);
59067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59069         this_ptr_conv.is_owned = false;
59070         RouteHop_set_maybe_announced_channel(&this_ptr_conv, val);
59071 }
59072
59073 int64_t  CS_LDK_RouteHop_new(int8_tArray pubkey_arg, int64_t node_features_arg, int64_t short_channel_id_arg, int64_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg, jboolean maybe_announced_channel_arg) {
59074         LDKPublicKey pubkey_arg_ref;
59075         CHECK(pubkey_arg->arr_len == 33);
59076         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
59077         LDKNodeFeatures node_features_arg_conv;
59078         node_features_arg_conv.inner = untag_ptr(node_features_arg);
59079         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
59080         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
59081         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
59082         LDKChannelFeatures channel_features_arg_conv;
59083         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
59084         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
59085         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
59086         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
59087         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, maybe_announced_channel_arg);
59088         int64_t ret_ref = 0;
59089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59091         return ret_ref;
59092 }
59093
59094 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
59095         LDKRouteHop ret_var = RouteHop_clone(arg);
59096         int64_t ret_ref = 0;
59097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59099         return ret_ref;
59100 }
59101 int64_t  CS_LDK_RouteHop_clone_ptr(int64_t arg) {
59102         LDKRouteHop arg_conv;
59103         arg_conv.inner = untag_ptr(arg);
59104         arg_conv.is_owned = ptr_is_owned(arg);
59105         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59106         arg_conv.is_owned = false;
59107         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
59108         return ret_conv;
59109 }
59110
59111 int64_t  CS_LDK_RouteHop_clone(int64_t orig) {
59112         LDKRouteHop orig_conv;
59113         orig_conv.inner = untag_ptr(orig);
59114         orig_conv.is_owned = ptr_is_owned(orig);
59115         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59116         orig_conv.is_owned = false;
59117         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
59118         int64_t ret_ref = 0;
59119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59121         return ret_ref;
59122 }
59123
59124 int64_t  CS_LDK_RouteHop_hash(int64_t o) {
59125         LDKRouteHop o_conv;
59126         o_conv.inner = untag_ptr(o);
59127         o_conv.is_owned = ptr_is_owned(o);
59128         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59129         o_conv.is_owned = false;
59130         int64_t ret_conv = RouteHop_hash(&o_conv);
59131         return ret_conv;
59132 }
59133
59134 jboolean  CS_LDK_RouteHop_eq(int64_t a, int64_t b) {
59135         LDKRouteHop a_conv;
59136         a_conv.inner = untag_ptr(a);
59137         a_conv.is_owned = ptr_is_owned(a);
59138         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59139         a_conv.is_owned = false;
59140         LDKRouteHop b_conv;
59141         b_conv.inner = untag_ptr(b);
59142         b_conv.is_owned = ptr_is_owned(b);
59143         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59144         b_conv.is_owned = false;
59145         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
59146         return ret_conv;
59147 }
59148
59149 int8_tArray  CS_LDK_RouteHop_write(int64_t obj) {
59150         LDKRouteHop obj_conv;
59151         obj_conv.inner = untag_ptr(obj);
59152         obj_conv.is_owned = ptr_is_owned(obj);
59153         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59154         obj_conv.is_owned = false;
59155         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
59156         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59157         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59158         CVec_u8Z_free(ret_var);
59159         return ret_arr;
59160 }
59161
59162 int64_t  CS_LDK_RouteHop_read(int8_tArray ser) {
59163         LDKu8slice ser_ref;
59164         ser_ref.datalen = ser->arr_len;
59165         ser_ref.data = ser->elems;
59166         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
59167         *ret_conv = RouteHop_read(ser_ref);
59168         FREE(ser);
59169         return tag_ptr(ret_conv, true);
59170 }
59171
59172 void  CS_LDK_BlindedTail_free(int64_t this_obj) {
59173         LDKBlindedTail this_obj_conv;
59174         this_obj_conv.inner = untag_ptr(this_obj);
59175         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59177         BlindedTail_free(this_obj_conv);
59178 }
59179
59180 int64_tArray  CS_LDK_BlindedTail_get_hops(int64_t this_ptr) {
59181         LDKBlindedTail this_ptr_conv;
59182         this_ptr_conv.inner = untag_ptr(this_ptr);
59183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59185         this_ptr_conv.is_owned = false;
59186         LDKCVec_BlindedHopZ ret_var = BlindedTail_get_hops(&this_ptr_conv);
59187         int64_tArray ret_arr = NULL;
59188         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
59189         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
59190         for (size_t m = 0; m < ret_var.datalen; m++) {
59191                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
59192                 int64_t ret_conv_12_ref = 0;
59193                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
59194                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
59195                 ret_arr_ptr[m] = ret_conv_12_ref;
59196         }
59197         
59198         FREE(ret_var.data);
59199         return ret_arr;
59200 }
59201
59202 void  CS_LDK_BlindedTail_set_hops(int64_t this_ptr, int64_tArray val) {
59203         LDKBlindedTail this_ptr_conv;
59204         this_ptr_conv.inner = untag_ptr(this_ptr);
59205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59207         this_ptr_conv.is_owned = false;
59208         LDKCVec_BlindedHopZ val_constr;
59209         val_constr.datalen = val->arr_len;
59210         if (val_constr.datalen > 0)
59211                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
59212         else
59213                 val_constr.data = NULL;
59214         int64_t* val_vals = val->elems;
59215         for (size_t m = 0; m < val_constr.datalen; m++) {
59216                 int64_t val_conv_12 = val_vals[m];
59217                 LDKBlindedHop val_conv_12_conv;
59218                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
59219                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
59220                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
59221                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
59222                 val_constr.data[m] = val_conv_12_conv;
59223         }
59224         FREE(val);
59225         BlindedTail_set_hops(&this_ptr_conv, val_constr);
59226 }
59227
59228 int8_tArray  CS_LDK_BlindedTail_get_blinding_point(int64_t this_ptr) {
59229         LDKBlindedTail this_ptr_conv;
59230         this_ptr_conv.inner = untag_ptr(this_ptr);
59231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59233         this_ptr_conv.is_owned = false;
59234         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
59235         memcpy(ret_arr->elems, BlindedTail_get_blinding_point(&this_ptr_conv).compressed_form, 33);
59236         return ret_arr;
59237 }
59238
59239 void  CS_LDK_BlindedTail_set_blinding_point(int64_t this_ptr, int8_tArray val) {
59240         LDKBlindedTail this_ptr_conv;
59241         this_ptr_conv.inner = untag_ptr(this_ptr);
59242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59244         this_ptr_conv.is_owned = false;
59245         LDKPublicKey val_ref;
59246         CHECK(val->arr_len == 33);
59247         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
59248         BlindedTail_set_blinding_point(&this_ptr_conv, val_ref);
59249 }
59250
59251 int32_t  CS_LDK_BlindedTail_get_excess_final_cltv_expiry_delta(int64_t this_ptr) {
59252         LDKBlindedTail this_ptr_conv;
59253         this_ptr_conv.inner = untag_ptr(this_ptr);
59254         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59256         this_ptr_conv.is_owned = false;
59257         int32_t ret_conv = BlindedTail_get_excess_final_cltv_expiry_delta(&this_ptr_conv);
59258         return ret_conv;
59259 }
59260
59261 void  CS_LDK_BlindedTail_set_excess_final_cltv_expiry_delta(int64_t this_ptr, int32_t val) {
59262         LDKBlindedTail this_ptr_conv;
59263         this_ptr_conv.inner = untag_ptr(this_ptr);
59264         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59266         this_ptr_conv.is_owned = false;
59267         BlindedTail_set_excess_final_cltv_expiry_delta(&this_ptr_conv, val);
59268 }
59269
59270 int64_t  CS_LDK_BlindedTail_get_final_value_msat(int64_t this_ptr) {
59271         LDKBlindedTail this_ptr_conv;
59272         this_ptr_conv.inner = untag_ptr(this_ptr);
59273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59275         this_ptr_conv.is_owned = false;
59276         int64_t ret_conv = BlindedTail_get_final_value_msat(&this_ptr_conv);
59277         return ret_conv;
59278 }
59279
59280 void  CS_LDK_BlindedTail_set_final_value_msat(int64_t this_ptr, int64_t val) {
59281         LDKBlindedTail this_ptr_conv;
59282         this_ptr_conv.inner = untag_ptr(this_ptr);
59283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59285         this_ptr_conv.is_owned = false;
59286         BlindedTail_set_final_value_msat(&this_ptr_conv, val);
59287 }
59288
59289 int64_t  CS_LDK_BlindedTail_new(int64_tArray hops_arg, int8_tArray blinding_point_arg, int32_t excess_final_cltv_expiry_delta_arg, int64_t final_value_msat_arg) {
59290         LDKCVec_BlindedHopZ hops_arg_constr;
59291         hops_arg_constr.datalen = hops_arg->arr_len;
59292         if (hops_arg_constr.datalen > 0)
59293                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
59294         else
59295                 hops_arg_constr.data = NULL;
59296         int64_t* hops_arg_vals = hops_arg->elems;
59297         for (size_t m = 0; m < hops_arg_constr.datalen; m++) {
59298                 int64_t hops_arg_conv_12 = hops_arg_vals[m];
59299                 LDKBlindedHop hops_arg_conv_12_conv;
59300                 hops_arg_conv_12_conv.inner = untag_ptr(hops_arg_conv_12);
59301                 hops_arg_conv_12_conv.is_owned = ptr_is_owned(hops_arg_conv_12);
59302                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_12_conv);
59303                 hops_arg_conv_12_conv = BlindedHop_clone(&hops_arg_conv_12_conv);
59304                 hops_arg_constr.data[m] = hops_arg_conv_12_conv;
59305         }
59306         FREE(hops_arg);
59307         LDKPublicKey blinding_point_arg_ref;
59308         CHECK(blinding_point_arg->arr_len == 33);
59309         memcpy(blinding_point_arg_ref.compressed_form, blinding_point_arg->elems, 33); FREE(blinding_point_arg);
59310         LDKBlindedTail ret_var = BlindedTail_new(hops_arg_constr, blinding_point_arg_ref, excess_final_cltv_expiry_delta_arg, final_value_msat_arg);
59311         int64_t ret_ref = 0;
59312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59314         return ret_ref;
59315 }
59316
59317 static inline uint64_t BlindedTail_clone_ptr(LDKBlindedTail *NONNULL_PTR arg) {
59318         LDKBlindedTail ret_var = BlindedTail_clone(arg);
59319         int64_t ret_ref = 0;
59320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59322         return ret_ref;
59323 }
59324 int64_t  CS_LDK_BlindedTail_clone_ptr(int64_t arg) {
59325         LDKBlindedTail arg_conv;
59326         arg_conv.inner = untag_ptr(arg);
59327         arg_conv.is_owned = ptr_is_owned(arg);
59328         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59329         arg_conv.is_owned = false;
59330         int64_t ret_conv = BlindedTail_clone_ptr(&arg_conv);
59331         return ret_conv;
59332 }
59333
59334 int64_t  CS_LDK_BlindedTail_clone(int64_t orig) {
59335         LDKBlindedTail orig_conv;
59336         orig_conv.inner = untag_ptr(orig);
59337         orig_conv.is_owned = ptr_is_owned(orig);
59338         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59339         orig_conv.is_owned = false;
59340         LDKBlindedTail ret_var = BlindedTail_clone(&orig_conv);
59341         int64_t ret_ref = 0;
59342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59344         return ret_ref;
59345 }
59346
59347 int64_t  CS_LDK_BlindedTail_hash(int64_t o) {
59348         LDKBlindedTail o_conv;
59349         o_conv.inner = untag_ptr(o);
59350         o_conv.is_owned = ptr_is_owned(o);
59351         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59352         o_conv.is_owned = false;
59353         int64_t ret_conv = BlindedTail_hash(&o_conv);
59354         return ret_conv;
59355 }
59356
59357 jboolean  CS_LDK_BlindedTail_eq(int64_t a, int64_t b) {
59358         LDKBlindedTail a_conv;
59359         a_conv.inner = untag_ptr(a);
59360         a_conv.is_owned = ptr_is_owned(a);
59361         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59362         a_conv.is_owned = false;
59363         LDKBlindedTail b_conv;
59364         b_conv.inner = untag_ptr(b);
59365         b_conv.is_owned = ptr_is_owned(b);
59366         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59367         b_conv.is_owned = false;
59368         jboolean ret_conv = BlindedTail_eq(&a_conv, &b_conv);
59369         return ret_conv;
59370 }
59371
59372 int8_tArray  CS_LDK_BlindedTail_write(int64_t obj) {
59373         LDKBlindedTail obj_conv;
59374         obj_conv.inner = untag_ptr(obj);
59375         obj_conv.is_owned = ptr_is_owned(obj);
59376         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59377         obj_conv.is_owned = false;
59378         LDKCVec_u8Z ret_var = BlindedTail_write(&obj_conv);
59379         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59380         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59381         CVec_u8Z_free(ret_var);
59382         return ret_arr;
59383 }
59384
59385 int64_t  CS_LDK_BlindedTail_read(int8_tArray ser) {
59386         LDKu8slice ser_ref;
59387         ser_ref.datalen = ser->arr_len;
59388         ser_ref.data = ser->elems;
59389         LDKCResult_BlindedTailDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedTailDecodeErrorZ), "LDKCResult_BlindedTailDecodeErrorZ");
59390         *ret_conv = BlindedTail_read(ser_ref);
59391         FREE(ser);
59392         return tag_ptr(ret_conv, true);
59393 }
59394
59395 void  CS_LDK_Path_free(int64_t this_obj) {
59396         LDKPath this_obj_conv;
59397         this_obj_conv.inner = untag_ptr(this_obj);
59398         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59400         Path_free(this_obj_conv);
59401 }
59402
59403 int64_tArray  CS_LDK_Path_get_hops(int64_t this_ptr) {
59404         LDKPath this_ptr_conv;
59405         this_ptr_conv.inner = untag_ptr(this_ptr);
59406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59408         this_ptr_conv.is_owned = false;
59409         LDKCVec_RouteHopZ ret_var = Path_get_hops(&this_ptr_conv);
59410         int64_tArray ret_arr = NULL;
59411         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
59412         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
59413         for (size_t k = 0; k < ret_var.datalen; k++) {
59414                 LDKRouteHop ret_conv_10_var = ret_var.data[k];
59415                 int64_t ret_conv_10_ref = 0;
59416                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
59417                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
59418                 ret_arr_ptr[k] = ret_conv_10_ref;
59419         }
59420         
59421         FREE(ret_var.data);
59422         return ret_arr;
59423 }
59424
59425 void  CS_LDK_Path_set_hops(int64_t this_ptr, int64_tArray val) {
59426         LDKPath this_ptr_conv;
59427         this_ptr_conv.inner = untag_ptr(this_ptr);
59428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59430         this_ptr_conv.is_owned = false;
59431         LDKCVec_RouteHopZ val_constr;
59432         val_constr.datalen = val->arr_len;
59433         if (val_constr.datalen > 0)
59434                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
59435         else
59436                 val_constr.data = NULL;
59437         int64_t* val_vals = val->elems;
59438         for (size_t k = 0; k < val_constr.datalen; k++) {
59439                 int64_t val_conv_10 = val_vals[k];
59440                 LDKRouteHop val_conv_10_conv;
59441                 val_conv_10_conv.inner = untag_ptr(val_conv_10);
59442                 val_conv_10_conv.is_owned = ptr_is_owned(val_conv_10);
59443                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_10_conv);
59444                 val_conv_10_conv = RouteHop_clone(&val_conv_10_conv);
59445                 val_constr.data[k] = val_conv_10_conv;
59446         }
59447         FREE(val);
59448         Path_set_hops(&this_ptr_conv, val_constr);
59449 }
59450
59451 int64_t  CS_LDK_Path_get_blinded_tail(int64_t this_ptr) {
59452         LDKPath this_ptr_conv;
59453         this_ptr_conv.inner = untag_ptr(this_ptr);
59454         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59456         this_ptr_conv.is_owned = false;
59457         LDKBlindedTail ret_var = Path_get_blinded_tail(&this_ptr_conv);
59458         int64_t ret_ref = 0;
59459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59461         return ret_ref;
59462 }
59463
59464 void  CS_LDK_Path_set_blinded_tail(int64_t this_ptr, int64_t val) {
59465         LDKPath this_ptr_conv;
59466         this_ptr_conv.inner = untag_ptr(this_ptr);
59467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59469         this_ptr_conv.is_owned = false;
59470         LDKBlindedTail val_conv;
59471         val_conv.inner = untag_ptr(val);
59472         val_conv.is_owned = ptr_is_owned(val);
59473         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59474         val_conv = BlindedTail_clone(&val_conv);
59475         Path_set_blinded_tail(&this_ptr_conv, val_conv);
59476 }
59477
59478 int64_t  CS_LDK_Path_new(int64_tArray hops_arg, int64_t blinded_tail_arg) {
59479         LDKCVec_RouteHopZ hops_arg_constr;
59480         hops_arg_constr.datalen = hops_arg->arr_len;
59481         if (hops_arg_constr.datalen > 0)
59482                 hops_arg_constr.data = MALLOC(hops_arg_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
59483         else
59484                 hops_arg_constr.data = NULL;
59485         int64_t* hops_arg_vals = hops_arg->elems;
59486         for (size_t k = 0; k < hops_arg_constr.datalen; k++) {
59487                 int64_t hops_arg_conv_10 = hops_arg_vals[k];
59488                 LDKRouteHop hops_arg_conv_10_conv;
59489                 hops_arg_conv_10_conv.inner = untag_ptr(hops_arg_conv_10);
59490                 hops_arg_conv_10_conv.is_owned = ptr_is_owned(hops_arg_conv_10);
59491                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_arg_conv_10_conv);
59492                 hops_arg_conv_10_conv = RouteHop_clone(&hops_arg_conv_10_conv);
59493                 hops_arg_constr.data[k] = hops_arg_conv_10_conv;
59494         }
59495         FREE(hops_arg);
59496         LDKBlindedTail blinded_tail_arg_conv;
59497         blinded_tail_arg_conv.inner = untag_ptr(blinded_tail_arg);
59498         blinded_tail_arg_conv.is_owned = ptr_is_owned(blinded_tail_arg);
59499         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_tail_arg_conv);
59500         blinded_tail_arg_conv = BlindedTail_clone(&blinded_tail_arg_conv);
59501         LDKPath ret_var = Path_new(hops_arg_constr, blinded_tail_arg_conv);
59502         int64_t ret_ref = 0;
59503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59505         return ret_ref;
59506 }
59507
59508 static inline uint64_t Path_clone_ptr(LDKPath *NONNULL_PTR arg) {
59509         LDKPath ret_var = Path_clone(arg);
59510         int64_t ret_ref = 0;
59511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59513         return ret_ref;
59514 }
59515 int64_t  CS_LDK_Path_clone_ptr(int64_t arg) {
59516         LDKPath arg_conv;
59517         arg_conv.inner = untag_ptr(arg);
59518         arg_conv.is_owned = ptr_is_owned(arg);
59519         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59520         arg_conv.is_owned = false;
59521         int64_t ret_conv = Path_clone_ptr(&arg_conv);
59522         return ret_conv;
59523 }
59524
59525 int64_t  CS_LDK_Path_clone(int64_t orig) {
59526         LDKPath orig_conv;
59527         orig_conv.inner = untag_ptr(orig);
59528         orig_conv.is_owned = ptr_is_owned(orig);
59529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59530         orig_conv.is_owned = false;
59531         LDKPath ret_var = Path_clone(&orig_conv);
59532         int64_t ret_ref = 0;
59533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59535         return ret_ref;
59536 }
59537
59538 int64_t  CS_LDK_Path_hash(int64_t o) {
59539         LDKPath o_conv;
59540         o_conv.inner = untag_ptr(o);
59541         o_conv.is_owned = ptr_is_owned(o);
59542         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59543         o_conv.is_owned = false;
59544         int64_t ret_conv = Path_hash(&o_conv);
59545         return ret_conv;
59546 }
59547
59548 jboolean  CS_LDK_Path_eq(int64_t a, int64_t b) {
59549         LDKPath a_conv;
59550         a_conv.inner = untag_ptr(a);
59551         a_conv.is_owned = ptr_is_owned(a);
59552         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59553         a_conv.is_owned = false;
59554         LDKPath b_conv;
59555         b_conv.inner = untag_ptr(b);
59556         b_conv.is_owned = ptr_is_owned(b);
59557         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59558         b_conv.is_owned = false;
59559         jboolean ret_conv = Path_eq(&a_conv, &b_conv);
59560         return ret_conv;
59561 }
59562
59563 int64_t  CS_LDK_Path_fee_msat(int64_t this_arg) {
59564         LDKPath this_arg_conv;
59565         this_arg_conv.inner = untag_ptr(this_arg);
59566         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59568         this_arg_conv.is_owned = false;
59569         int64_t ret_conv = Path_fee_msat(&this_arg_conv);
59570         return ret_conv;
59571 }
59572
59573 int64_t  CS_LDK_Path_final_value_msat(int64_t this_arg) {
59574         LDKPath this_arg_conv;
59575         this_arg_conv.inner = untag_ptr(this_arg);
59576         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59578         this_arg_conv.is_owned = false;
59579         int64_t ret_conv = Path_final_value_msat(&this_arg_conv);
59580         return ret_conv;
59581 }
59582
59583 int64_t  CS_LDK_Path_final_cltv_expiry_delta(int64_t this_arg) {
59584         LDKPath this_arg_conv;
59585         this_arg_conv.inner = untag_ptr(this_arg);
59586         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59588         this_arg_conv.is_owned = false;
59589         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
59590         *ret_copy = Path_final_cltv_expiry_delta(&this_arg_conv);
59591         int64_t ret_ref = tag_ptr(ret_copy, true);
59592         return ret_ref;
59593 }
59594
59595 void  CS_LDK_Route_free(int64_t this_obj) {
59596         LDKRoute this_obj_conv;
59597         this_obj_conv.inner = untag_ptr(this_obj);
59598         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59600         Route_free(this_obj_conv);
59601 }
59602
59603 int64_tArray  CS_LDK_Route_get_paths(int64_t this_ptr) {
59604         LDKRoute this_ptr_conv;
59605         this_ptr_conv.inner = untag_ptr(this_ptr);
59606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59608         this_ptr_conv.is_owned = false;
59609         LDKCVec_PathZ ret_var = Route_get_paths(&this_ptr_conv);
59610         int64_tArray ret_arr = NULL;
59611         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
59612         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
59613         for (size_t g = 0; g < ret_var.datalen; g++) {
59614                 LDKPath ret_conv_6_var = ret_var.data[g];
59615                 int64_t ret_conv_6_ref = 0;
59616                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
59617                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
59618                 ret_arr_ptr[g] = ret_conv_6_ref;
59619         }
59620         
59621         FREE(ret_var.data);
59622         return ret_arr;
59623 }
59624
59625 void  CS_LDK_Route_set_paths(int64_t this_ptr, int64_tArray val) {
59626         LDKRoute this_ptr_conv;
59627         this_ptr_conv.inner = untag_ptr(this_ptr);
59628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59630         this_ptr_conv.is_owned = false;
59631         LDKCVec_PathZ val_constr;
59632         val_constr.datalen = val->arr_len;
59633         if (val_constr.datalen > 0)
59634                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
59635         else
59636                 val_constr.data = NULL;
59637         int64_t* val_vals = val->elems;
59638         for (size_t g = 0; g < val_constr.datalen; g++) {
59639                 int64_t val_conv_6 = val_vals[g];
59640                 LDKPath val_conv_6_conv;
59641                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
59642                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
59643                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
59644                 val_conv_6_conv = Path_clone(&val_conv_6_conv);
59645                 val_constr.data[g] = val_conv_6_conv;
59646         }
59647         FREE(val);
59648         Route_set_paths(&this_ptr_conv, val_constr);
59649 }
59650
59651 int64_t  CS_LDK_Route_get_route_params(int64_t this_ptr) {
59652         LDKRoute this_ptr_conv;
59653         this_ptr_conv.inner = untag_ptr(this_ptr);
59654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59656         this_ptr_conv.is_owned = false;
59657         LDKRouteParameters ret_var = Route_get_route_params(&this_ptr_conv);
59658         int64_t ret_ref = 0;
59659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59660         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59661         return ret_ref;
59662 }
59663
59664 void  CS_LDK_Route_set_route_params(int64_t this_ptr, int64_t val) {
59665         LDKRoute this_ptr_conv;
59666         this_ptr_conv.inner = untag_ptr(this_ptr);
59667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59669         this_ptr_conv.is_owned = false;
59670         LDKRouteParameters val_conv;
59671         val_conv.inner = untag_ptr(val);
59672         val_conv.is_owned = ptr_is_owned(val);
59673         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59674         val_conv = RouteParameters_clone(&val_conv);
59675         Route_set_route_params(&this_ptr_conv, val_conv);
59676 }
59677
59678 int64_t  CS_LDK_Route_new(int64_tArray paths_arg, int64_t route_params_arg) {
59679         LDKCVec_PathZ paths_arg_constr;
59680         paths_arg_constr.datalen = paths_arg->arr_len;
59681         if (paths_arg_constr.datalen > 0)
59682                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKPath), "LDKCVec_PathZ Elements");
59683         else
59684                 paths_arg_constr.data = NULL;
59685         int64_t* paths_arg_vals = paths_arg->elems;
59686         for (size_t g = 0; g < paths_arg_constr.datalen; g++) {
59687                 int64_t paths_arg_conv_6 = paths_arg_vals[g];
59688                 LDKPath paths_arg_conv_6_conv;
59689                 paths_arg_conv_6_conv.inner = untag_ptr(paths_arg_conv_6);
59690                 paths_arg_conv_6_conv.is_owned = ptr_is_owned(paths_arg_conv_6);
59691                 CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_6_conv);
59692                 paths_arg_conv_6_conv = Path_clone(&paths_arg_conv_6_conv);
59693                 paths_arg_constr.data[g] = paths_arg_conv_6_conv;
59694         }
59695         FREE(paths_arg);
59696         LDKRouteParameters route_params_arg_conv;
59697         route_params_arg_conv.inner = untag_ptr(route_params_arg);
59698         route_params_arg_conv.is_owned = ptr_is_owned(route_params_arg);
59699         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_arg_conv);
59700         route_params_arg_conv = RouteParameters_clone(&route_params_arg_conv);
59701         LDKRoute ret_var = Route_new(paths_arg_constr, route_params_arg_conv);
59702         int64_t ret_ref = 0;
59703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59705         return ret_ref;
59706 }
59707
59708 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
59709         LDKRoute ret_var = Route_clone(arg);
59710         int64_t ret_ref = 0;
59711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59712         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59713         return ret_ref;
59714 }
59715 int64_t  CS_LDK_Route_clone_ptr(int64_t arg) {
59716         LDKRoute arg_conv;
59717         arg_conv.inner = untag_ptr(arg);
59718         arg_conv.is_owned = ptr_is_owned(arg);
59719         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59720         arg_conv.is_owned = false;
59721         int64_t ret_conv = Route_clone_ptr(&arg_conv);
59722         return ret_conv;
59723 }
59724
59725 int64_t  CS_LDK_Route_clone(int64_t orig) {
59726         LDKRoute orig_conv;
59727         orig_conv.inner = untag_ptr(orig);
59728         orig_conv.is_owned = ptr_is_owned(orig);
59729         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59730         orig_conv.is_owned = false;
59731         LDKRoute ret_var = Route_clone(&orig_conv);
59732         int64_t ret_ref = 0;
59733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59735         return ret_ref;
59736 }
59737
59738 int64_t  CS_LDK_Route_hash(int64_t o) {
59739         LDKRoute o_conv;
59740         o_conv.inner = untag_ptr(o);
59741         o_conv.is_owned = ptr_is_owned(o);
59742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59743         o_conv.is_owned = false;
59744         int64_t ret_conv = Route_hash(&o_conv);
59745         return ret_conv;
59746 }
59747
59748 jboolean  CS_LDK_Route_eq(int64_t a, int64_t b) {
59749         LDKRoute a_conv;
59750         a_conv.inner = untag_ptr(a);
59751         a_conv.is_owned = ptr_is_owned(a);
59752         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59753         a_conv.is_owned = false;
59754         LDKRoute b_conv;
59755         b_conv.inner = untag_ptr(b);
59756         b_conv.is_owned = ptr_is_owned(b);
59757         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59758         b_conv.is_owned = false;
59759         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
59760         return ret_conv;
59761 }
59762
59763 int64_t  CS_LDK_Route_get_total_fees(int64_t this_arg) {
59764         LDKRoute this_arg_conv;
59765         this_arg_conv.inner = untag_ptr(this_arg);
59766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59768         this_arg_conv.is_owned = false;
59769         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
59770         return ret_conv;
59771 }
59772
59773 int64_t  CS_LDK_Route_get_total_amount(int64_t this_arg) {
59774         LDKRoute this_arg_conv;
59775         this_arg_conv.inner = untag_ptr(this_arg);
59776         this_arg_conv.is_owned = ptr_is_owned(this_arg);
59777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
59778         this_arg_conv.is_owned = false;
59779         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
59780         return ret_conv;
59781 }
59782
59783 int8_tArray  CS_LDK_Route_write(int64_t obj) {
59784         LDKRoute obj_conv;
59785         obj_conv.inner = untag_ptr(obj);
59786         obj_conv.is_owned = ptr_is_owned(obj);
59787         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59788         obj_conv.is_owned = false;
59789         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
59790         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59791         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59792         CVec_u8Z_free(ret_var);
59793         return ret_arr;
59794 }
59795
59796 int64_t  CS_LDK_Route_read(int8_tArray ser) {
59797         LDKu8slice ser_ref;
59798         ser_ref.datalen = ser->arr_len;
59799         ser_ref.data = ser->elems;
59800         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
59801         *ret_conv = Route_read(ser_ref);
59802         FREE(ser);
59803         return tag_ptr(ret_conv, true);
59804 }
59805
59806 void  CS_LDK_RouteParameters_free(int64_t this_obj) {
59807         LDKRouteParameters this_obj_conv;
59808         this_obj_conv.inner = untag_ptr(this_obj);
59809         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59811         RouteParameters_free(this_obj_conv);
59812 }
59813
59814 int64_t  CS_LDK_RouteParameters_get_payment_params(int64_t this_ptr) {
59815         LDKRouteParameters this_ptr_conv;
59816         this_ptr_conv.inner = untag_ptr(this_ptr);
59817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59819         this_ptr_conv.is_owned = false;
59820         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
59821         int64_t ret_ref = 0;
59822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59824         return ret_ref;
59825 }
59826
59827 void  CS_LDK_RouteParameters_set_payment_params(int64_t this_ptr, int64_t val) {
59828         LDKRouteParameters this_ptr_conv;
59829         this_ptr_conv.inner = untag_ptr(this_ptr);
59830         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59832         this_ptr_conv.is_owned = false;
59833         LDKPaymentParameters val_conv;
59834         val_conv.inner = untag_ptr(val);
59835         val_conv.is_owned = ptr_is_owned(val);
59836         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
59837         val_conv = PaymentParameters_clone(&val_conv);
59838         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
59839 }
59840
59841 int64_t  CS_LDK_RouteParameters_get_final_value_msat(int64_t this_ptr) {
59842         LDKRouteParameters this_ptr_conv;
59843         this_ptr_conv.inner = untag_ptr(this_ptr);
59844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59846         this_ptr_conv.is_owned = false;
59847         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
59848         return ret_conv;
59849 }
59850
59851 void  CS_LDK_RouteParameters_set_final_value_msat(int64_t this_ptr, int64_t val) {
59852         LDKRouteParameters this_ptr_conv;
59853         this_ptr_conv.inner = untag_ptr(this_ptr);
59854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59856         this_ptr_conv.is_owned = false;
59857         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
59858 }
59859
59860 int64_t  CS_LDK_RouteParameters_get_max_total_routing_fee_msat(int64_t this_ptr) {
59861         LDKRouteParameters this_ptr_conv;
59862         this_ptr_conv.inner = untag_ptr(this_ptr);
59863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59865         this_ptr_conv.is_owned = false;
59866         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
59867         *ret_copy = RouteParameters_get_max_total_routing_fee_msat(&this_ptr_conv);
59868         int64_t ret_ref = tag_ptr(ret_copy, true);
59869         return ret_ref;
59870 }
59871
59872 void  CS_LDK_RouteParameters_set_max_total_routing_fee_msat(int64_t this_ptr, int64_t val) {
59873         LDKRouteParameters this_ptr_conv;
59874         this_ptr_conv.inner = untag_ptr(this_ptr);
59875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
59876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
59877         this_ptr_conv.is_owned = false;
59878         void* val_ptr = untag_ptr(val);
59879         CHECK_ACCESS(val_ptr);
59880         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
59881         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
59882         RouteParameters_set_max_total_routing_fee_msat(&this_ptr_conv, val_conv);
59883 }
59884
59885 int64_t  CS_LDK_RouteParameters_new(int64_t payment_params_arg, int64_t final_value_msat_arg, int64_t max_total_routing_fee_msat_arg) {
59886         LDKPaymentParameters payment_params_arg_conv;
59887         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
59888         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
59889         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
59890         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
59891         void* max_total_routing_fee_msat_arg_ptr = untag_ptr(max_total_routing_fee_msat_arg);
59892         CHECK_ACCESS(max_total_routing_fee_msat_arg_ptr);
59893         LDKCOption_u64Z max_total_routing_fee_msat_arg_conv = *(LDKCOption_u64Z*)(max_total_routing_fee_msat_arg_ptr);
59894         max_total_routing_fee_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(max_total_routing_fee_msat_arg));
59895         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, max_total_routing_fee_msat_arg_conv);
59896         int64_t ret_ref = 0;
59897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59899         return ret_ref;
59900 }
59901
59902 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
59903         LDKRouteParameters ret_var = RouteParameters_clone(arg);
59904         int64_t ret_ref = 0;
59905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59907         return ret_ref;
59908 }
59909 int64_t  CS_LDK_RouteParameters_clone_ptr(int64_t arg) {
59910         LDKRouteParameters arg_conv;
59911         arg_conv.inner = untag_ptr(arg);
59912         arg_conv.is_owned = ptr_is_owned(arg);
59913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
59914         arg_conv.is_owned = false;
59915         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
59916         return ret_conv;
59917 }
59918
59919 int64_t  CS_LDK_RouteParameters_clone(int64_t orig) {
59920         LDKRouteParameters orig_conv;
59921         orig_conv.inner = untag_ptr(orig);
59922         orig_conv.is_owned = ptr_is_owned(orig);
59923         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
59924         orig_conv.is_owned = false;
59925         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
59926         int64_t ret_ref = 0;
59927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59929         return ret_ref;
59930 }
59931
59932 int64_t  CS_LDK_RouteParameters_hash(int64_t o) {
59933         LDKRouteParameters o_conv;
59934         o_conv.inner = untag_ptr(o);
59935         o_conv.is_owned = ptr_is_owned(o);
59936         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
59937         o_conv.is_owned = false;
59938         int64_t ret_conv = RouteParameters_hash(&o_conv);
59939         return ret_conv;
59940 }
59941
59942 jboolean  CS_LDK_RouteParameters_eq(int64_t a, int64_t b) {
59943         LDKRouteParameters a_conv;
59944         a_conv.inner = untag_ptr(a);
59945         a_conv.is_owned = ptr_is_owned(a);
59946         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
59947         a_conv.is_owned = false;
59948         LDKRouteParameters b_conv;
59949         b_conv.inner = untag_ptr(b);
59950         b_conv.is_owned = ptr_is_owned(b);
59951         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
59952         b_conv.is_owned = false;
59953         jboolean ret_conv = RouteParameters_eq(&a_conv, &b_conv);
59954         return ret_conv;
59955 }
59956
59957 int64_t  CS_LDK_RouteParameters_from_payment_params_and_value(int64_t payment_params, int64_t final_value_msat) {
59958         LDKPaymentParameters payment_params_conv;
59959         payment_params_conv.inner = untag_ptr(payment_params);
59960         payment_params_conv.is_owned = ptr_is_owned(payment_params);
59961         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_conv);
59962         payment_params_conv = PaymentParameters_clone(&payment_params_conv);
59963         LDKRouteParameters ret_var = RouteParameters_from_payment_params_and_value(payment_params_conv, final_value_msat);
59964         int64_t ret_ref = 0;
59965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
59966         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
59967         return ret_ref;
59968 }
59969
59970 int8_tArray  CS_LDK_RouteParameters_write(int64_t obj) {
59971         LDKRouteParameters obj_conv;
59972         obj_conv.inner = untag_ptr(obj);
59973         obj_conv.is_owned = ptr_is_owned(obj);
59974         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
59975         obj_conv.is_owned = false;
59976         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
59977         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
59978         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
59979         CVec_u8Z_free(ret_var);
59980         return ret_arr;
59981 }
59982
59983 int64_t  CS_LDK_RouteParameters_read(int8_tArray ser) {
59984         LDKu8slice ser_ref;
59985         ser_ref.datalen = ser->arr_len;
59986         ser_ref.data = ser->elems;
59987         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
59988         *ret_conv = RouteParameters_read(ser_ref);
59989         FREE(ser);
59990         return tag_ptr(ret_conv, true);
59991 }
59992
59993 void  CS_LDK_PaymentParameters_free(int64_t this_obj) {
59994         LDKPaymentParameters this_obj_conv;
59995         this_obj_conv.inner = untag_ptr(this_obj);
59996         this_obj_conv.is_owned = ptr_is_owned(this_obj);
59997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
59998         PaymentParameters_free(this_obj_conv);
59999 }
60000
60001 int64_t  CS_LDK_PaymentParameters_get_payee(int64_t this_ptr) {
60002         LDKPaymentParameters this_ptr_conv;
60003         this_ptr_conv.inner = untag_ptr(this_ptr);
60004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60006         this_ptr_conv.is_owned = false;
60007         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60008         *ret_copy = PaymentParameters_get_payee(&this_ptr_conv);
60009         int64_t ret_ref = tag_ptr(ret_copy, true);
60010         return ret_ref;
60011 }
60012
60013 void  CS_LDK_PaymentParameters_set_payee(int64_t this_ptr, int64_t val) {
60014         LDKPaymentParameters this_ptr_conv;
60015         this_ptr_conv.inner = untag_ptr(this_ptr);
60016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60018         this_ptr_conv.is_owned = false;
60019         void* val_ptr = untag_ptr(val);
60020         CHECK_ACCESS(val_ptr);
60021         LDKPayee val_conv = *(LDKPayee*)(val_ptr);
60022         val_conv = Payee_clone((LDKPayee*)untag_ptr(val));
60023         PaymentParameters_set_payee(&this_ptr_conv, val_conv);
60024 }
60025
60026 int64_t  CS_LDK_PaymentParameters_get_expiry_time(int64_t this_ptr) {
60027         LDKPaymentParameters this_ptr_conv;
60028         this_ptr_conv.inner = untag_ptr(this_ptr);
60029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60031         this_ptr_conv.is_owned = false;
60032         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
60033         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
60034         int64_t ret_ref = tag_ptr(ret_copy, true);
60035         return ret_ref;
60036 }
60037
60038 void  CS_LDK_PaymentParameters_set_expiry_time(int64_t this_ptr, int64_t val) {
60039         LDKPaymentParameters this_ptr_conv;
60040         this_ptr_conv.inner = untag_ptr(this_ptr);
60041         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60043         this_ptr_conv.is_owned = false;
60044         void* val_ptr = untag_ptr(val);
60045         CHECK_ACCESS(val_ptr);
60046         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
60047         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
60048         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
60049 }
60050
60051 int32_t  CS_LDK_PaymentParameters_get_max_total_cltv_expiry_delta(int64_t this_ptr) {
60052         LDKPaymentParameters this_ptr_conv;
60053         this_ptr_conv.inner = untag_ptr(this_ptr);
60054         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60056         this_ptr_conv.is_owned = false;
60057         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
60058         return ret_conv;
60059 }
60060
60061 void  CS_LDK_PaymentParameters_set_max_total_cltv_expiry_delta(int64_t this_ptr, int32_t val) {
60062         LDKPaymentParameters this_ptr_conv;
60063         this_ptr_conv.inner = untag_ptr(this_ptr);
60064         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60066         this_ptr_conv.is_owned = false;
60067         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
60068 }
60069
60070 int8_t  CS_LDK_PaymentParameters_get_max_path_count(int64_t this_ptr) {
60071         LDKPaymentParameters this_ptr_conv;
60072         this_ptr_conv.inner = untag_ptr(this_ptr);
60073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60075         this_ptr_conv.is_owned = false;
60076         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
60077         return ret_conv;
60078 }
60079
60080 void  CS_LDK_PaymentParameters_set_max_path_count(int64_t this_ptr, int8_t val) {
60081         LDKPaymentParameters this_ptr_conv;
60082         this_ptr_conv.inner = untag_ptr(this_ptr);
60083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60085         this_ptr_conv.is_owned = false;
60086         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
60087 }
60088
60089 int8_t  CS_LDK_PaymentParameters_get_max_channel_saturation_power_of_half(int64_t this_ptr) {
60090         LDKPaymentParameters this_ptr_conv;
60091         this_ptr_conv.inner = untag_ptr(this_ptr);
60092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60094         this_ptr_conv.is_owned = false;
60095         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
60096         return ret_conv;
60097 }
60098
60099 void  CS_LDK_PaymentParameters_set_max_channel_saturation_power_of_half(int64_t this_ptr, int8_t val) {
60100         LDKPaymentParameters this_ptr_conv;
60101         this_ptr_conv.inner = untag_ptr(this_ptr);
60102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60104         this_ptr_conv.is_owned = false;
60105         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
60106 }
60107
60108 int64_tArray  CS_LDK_PaymentParameters_get_previously_failed_channels(int64_t this_ptr) {
60109         LDKPaymentParameters this_ptr_conv;
60110         this_ptr_conv.inner = untag_ptr(this_ptr);
60111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60113         this_ptr_conv.is_owned = false;
60114         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
60115         int64_tArray ret_arr = NULL;
60116         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
60117         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
60118         for (size_t g = 0; g < ret_var.datalen; g++) {
60119                 int64_t ret_conv_6_conv = ret_var.data[g];
60120                 ret_arr_ptr[g] = ret_conv_6_conv;
60121         }
60122         
60123         FREE(ret_var.data);
60124         return ret_arr;
60125 }
60126
60127 void  CS_LDK_PaymentParameters_set_previously_failed_channels(int64_t this_ptr, int64_tArray val) {
60128         LDKPaymentParameters this_ptr_conv;
60129         this_ptr_conv.inner = untag_ptr(this_ptr);
60130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60132         this_ptr_conv.is_owned = false;
60133         LDKCVec_u64Z val_constr;
60134         val_constr.datalen = val->arr_len;
60135         if (val_constr.datalen > 0)
60136                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
60137         else
60138                 val_constr.data = NULL;
60139         int64_t* val_vals = val->elems;
60140         for (size_t g = 0; g < val_constr.datalen; g++) {
60141                 int64_t val_conv_6 = val_vals[g];
60142                 val_constr.data[g] = val_conv_6;
60143         }
60144         FREE(val);
60145         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
60146 }
60147
60148 int64_t  CS_LDK_PaymentParameters_new(int64_t payee_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
60149         void* payee_arg_ptr = untag_ptr(payee_arg);
60150         CHECK_ACCESS(payee_arg_ptr);
60151         LDKPayee payee_arg_conv = *(LDKPayee*)(payee_arg_ptr);
60152         payee_arg_conv = Payee_clone((LDKPayee*)untag_ptr(payee_arg));
60153         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
60154         CHECK_ACCESS(expiry_time_arg_ptr);
60155         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
60156         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
60157         LDKCVec_u64Z previously_failed_channels_arg_constr;
60158         previously_failed_channels_arg_constr.datalen = previously_failed_channels_arg->arr_len;
60159         if (previously_failed_channels_arg_constr.datalen > 0)
60160                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
60161         else
60162                 previously_failed_channels_arg_constr.data = NULL;
60163         int64_t* previously_failed_channels_arg_vals = previously_failed_channels_arg->elems;
60164         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
60165                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
60166                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
60167         }
60168         FREE(previously_failed_channels_arg);
60169         LDKPaymentParameters ret_var = PaymentParameters_new(payee_arg_conv, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
60170         int64_t ret_ref = 0;
60171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60173         return ret_ref;
60174 }
60175
60176 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
60177         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
60178         int64_t ret_ref = 0;
60179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60180         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60181         return ret_ref;
60182 }
60183 int64_t  CS_LDK_PaymentParameters_clone_ptr(int64_t arg) {
60184         LDKPaymentParameters arg_conv;
60185         arg_conv.inner = untag_ptr(arg);
60186         arg_conv.is_owned = ptr_is_owned(arg);
60187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
60188         arg_conv.is_owned = false;
60189         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
60190         return ret_conv;
60191 }
60192
60193 int64_t  CS_LDK_PaymentParameters_clone(int64_t orig) {
60194         LDKPaymentParameters orig_conv;
60195         orig_conv.inner = untag_ptr(orig);
60196         orig_conv.is_owned = ptr_is_owned(orig);
60197         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
60198         orig_conv.is_owned = false;
60199         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
60200         int64_t ret_ref = 0;
60201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60203         return ret_ref;
60204 }
60205
60206 int64_t  CS_LDK_PaymentParameters_hash(int64_t o) {
60207         LDKPaymentParameters o_conv;
60208         o_conv.inner = untag_ptr(o);
60209         o_conv.is_owned = ptr_is_owned(o);
60210         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
60211         o_conv.is_owned = false;
60212         int64_t ret_conv = PaymentParameters_hash(&o_conv);
60213         return ret_conv;
60214 }
60215
60216 jboolean  CS_LDK_PaymentParameters_eq(int64_t a, int64_t b) {
60217         LDKPaymentParameters a_conv;
60218         a_conv.inner = untag_ptr(a);
60219         a_conv.is_owned = ptr_is_owned(a);
60220         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
60221         a_conv.is_owned = false;
60222         LDKPaymentParameters b_conv;
60223         b_conv.inner = untag_ptr(b);
60224         b_conv.is_owned = ptr_is_owned(b);
60225         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
60226         b_conv.is_owned = false;
60227         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
60228         return ret_conv;
60229 }
60230
60231 int8_tArray  CS_LDK_PaymentParameters_write(int64_t obj) {
60232         LDKPaymentParameters obj_conv;
60233         obj_conv.inner = untag_ptr(obj);
60234         obj_conv.is_owned = ptr_is_owned(obj);
60235         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
60236         obj_conv.is_owned = false;
60237         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
60238         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
60239         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
60240         CVec_u8Z_free(ret_var);
60241         return ret_arr;
60242 }
60243
60244 int64_t  CS_LDK_PaymentParameters_read(int8_tArray ser, int32_t arg) {
60245         LDKu8slice ser_ref;
60246         ser_ref.datalen = ser->arr_len;
60247         ser_ref.data = ser->elems;
60248         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
60249         *ret_conv = PaymentParameters_read(ser_ref, arg);
60250         FREE(ser);
60251         return tag_ptr(ret_conv, true);
60252 }
60253
60254 int64_t  CS_LDK_PaymentParameters_from_node_id(int8_tArray payee_pubkey, int32_t final_cltv_expiry_delta) {
60255         LDKPublicKey payee_pubkey_ref;
60256         CHECK(payee_pubkey->arr_len == 33);
60257         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
60258         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref, final_cltv_expiry_delta);
60259         int64_t ret_ref = 0;
60260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60262         return ret_ref;
60263 }
60264
60265 int64_t  CS_LDK_PaymentParameters_for_keysend(int8_tArray payee_pubkey, int32_t final_cltv_expiry_delta, jboolean allow_mpp) {
60266         LDKPublicKey payee_pubkey_ref;
60267         CHECK(payee_pubkey->arr_len == 33);
60268         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
60269         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref, final_cltv_expiry_delta, allow_mpp);
60270         int64_t ret_ref = 0;
60271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60273         return ret_ref;
60274 }
60275
60276 int64_t  CS_LDK_PaymentParameters_from_bolt12_invoice(int64_t invoice) {
60277         LDKBolt12Invoice invoice_conv;
60278         invoice_conv.inner = untag_ptr(invoice);
60279         invoice_conv.is_owned = ptr_is_owned(invoice);
60280         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
60281         invoice_conv.is_owned = false;
60282         LDKPaymentParameters ret_var = PaymentParameters_from_bolt12_invoice(&invoice_conv);
60283         int64_t ret_ref = 0;
60284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60285         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60286         return ret_ref;
60287 }
60288
60289 int64_t  CS_LDK_PaymentParameters_blinded(int64_tArray blinded_route_hints) {
60290         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ blinded_route_hints_constr;
60291         blinded_route_hints_constr.datalen = blinded_route_hints->arr_len;
60292         if (blinded_route_hints_constr.datalen > 0)
60293                 blinded_route_hints_constr.data = MALLOC(blinded_route_hints_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
60294         else
60295                 blinded_route_hints_constr.data = NULL;
60296         int64_t* blinded_route_hints_vals = blinded_route_hints->elems;
60297         for (size_t l = 0; l < blinded_route_hints_constr.datalen; l++) {
60298                 int64_t blinded_route_hints_conv_37 = blinded_route_hints_vals[l];
60299                 void* blinded_route_hints_conv_37_ptr = untag_ptr(blinded_route_hints_conv_37);
60300                 CHECK_ACCESS(blinded_route_hints_conv_37_ptr);
60301                 LDKC2Tuple_BlindedPayInfoBlindedPathZ blinded_route_hints_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(blinded_route_hints_conv_37_ptr);
60302                 blinded_route_hints_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(blinded_route_hints_conv_37));
60303                 blinded_route_hints_constr.data[l] = blinded_route_hints_conv_37_conv;
60304         }
60305         FREE(blinded_route_hints);
60306         LDKPaymentParameters ret_var = PaymentParameters_blinded(blinded_route_hints_constr);
60307         int64_t ret_ref = 0;
60308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60310         return ret_ref;
60311 }
60312
60313 void  CS_LDK_Payee_free(int64_t this_ptr) {
60314         if (!ptr_is_owned(this_ptr)) return;
60315         void* this_ptr_ptr = untag_ptr(this_ptr);
60316         CHECK_ACCESS(this_ptr_ptr);
60317         LDKPayee this_ptr_conv = *(LDKPayee*)(this_ptr_ptr);
60318         FREE(untag_ptr(this_ptr));
60319         Payee_free(this_ptr_conv);
60320 }
60321
60322 static inline uint64_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
60323         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60324         *ret_copy = Payee_clone(arg);
60325         int64_t ret_ref = tag_ptr(ret_copy, true);
60326         return ret_ref;
60327 }
60328 int64_t  CS_LDK_Payee_clone_ptr(int64_t arg) {
60329         LDKPayee* arg_conv = (LDKPayee*)untag_ptr(arg);
60330         int64_t ret_conv = Payee_clone_ptr(arg_conv);
60331         return ret_conv;
60332 }
60333
60334 int64_t  CS_LDK_Payee_clone(int64_t orig) {
60335         LDKPayee* orig_conv = (LDKPayee*)untag_ptr(orig);
60336         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60337         *ret_copy = Payee_clone(orig_conv);
60338         int64_t ret_ref = tag_ptr(ret_copy, true);
60339         return ret_ref;
60340 }
60341
60342 int64_t  CS_LDK_Payee_blinded(int64_tArray route_hints, int64_t features) {
60343         LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ route_hints_constr;
60344         route_hints_constr.datalen = route_hints->arr_len;
60345         if (route_hints_constr.datalen > 0)
60346                 route_hints_constr.data = MALLOC(route_hints_constr.datalen * sizeof(LDKC2Tuple_BlindedPayInfoBlindedPathZ), "LDKCVec_C2Tuple_BlindedPayInfoBlindedPathZZ Elements");
60347         else
60348                 route_hints_constr.data = NULL;
60349         int64_t* route_hints_vals = route_hints->elems;
60350         for (size_t l = 0; l < route_hints_constr.datalen; l++) {
60351                 int64_t route_hints_conv_37 = route_hints_vals[l];
60352                 void* route_hints_conv_37_ptr = untag_ptr(route_hints_conv_37);
60353                 CHECK_ACCESS(route_hints_conv_37_ptr);
60354                 LDKC2Tuple_BlindedPayInfoBlindedPathZ route_hints_conv_37_conv = *(LDKC2Tuple_BlindedPayInfoBlindedPathZ*)(route_hints_conv_37_ptr);
60355                 route_hints_conv_37_conv = C2Tuple_BlindedPayInfoBlindedPathZ_clone((LDKC2Tuple_BlindedPayInfoBlindedPathZ*)untag_ptr(route_hints_conv_37));
60356                 route_hints_constr.data[l] = route_hints_conv_37_conv;
60357         }
60358         FREE(route_hints);
60359         LDKBolt12InvoiceFeatures features_conv;
60360         features_conv.inner = untag_ptr(features);
60361         features_conv.is_owned = ptr_is_owned(features);
60362         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
60363         features_conv = Bolt12InvoiceFeatures_clone(&features_conv);
60364         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60365         *ret_copy = Payee_blinded(route_hints_constr, features_conv);
60366         int64_t ret_ref = tag_ptr(ret_copy, true);
60367         return ret_ref;
60368 }
60369
60370 int64_t  CS_LDK_Payee_clear(int8_tArray node_id, int64_tArray route_hints, int64_t features, int32_t final_cltv_expiry_delta) {
60371         LDKPublicKey node_id_ref;
60372         CHECK(node_id->arr_len == 33);
60373         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
60374         LDKCVec_RouteHintZ route_hints_constr;
60375         route_hints_constr.datalen = route_hints->arr_len;
60376         if (route_hints_constr.datalen > 0)
60377                 route_hints_constr.data = MALLOC(route_hints_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
60378         else
60379                 route_hints_constr.data = NULL;
60380         int64_t* route_hints_vals = route_hints->elems;
60381         for (size_t l = 0; l < route_hints_constr.datalen; l++) {
60382                 int64_t route_hints_conv_11 = route_hints_vals[l];
60383                 LDKRouteHint route_hints_conv_11_conv;
60384                 route_hints_conv_11_conv.inner = untag_ptr(route_hints_conv_11);
60385                 route_hints_conv_11_conv.is_owned = ptr_is_owned(route_hints_conv_11);
60386                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_conv_11_conv);
60387                 route_hints_conv_11_conv = RouteHint_clone(&route_hints_conv_11_conv);
60388                 route_hints_constr.data[l] = route_hints_conv_11_conv;
60389         }
60390         FREE(route_hints);
60391         LDKBolt11InvoiceFeatures features_conv;
60392         features_conv.inner = untag_ptr(features);
60393         features_conv.is_owned = ptr_is_owned(features);
60394         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
60395         features_conv = Bolt11InvoiceFeatures_clone(&features_conv);
60396         LDKPayee *ret_copy = MALLOC(sizeof(LDKPayee), "LDKPayee");
60397         *ret_copy = Payee_clear(node_id_ref, route_hints_constr, features_conv, final_cltv_expiry_delta);
60398         int64_t ret_ref = tag_ptr(ret_copy, true);
60399         return ret_ref;
60400 }
60401
60402 int64_t  CS_LDK_Payee_hash(int64_t o) {
60403         LDKPayee* o_conv = (LDKPayee*)untag_ptr(o);
60404         int64_t ret_conv = Payee_hash(o_conv);
60405         return ret_conv;
60406 }
60407
60408 jboolean  CS_LDK_Payee_eq(int64_t a, int64_t b) {
60409         LDKPayee* a_conv = (LDKPayee*)untag_ptr(a);
60410         LDKPayee* b_conv = (LDKPayee*)untag_ptr(b);
60411         jboolean ret_conv = Payee_eq(a_conv, b_conv);
60412         return ret_conv;
60413 }
60414
60415 void  CS_LDK_RouteHint_free(int64_t this_obj) {
60416         LDKRouteHint this_obj_conv;
60417         this_obj_conv.inner = untag_ptr(this_obj);
60418         this_obj_conv.is_owned = ptr_is_owned(this_obj);
60419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
60420         RouteHint_free(this_obj_conv);
60421 }
60422
60423 int64_tArray  CS_LDK_RouteHint_get_a(int64_t this_ptr) {
60424         LDKRouteHint this_ptr_conv;
60425         this_ptr_conv.inner = untag_ptr(this_ptr);
60426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60428         this_ptr_conv.is_owned = false;
60429         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
60430         int64_tArray ret_arr = NULL;
60431         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
60432         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
60433         for (size_t o = 0; o < ret_var.datalen; o++) {
60434                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
60435                 int64_t ret_conv_14_ref = 0;
60436                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
60437                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
60438                 ret_arr_ptr[o] = ret_conv_14_ref;
60439         }
60440         
60441         FREE(ret_var.data);
60442         return ret_arr;
60443 }
60444
60445 void  CS_LDK_RouteHint_set_a(int64_t this_ptr, int64_tArray val) {
60446         LDKRouteHint this_ptr_conv;
60447         this_ptr_conv.inner = untag_ptr(this_ptr);
60448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60450         this_ptr_conv.is_owned = false;
60451         LDKCVec_RouteHintHopZ val_constr;
60452         val_constr.datalen = val->arr_len;
60453         if (val_constr.datalen > 0)
60454                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
60455         else
60456                 val_constr.data = NULL;
60457         int64_t* val_vals = val->elems;
60458         for (size_t o = 0; o < val_constr.datalen; o++) {
60459                 int64_t val_conv_14 = val_vals[o];
60460                 LDKRouteHintHop val_conv_14_conv;
60461                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
60462                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
60463                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
60464                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
60465                 val_constr.data[o] = val_conv_14_conv;
60466         }
60467         FREE(val);
60468         RouteHint_set_a(&this_ptr_conv, val_constr);
60469 }
60470
60471 int64_t  CS_LDK_RouteHint_new(int64_tArray a_arg) {
60472         LDKCVec_RouteHintHopZ a_arg_constr;
60473         a_arg_constr.datalen = a_arg->arr_len;
60474         if (a_arg_constr.datalen > 0)
60475                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
60476         else
60477                 a_arg_constr.data = NULL;
60478         int64_t* a_arg_vals = a_arg->elems;
60479         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
60480                 int64_t a_arg_conv_14 = a_arg_vals[o];
60481                 LDKRouteHintHop a_arg_conv_14_conv;
60482                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
60483                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
60484                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
60485                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
60486                 a_arg_constr.data[o] = a_arg_conv_14_conv;
60487         }
60488         FREE(a_arg);
60489         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
60490         int64_t ret_ref = 0;
60491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60493         return ret_ref;
60494 }
60495
60496 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
60497         LDKRouteHint ret_var = RouteHint_clone(arg);
60498         int64_t ret_ref = 0;
60499         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60500         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60501         return ret_ref;
60502 }
60503 int64_t  CS_LDK_RouteHint_clone_ptr(int64_t arg) {
60504         LDKRouteHint arg_conv;
60505         arg_conv.inner = untag_ptr(arg);
60506         arg_conv.is_owned = ptr_is_owned(arg);
60507         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
60508         arg_conv.is_owned = false;
60509         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
60510         return ret_conv;
60511 }
60512
60513 int64_t  CS_LDK_RouteHint_clone(int64_t orig) {
60514         LDKRouteHint orig_conv;
60515         orig_conv.inner = untag_ptr(orig);
60516         orig_conv.is_owned = ptr_is_owned(orig);
60517         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
60518         orig_conv.is_owned = false;
60519         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
60520         int64_t ret_ref = 0;
60521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60523         return ret_ref;
60524 }
60525
60526 int64_t  CS_LDK_RouteHint_hash(int64_t o) {
60527         LDKRouteHint o_conv;
60528         o_conv.inner = untag_ptr(o);
60529         o_conv.is_owned = ptr_is_owned(o);
60530         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
60531         o_conv.is_owned = false;
60532         int64_t ret_conv = RouteHint_hash(&o_conv);
60533         return ret_conv;
60534 }
60535
60536 jboolean  CS_LDK_RouteHint_eq(int64_t a, int64_t b) {
60537         LDKRouteHint a_conv;
60538         a_conv.inner = untag_ptr(a);
60539         a_conv.is_owned = ptr_is_owned(a);
60540         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
60541         a_conv.is_owned = false;
60542         LDKRouteHint b_conv;
60543         b_conv.inner = untag_ptr(b);
60544         b_conv.is_owned = ptr_is_owned(b);
60545         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
60546         b_conv.is_owned = false;
60547         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
60548         return ret_conv;
60549 }
60550
60551 int8_tArray  CS_LDK_RouteHint_write(int64_t obj) {
60552         LDKRouteHint obj_conv;
60553         obj_conv.inner = untag_ptr(obj);
60554         obj_conv.is_owned = ptr_is_owned(obj);
60555         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
60556         obj_conv.is_owned = false;
60557         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
60558         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
60559         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
60560         CVec_u8Z_free(ret_var);
60561         return ret_arr;
60562 }
60563
60564 int64_t  CS_LDK_RouteHint_read(int8_tArray ser) {
60565         LDKu8slice ser_ref;
60566         ser_ref.datalen = ser->arr_len;
60567         ser_ref.data = ser->elems;
60568         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
60569         *ret_conv = RouteHint_read(ser_ref);
60570         FREE(ser);
60571         return tag_ptr(ret_conv, true);
60572 }
60573
60574 void  CS_LDK_RouteHintHop_free(int64_t this_obj) {
60575         LDKRouteHintHop this_obj_conv;
60576         this_obj_conv.inner = untag_ptr(this_obj);
60577         this_obj_conv.is_owned = ptr_is_owned(this_obj);
60578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
60579         RouteHintHop_free(this_obj_conv);
60580 }
60581
60582 int8_tArray  CS_LDK_RouteHintHop_get_src_node_id(int64_t this_ptr) {
60583         LDKRouteHintHop this_ptr_conv;
60584         this_ptr_conv.inner = untag_ptr(this_ptr);
60585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60587         this_ptr_conv.is_owned = false;
60588         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
60589         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
60590         return ret_arr;
60591 }
60592
60593 void  CS_LDK_RouteHintHop_set_src_node_id(int64_t this_ptr, int8_tArray val) {
60594         LDKRouteHintHop this_ptr_conv;
60595         this_ptr_conv.inner = untag_ptr(this_ptr);
60596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60598         this_ptr_conv.is_owned = false;
60599         LDKPublicKey val_ref;
60600         CHECK(val->arr_len == 33);
60601         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
60602         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
60603 }
60604
60605 int64_t  CS_LDK_RouteHintHop_get_short_channel_id(int64_t this_ptr) {
60606         LDKRouteHintHop this_ptr_conv;
60607         this_ptr_conv.inner = untag_ptr(this_ptr);
60608         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60610         this_ptr_conv.is_owned = false;
60611         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
60612         return ret_conv;
60613 }
60614
60615 void  CS_LDK_RouteHintHop_set_short_channel_id(int64_t this_ptr, int64_t val) {
60616         LDKRouteHintHop this_ptr_conv;
60617         this_ptr_conv.inner = untag_ptr(this_ptr);
60618         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60620         this_ptr_conv.is_owned = false;
60621         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
60622 }
60623
60624 int64_t  CS_LDK_RouteHintHop_get_fees(int64_t this_ptr) {
60625         LDKRouteHintHop this_ptr_conv;
60626         this_ptr_conv.inner = untag_ptr(this_ptr);
60627         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60629         this_ptr_conv.is_owned = false;
60630         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
60631         int64_t ret_ref = 0;
60632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60634         return ret_ref;
60635 }
60636
60637 void  CS_LDK_RouteHintHop_set_fees(int64_t this_ptr, int64_t val) {
60638         LDKRouteHintHop this_ptr_conv;
60639         this_ptr_conv.inner = untag_ptr(this_ptr);
60640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60642         this_ptr_conv.is_owned = false;
60643         LDKRoutingFees val_conv;
60644         val_conv.inner = untag_ptr(val);
60645         val_conv.is_owned = ptr_is_owned(val);
60646         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
60647         val_conv = RoutingFees_clone(&val_conv);
60648         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
60649 }
60650
60651 int16_t  CS_LDK_RouteHintHop_get_cltv_expiry_delta(int64_t this_ptr) {
60652         LDKRouteHintHop this_ptr_conv;
60653         this_ptr_conv.inner = untag_ptr(this_ptr);
60654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60656         this_ptr_conv.is_owned = false;
60657         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
60658         return ret_conv;
60659 }
60660
60661 void  CS_LDK_RouteHintHop_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
60662         LDKRouteHintHop this_ptr_conv;
60663         this_ptr_conv.inner = untag_ptr(this_ptr);
60664         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60666         this_ptr_conv.is_owned = false;
60667         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
60668 }
60669
60670 int64_t  CS_LDK_RouteHintHop_get_htlc_minimum_msat(int64_t this_ptr) {
60671         LDKRouteHintHop this_ptr_conv;
60672         this_ptr_conv.inner = untag_ptr(this_ptr);
60673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60675         this_ptr_conv.is_owned = false;
60676         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
60677         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
60678         int64_t ret_ref = tag_ptr(ret_copy, true);
60679         return ret_ref;
60680 }
60681
60682 void  CS_LDK_RouteHintHop_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
60683         LDKRouteHintHop this_ptr_conv;
60684         this_ptr_conv.inner = untag_ptr(this_ptr);
60685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60687         this_ptr_conv.is_owned = false;
60688         void* val_ptr = untag_ptr(val);
60689         CHECK_ACCESS(val_ptr);
60690         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
60691         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
60692         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
60693 }
60694
60695 int64_t  CS_LDK_RouteHintHop_get_htlc_maximum_msat(int64_t this_ptr) {
60696         LDKRouteHintHop this_ptr_conv;
60697         this_ptr_conv.inner = untag_ptr(this_ptr);
60698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60700         this_ptr_conv.is_owned = false;
60701         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
60702         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
60703         int64_t ret_ref = tag_ptr(ret_copy, true);
60704         return ret_ref;
60705 }
60706
60707 void  CS_LDK_RouteHintHop_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
60708         LDKRouteHintHop this_ptr_conv;
60709         this_ptr_conv.inner = untag_ptr(this_ptr);
60710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
60711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
60712         this_ptr_conv.is_owned = false;
60713         void* val_ptr = untag_ptr(val);
60714         CHECK_ACCESS(val_ptr);
60715         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
60716         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
60717         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
60718 }
60719
60720 int64_t  CS_LDK_RouteHintHop_new(int8_tArray src_node_id_arg, int64_t short_channel_id_arg, int64_t fees_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg) {
60721         LDKPublicKey src_node_id_arg_ref;
60722         CHECK(src_node_id_arg->arr_len == 33);
60723         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
60724         LDKRoutingFees fees_arg_conv;
60725         fees_arg_conv.inner = untag_ptr(fees_arg);
60726         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
60727         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
60728         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
60729         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
60730         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
60731         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
60732         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
60733         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
60734         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
60735         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
60736         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
60737         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);
60738         int64_t ret_ref = 0;
60739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60740         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60741         return ret_ref;
60742 }
60743
60744 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
60745         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
60746         int64_t ret_ref = 0;
60747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60749         return ret_ref;
60750 }
60751 int64_t  CS_LDK_RouteHintHop_clone_ptr(int64_t arg) {
60752         LDKRouteHintHop arg_conv;
60753         arg_conv.inner = untag_ptr(arg);
60754         arg_conv.is_owned = ptr_is_owned(arg);
60755         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
60756         arg_conv.is_owned = false;
60757         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
60758         return ret_conv;
60759 }
60760
60761 int64_t  CS_LDK_RouteHintHop_clone(int64_t orig) {
60762         LDKRouteHintHop orig_conv;
60763         orig_conv.inner = untag_ptr(orig);
60764         orig_conv.is_owned = ptr_is_owned(orig);
60765         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
60766         orig_conv.is_owned = false;
60767         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
60768         int64_t ret_ref = 0;
60769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
60770         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
60771         return ret_ref;
60772 }
60773
60774 int64_t  CS_LDK_RouteHintHop_hash(int64_t o) {
60775         LDKRouteHintHop o_conv;
60776         o_conv.inner = untag_ptr(o);
60777         o_conv.is_owned = ptr_is_owned(o);
60778         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
60779         o_conv.is_owned = false;
60780         int64_t ret_conv = RouteHintHop_hash(&o_conv);
60781         return ret_conv;
60782 }
60783
60784 jboolean  CS_LDK_RouteHintHop_eq(int64_t a, int64_t b) {
60785         LDKRouteHintHop a_conv;
60786         a_conv.inner = untag_ptr(a);
60787         a_conv.is_owned = ptr_is_owned(a);
60788         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
60789         a_conv.is_owned = false;
60790         LDKRouteHintHop b_conv;
60791         b_conv.inner = untag_ptr(b);
60792         b_conv.is_owned = ptr_is_owned(b);
60793         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
60794         b_conv.is_owned = false;
60795         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
60796         return ret_conv;
60797 }
60798
60799 int8_tArray  CS_LDK_RouteHintHop_write(int64_t obj) {
60800         LDKRouteHintHop obj_conv;
60801         obj_conv.inner = untag_ptr(obj);
60802         obj_conv.is_owned = ptr_is_owned(obj);
60803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
60804         obj_conv.is_owned = false;
60805         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
60806         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
60807         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
60808         CVec_u8Z_free(ret_var);
60809         return ret_arr;
60810 }
60811
60812 int64_t  CS_LDK_RouteHintHop_read(int8_tArray ser) {
60813         LDKu8slice ser_ref;
60814         ser_ref.datalen = ser->arr_len;
60815         ser_ref.data = ser->elems;
60816         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
60817         *ret_conv = RouteHintHop_read(ser_ref);
60818         FREE(ser);
60819         return tag_ptr(ret_conv, true);
60820 }
60821
60822 int64_t  CS_LDK_find_route(int8_tArray our_node_pubkey, int64_t route_params, int64_t network_graph, int64_tArray first_hops, int64_t logger, int64_t scorer, int64_t score_params, int8_tArray random_seed_bytes) {
60823         LDKPublicKey our_node_pubkey_ref;
60824         CHECK(our_node_pubkey->arr_len == 33);
60825         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
60826         LDKRouteParameters route_params_conv;
60827         route_params_conv.inner = untag_ptr(route_params);
60828         route_params_conv.is_owned = ptr_is_owned(route_params);
60829         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
60830         route_params_conv.is_owned = false;
60831         LDKNetworkGraph network_graph_conv;
60832         network_graph_conv.inner = untag_ptr(network_graph);
60833         network_graph_conv.is_owned = ptr_is_owned(network_graph);
60834         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
60835         network_graph_conv.is_owned = false;
60836         LDKCVec_ChannelDetailsZ first_hops_constr;
60837         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
60838         if (first_hops != NULL) {
60839                 first_hops_constr.datalen = first_hops->arr_len;
60840                 if (first_hops_constr.datalen > 0)
60841                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
60842                 else
60843                         first_hops_constr.data = NULL;
60844                 int64_t* first_hops_vals = first_hops->elems;
60845                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
60846                         int64_t first_hops_conv_16 = first_hops_vals[q];
60847                         LDKChannelDetails first_hops_conv_16_conv;
60848                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
60849                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
60850                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
60851                         first_hops_conv_16_conv.is_owned = false;
60852                         first_hops_constr.data[q] = first_hops_conv_16_conv;
60853                 }
60854                 FREE(first_hops);
60855                 first_hops_ptr = &first_hops_constr;
60856         }
60857         void* logger_ptr = untag_ptr(logger);
60858         CHECK_ACCESS(logger_ptr);
60859         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
60860         if (logger_conv.free == LDKLogger_JCalls_free) {
60861                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
60862                 LDKLogger_JCalls_cloned(&logger_conv);
60863         }
60864         void* scorer_ptr = untag_ptr(scorer);
60865         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
60866         LDKScoreLookUp* scorer_conv = (LDKScoreLookUp*)scorer_ptr;
60867         LDKProbabilisticScoringFeeParameters score_params_conv;
60868         score_params_conv.inner = untag_ptr(score_params);
60869         score_params_conv.is_owned = ptr_is_owned(score_params);
60870         CHECK_INNER_FIELD_ACCESS_OR_NULL(score_params_conv);
60871         score_params_conv.is_owned = false;
60872         uint8_t random_seed_bytes_arr[32];
60873         CHECK(random_seed_bytes->arr_len == 32);
60874         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
60875         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
60876         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
60877         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, &score_params_conv, random_seed_bytes_ref);
60878         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
60879         return tag_ptr(ret_conv, true);
60880 }
60881
60882 int64_t  CS_LDK_build_route_from_hops(int8_tArray our_node_pubkey, ptrArray hops, int64_t route_params, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
60883         LDKPublicKey our_node_pubkey_ref;
60884         CHECK(our_node_pubkey->arr_len == 33);
60885         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
60886         LDKCVec_PublicKeyZ hops_constr;
60887         hops_constr.datalen = hops->arr_len;
60888         if (hops_constr.datalen > 0)
60889                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
60890         else
60891                 hops_constr.data = NULL;
60892         int8_tArray* hops_vals = (void*) hops->elems;
60893         for (size_t i = 0; i < hops_constr.datalen; i++) {
60894                 int8_tArray hops_conv_8 = hops_vals[i];
60895                 LDKPublicKey hops_conv_8_ref;
60896                 CHECK(hops_conv_8->arr_len == 33);
60897                 memcpy(hops_conv_8_ref.compressed_form, hops_conv_8->elems, 33); FREE(hops_conv_8);
60898                 hops_constr.data[i] = hops_conv_8_ref;
60899         }
60900         FREE(hops);
60901         LDKRouteParameters route_params_conv;
60902         route_params_conv.inner = untag_ptr(route_params);
60903         route_params_conv.is_owned = ptr_is_owned(route_params);
60904         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
60905         route_params_conv.is_owned = false;
60906         LDKNetworkGraph network_graph_conv;
60907         network_graph_conv.inner = untag_ptr(network_graph);
60908         network_graph_conv.is_owned = ptr_is_owned(network_graph);
60909         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
60910         network_graph_conv.is_owned = false;
60911         void* logger_ptr = untag_ptr(logger);
60912         CHECK_ACCESS(logger_ptr);
60913         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
60914         if (logger_conv.free == LDKLogger_JCalls_free) {
60915                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
60916                 LDKLogger_JCalls_cloned(&logger_conv);
60917         }
60918         uint8_t random_seed_bytes_arr[32];
60919         CHECK(random_seed_bytes->arr_len == 32);
60920         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
60921         uint8_t (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
60922         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
60923         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
60924         return tag_ptr(ret_conv, true);
60925 }
60926
60927 void  CS_LDK_ScoreLookUp_free(int64_t this_ptr) {
60928         if (!ptr_is_owned(this_ptr)) return;
60929         void* this_ptr_ptr = untag_ptr(this_ptr);
60930         CHECK_ACCESS(this_ptr_ptr);
60931         LDKScoreLookUp this_ptr_conv = *(LDKScoreLookUp*)(this_ptr_ptr);
60932         FREE(untag_ptr(this_ptr));
60933         ScoreLookUp_free(this_ptr_conv);
60934 }
60935
60936 void  CS_LDK_ScoreUpdate_free(int64_t this_ptr) {
60937         if (!ptr_is_owned(this_ptr)) return;
60938         void* this_ptr_ptr = untag_ptr(this_ptr);
60939         CHECK_ACCESS(this_ptr_ptr);
60940         LDKScoreUpdate this_ptr_conv = *(LDKScoreUpdate*)(this_ptr_ptr);
60941         FREE(untag_ptr(this_ptr));
60942         ScoreUpdate_free(this_ptr_conv);
60943 }
60944
60945 void  CS_LDK_Score_free(int64_t this_ptr) {
60946         if (!ptr_is_owned(this_ptr)) return;
60947         void* this_ptr_ptr = untag_ptr(this_ptr);
60948         CHECK_ACCESS(this_ptr_ptr);
60949         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
60950         FREE(untag_ptr(this_ptr));
60951         Score_free(this_ptr_conv);
60952 }
60953
60954 void  CS_LDK_LockableScore_free(int64_t this_ptr) {
60955         if (!ptr_is_owned(this_ptr)) return;
60956         void* this_ptr_ptr = untag_ptr(this_ptr);
60957         CHECK_ACCESS(this_ptr_ptr);
60958         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
60959         FREE(untag_ptr(this_ptr));
60960         LockableScore_free(this_ptr_conv);
60961 }
60962
60963 void  CS_LDK_WriteableScore_free(int64_t this_ptr) {
60964         if (!ptr_is_owned(this_ptr)) return;
60965         void* this_ptr_ptr = untag_ptr(this_ptr);
60966         CHECK_ACCESS(this_ptr_ptr);
60967         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
60968         FREE(untag_ptr(this_ptr));
60969         WriteableScore_free(this_ptr_conv);
60970 }
60971
60972 void  CS_LDK_MultiThreadedLockableScore_free(int64_t this_obj) {
60973         LDKMultiThreadedLockableScore this_obj_conv;
60974         this_obj_conv.inner = untag_ptr(this_obj);
60975         this_obj_conv.is_owned = ptr_is_owned(this_obj);
60976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
60977         MultiThreadedLockableScore_free(this_obj_conv);
60978 }
60979
60980 int64_t  CS_LDK_MultiThreadedLockableScore_as_LockableScore(int64_t this_arg) {
60981         LDKMultiThreadedLockableScore this_arg_conv;
60982         this_arg_conv.inner = untag_ptr(this_arg);
60983         this_arg_conv.is_owned = ptr_is_owned(this_arg);
60984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
60985         this_arg_conv.is_owned = false;
60986         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
60987         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
60988         return tag_ptr(ret_ret, true);
60989 }
60990
60991 int8_tArray  CS_LDK_MultiThreadedLockableScore_write(int64_t obj) {
60992         LDKMultiThreadedLockableScore obj_conv;
60993         obj_conv.inner = untag_ptr(obj);
60994         obj_conv.is_owned = ptr_is_owned(obj);
60995         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
60996         obj_conv.is_owned = false;
60997         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
60998         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
60999         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61000         CVec_u8Z_free(ret_var);
61001         return ret_arr;
61002 }
61003
61004 int64_t  CS_LDK_MultiThreadedLockableScore_as_WriteableScore(int64_t this_arg) {
61005         LDKMultiThreadedLockableScore this_arg_conv;
61006         this_arg_conv.inner = untag_ptr(this_arg);
61007         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61009         this_arg_conv.is_owned = false;
61010         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
61011         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
61012         return tag_ptr(ret_ret, true);
61013 }
61014
61015 int64_t  CS_LDK_MultiThreadedLockableScore_new(int64_t score) {
61016         void* score_ptr = untag_ptr(score);
61017         CHECK_ACCESS(score_ptr);
61018         LDKScore score_conv = *(LDKScore*)(score_ptr);
61019         if (score_conv.free == LDKScore_JCalls_free) {
61020                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
61021                 LDKScore_JCalls_cloned(&score_conv);
61022         }
61023         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
61024         int64_t ret_ref = 0;
61025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61027         return ret_ref;
61028 }
61029
61030 void  CS_LDK_MultiThreadedScoreLockRead_free(int64_t this_obj) {
61031         LDKMultiThreadedScoreLockRead this_obj_conv;
61032         this_obj_conv.inner = untag_ptr(this_obj);
61033         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61035         MultiThreadedScoreLockRead_free(this_obj_conv);
61036 }
61037
61038 void  CS_LDK_MultiThreadedScoreLockWrite_free(int64_t this_obj) {
61039         LDKMultiThreadedScoreLockWrite this_obj_conv;
61040         this_obj_conv.inner = untag_ptr(this_obj);
61041         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61043         MultiThreadedScoreLockWrite_free(this_obj_conv);
61044 }
61045
61046 int64_t  CS_LDK_MultiThreadedScoreLockRead_as_ScoreLookUp(int64_t this_arg) {
61047         LDKMultiThreadedScoreLockRead this_arg_conv;
61048         this_arg_conv.inner = untag_ptr(this_arg);
61049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61051         this_arg_conv.is_owned = false;
61052         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
61053         *ret_ret = MultiThreadedScoreLockRead_as_ScoreLookUp(&this_arg_conv);
61054         return tag_ptr(ret_ret, true);
61055 }
61056
61057 int8_tArray  CS_LDK_MultiThreadedScoreLockWrite_write(int64_t obj) {
61058         LDKMultiThreadedScoreLockWrite obj_conv;
61059         obj_conv.inner = untag_ptr(obj);
61060         obj_conv.is_owned = ptr_is_owned(obj);
61061         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
61062         obj_conv.is_owned = false;
61063         LDKCVec_u8Z ret_var = MultiThreadedScoreLockWrite_write(&obj_conv);
61064         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
61065         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61066         CVec_u8Z_free(ret_var);
61067         return ret_arr;
61068 }
61069
61070 int64_t  CS_LDK_MultiThreadedScoreLockWrite_as_ScoreUpdate(int64_t this_arg) {
61071         LDKMultiThreadedScoreLockWrite this_arg_conv;
61072         this_arg_conv.inner = untag_ptr(this_arg);
61073         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61075         this_arg_conv.is_owned = false;
61076         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
61077         *ret_ret = MultiThreadedScoreLockWrite_as_ScoreUpdate(&this_arg_conv);
61078         return tag_ptr(ret_ret, true);
61079 }
61080
61081 void  CS_LDK_ChannelUsage_free(int64_t this_obj) {
61082         LDKChannelUsage this_obj_conv;
61083         this_obj_conv.inner = untag_ptr(this_obj);
61084         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61086         ChannelUsage_free(this_obj_conv);
61087 }
61088
61089 int64_t  CS_LDK_ChannelUsage_get_amount_msat(int64_t this_ptr) {
61090         LDKChannelUsage this_ptr_conv;
61091         this_ptr_conv.inner = untag_ptr(this_ptr);
61092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61094         this_ptr_conv.is_owned = false;
61095         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
61096         return ret_conv;
61097 }
61098
61099 void  CS_LDK_ChannelUsage_set_amount_msat(int64_t this_ptr, int64_t val) {
61100         LDKChannelUsage this_ptr_conv;
61101         this_ptr_conv.inner = untag_ptr(this_ptr);
61102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61104         this_ptr_conv.is_owned = false;
61105         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
61106 }
61107
61108 int64_t  CS_LDK_ChannelUsage_get_inflight_htlc_msat(int64_t this_ptr) {
61109         LDKChannelUsage this_ptr_conv;
61110         this_ptr_conv.inner = untag_ptr(this_ptr);
61111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61113         this_ptr_conv.is_owned = false;
61114         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
61115         return ret_conv;
61116 }
61117
61118 void  CS_LDK_ChannelUsage_set_inflight_htlc_msat(int64_t this_ptr, int64_t val) {
61119         LDKChannelUsage this_ptr_conv;
61120         this_ptr_conv.inner = untag_ptr(this_ptr);
61121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61123         this_ptr_conv.is_owned = false;
61124         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
61125 }
61126
61127 int64_t  CS_LDK_ChannelUsage_get_effective_capacity(int64_t this_ptr) {
61128         LDKChannelUsage this_ptr_conv;
61129         this_ptr_conv.inner = untag_ptr(this_ptr);
61130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61132         this_ptr_conv.is_owned = false;
61133         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
61134         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
61135         int64_t ret_ref = tag_ptr(ret_copy, true);
61136         return ret_ref;
61137 }
61138
61139 void  CS_LDK_ChannelUsage_set_effective_capacity(int64_t this_ptr, int64_t val) {
61140         LDKChannelUsage this_ptr_conv;
61141         this_ptr_conv.inner = untag_ptr(this_ptr);
61142         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61144         this_ptr_conv.is_owned = false;
61145         void* val_ptr = untag_ptr(val);
61146         CHECK_ACCESS(val_ptr);
61147         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
61148         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
61149         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
61150 }
61151
61152 int64_t  CS_LDK_ChannelUsage_new(int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
61153         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
61154         CHECK_ACCESS(effective_capacity_arg_ptr);
61155         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
61156         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
61157         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
61158         int64_t ret_ref = 0;
61159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61160         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61161         return ret_ref;
61162 }
61163
61164 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
61165         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
61166         int64_t ret_ref = 0;
61167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61169         return ret_ref;
61170 }
61171 int64_t  CS_LDK_ChannelUsage_clone_ptr(int64_t arg) {
61172         LDKChannelUsage arg_conv;
61173         arg_conv.inner = untag_ptr(arg);
61174         arg_conv.is_owned = ptr_is_owned(arg);
61175         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61176         arg_conv.is_owned = false;
61177         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
61178         return ret_conv;
61179 }
61180
61181 int64_t  CS_LDK_ChannelUsage_clone(int64_t orig) {
61182         LDKChannelUsage orig_conv;
61183         orig_conv.inner = untag_ptr(orig);
61184         orig_conv.is_owned = ptr_is_owned(orig);
61185         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61186         orig_conv.is_owned = false;
61187         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
61188         int64_t ret_ref = 0;
61189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61190         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61191         return ret_ref;
61192 }
61193
61194 void  CS_LDK_FixedPenaltyScorer_free(int64_t this_obj) {
61195         LDKFixedPenaltyScorer this_obj_conv;
61196         this_obj_conv.inner = untag_ptr(this_obj);
61197         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61199         FixedPenaltyScorer_free(this_obj_conv);
61200 }
61201
61202 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
61203         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
61204         int64_t ret_ref = 0;
61205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61206         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61207         return ret_ref;
61208 }
61209 int64_t  CS_LDK_FixedPenaltyScorer_clone_ptr(int64_t arg) {
61210         LDKFixedPenaltyScorer arg_conv;
61211         arg_conv.inner = untag_ptr(arg);
61212         arg_conv.is_owned = ptr_is_owned(arg);
61213         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61214         arg_conv.is_owned = false;
61215         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
61216         return ret_conv;
61217 }
61218
61219 int64_t  CS_LDK_FixedPenaltyScorer_clone(int64_t orig) {
61220         LDKFixedPenaltyScorer orig_conv;
61221         orig_conv.inner = untag_ptr(orig);
61222         orig_conv.is_owned = ptr_is_owned(orig);
61223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61224         orig_conv.is_owned = false;
61225         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
61226         int64_t ret_ref = 0;
61227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61229         return ret_ref;
61230 }
61231
61232 int64_t  CS_LDK_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
61233         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
61234         int64_t ret_ref = 0;
61235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61237         return ret_ref;
61238 }
61239
61240 int64_t  CS_LDK_FixedPenaltyScorer_as_ScoreLookUp(int64_t this_arg) {
61241         LDKFixedPenaltyScorer this_arg_conv;
61242         this_arg_conv.inner = untag_ptr(this_arg);
61243         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61245         this_arg_conv.is_owned = false;
61246         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
61247         *ret_ret = FixedPenaltyScorer_as_ScoreLookUp(&this_arg_conv);
61248         return tag_ptr(ret_ret, true);
61249 }
61250
61251 int64_t  CS_LDK_FixedPenaltyScorer_as_ScoreUpdate(int64_t this_arg) {
61252         LDKFixedPenaltyScorer this_arg_conv;
61253         this_arg_conv.inner = untag_ptr(this_arg);
61254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61256         this_arg_conv.is_owned = false;
61257         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
61258         *ret_ret = FixedPenaltyScorer_as_ScoreUpdate(&this_arg_conv);
61259         return tag_ptr(ret_ret, true);
61260 }
61261
61262 int8_tArray  CS_LDK_FixedPenaltyScorer_write(int64_t obj) {
61263         LDKFixedPenaltyScorer obj_conv;
61264         obj_conv.inner = untag_ptr(obj);
61265         obj_conv.is_owned = ptr_is_owned(obj);
61266         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
61267         obj_conv.is_owned = false;
61268         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
61269         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
61270         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61271         CVec_u8Z_free(ret_var);
61272         return ret_arr;
61273 }
61274
61275 int64_t  CS_LDK_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
61276         LDKu8slice ser_ref;
61277         ser_ref.datalen = ser->arr_len;
61278         ser_ref.data = ser->elems;
61279         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
61280         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
61281         FREE(ser);
61282         return tag_ptr(ret_conv, true);
61283 }
61284
61285 void  CS_LDK_ProbabilisticScorer_free(int64_t this_obj) {
61286         LDKProbabilisticScorer this_obj_conv;
61287         this_obj_conv.inner = untag_ptr(this_obj);
61288         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61290         ProbabilisticScorer_free(this_obj_conv);
61291 }
61292
61293 void  CS_LDK_ProbabilisticScoringFeeParameters_free(int64_t this_obj) {
61294         LDKProbabilisticScoringFeeParameters this_obj_conv;
61295         this_obj_conv.inner = untag_ptr(this_obj);
61296         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61298         ProbabilisticScoringFeeParameters_free(this_obj_conv);
61299 }
61300
61301 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_base_penalty_msat(int64_t this_ptr) {
61302         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61303         this_ptr_conv.inner = untag_ptr(this_ptr);
61304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61306         this_ptr_conv.is_owned = false;
61307         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_base_penalty_msat(&this_ptr_conv);
61308         return ret_conv;
61309 }
61310
61311 void  CS_LDK_ProbabilisticScoringFeeParameters_set_base_penalty_msat(int64_t this_ptr, int64_t val) {
61312         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61313         this_ptr_conv.inner = untag_ptr(this_ptr);
61314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61316         this_ptr_conv.is_owned = false;
61317         ProbabilisticScoringFeeParameters_set_base_penalty_msat(&this_ptr_conv, val);
61318 }
61319
61320 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(int64_t this_ptr) {
61321         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61322         this_ptr_conv.inner = untag_ptr(this_ptr);
61323         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61325         this_ptr_conv.is_owned = false;
61326         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
61327         return ret_conv;
61328 }
61329
61330 void  CS_LDK_ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(int64_t this_ptr, int64_t val) {
61331         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61332         this_ptr_conv.inner = untag_ptr(this_ptr);
61333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61335         this_ptr_conv.is_owned = false;
61336         ProbabilisticScoringFeeParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
61337 }
61338
61339 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(int64_t this_ptr) {
61340         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61341         this_ptr_conv.inner = untag_ptr(this_ptr);
61342         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61344         this_ptr_conv.is_owned = false;
61345         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
61346         return ret_conv;
61347 }
61348
61349 void  CS_LDK_ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(int64_t this_ptr, int64_t val) {
61350         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61351         this_ptr_conv.inner = untag_ptr(this_ptr);
61352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61354         this_ptr_conv.is_owned = false;
61355         ProbabilisticScoringFeeParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
61356 }
61357
61358 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr) {
61359         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61360         this_ptr_conv.inner = untag_ptr(this_ptr);
61361         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61363         this_ptr_conv.is_owned = false;
61364         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
61365         return ret_conv;
61366 }
61367
61368 void  CS_LDK_ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr, int64_t val) {
61369         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61370         this_ptr_conv.inner = untag_ptr(this_ptr);
61371         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61373         this_ptr_conv.is_owned = false;
61374         ProbabilisticScoringFeeParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
61375 }
61376
61377 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(int64_t this_ptr) {
61378         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61379         this_ptr_conv.inner = untag_ptr(this_ptr);
61380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61382         this_ptr_conv.is_owned = false;
61383         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
61384         return ret_conv;
61385 }
61386
61387 void  CS_LDK_ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(int64_t this_ptr, int64_t val) {
61388         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61389         this_ptr_conv.inner = untag_ptr(this_ptr);
61390         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61392         this_ptr_conv.is_owned = false;
61393         ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
61394 }
61395
61396 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr) {
61397         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61398         this_ptr_conv.inner = untag_ptr(this_ptr);
61399         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61401         this_ptr_conv.is_owned = false;
61402         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
61403         return ret_conv;
61404 }
61405
61406 void  CS_LDK_ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(int64_t this_ptr, int64_t val) {
61407         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61408         this_ptr_conv.inner = untag_ptr(this_ptr);
61409         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61411         this_ptr_conv.is_owned = false;
61412         ProbabilisticScoringFeeParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
61413 }
61414
61415 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(int64_t this_ptr) {
61416         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61417         this_ptr_conv.inner = untag_ptr(this_ptr);
61418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61420         this_ptr_conv.is_owned = false;
61421         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
61422         return ret_conv;
61423 }
61424
61425 void  CS_LDK_ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(int64_t this_ptr, int64_t val) {
61426         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61427         this_ptr_conv.inner = untag_ptr(this_ptr);
61428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61430         this_ptr_conv.is_owned = false;
61431         ProbabilisticScoringFeeParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
61432 }
61433
61434 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(int64_t this_ptr) {
61435         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61436         this_ptr_conv.inner = untag_ptr(this_ptr);
61437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61439         this_ptr_conv.is_owned = false;
61440         int64_t ret_conv = ProbabilisticScoringFeeParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
61441         return ret_conv;
61442 }
61443
61444 void  CS_LDK_ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(int64_t this_ptr, int64_t val) {
61445         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61446         this_ptr_conv.inner = untag_ptr(this_ptr);
61447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61449         this_ptr_conv.is_owned = false;
61450         ProbabilisticScoringFeeParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
61451 }
61452
61453 jboolean  CS_LDK_ProbabilisticScoringFeeParameters_get_linear_success_probability(int64_t this_ptr) {
61454         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61455         this_ptr_conv.inner = untag_ptr(this_ptr);
61456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61458         this_ptr_conv.is_owned = false;
61459         jboolean ret_conv = ProbabilisticScoringFeeParameters_get_linear_success_probability(&this_ptr_conv);
61460         return ret_conv;
61461 }
61462
61463 void  CS_LDK_ProbabilisticScoringFeeParameters_set_linear_success_probability(int64_t this_ptr, jboolean val) {
61464         LDKProbabilisticScoringFeeParameters this_ptr_conv;
61465         this_ptr_conv.inner = untag_ptr(this_ptr);
61466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61468         this_ptr_conv.is_owned = false;
61469         ProbabilisticScoringFeeParameters_set_linear_success_probability(&this_ptr_conv, val);
61470 }
61471
61472 static inline uint64_t ProbabilisticScoringFeeParameters_clone_ptr(LDKProbabilisticScoringFeeParameters *NONNULL_PTR arg) {
61473         LDKProbabilisticScoringFeeParameters ret_var = ProbabilisticScoringFeeParameters_clone(arg);
61474         int64_t ret_ref = 0;
61475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61477         return ret_ref;
61478 }
61479 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_clone_ptr(int64_t arg) {
61480         LDKProbabilisticScoringFeeParameters arg_conv;
61481         arg_conv.inner = untag_ptr(arg);
61482         arg_conv.is_owned = ptr_is_owned(arg);
61483         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61484         arg_conv.is_owned = false;
61485         int64_t ret_conv = ProbabilisticScoringFeeParameters_clone_ptr(&arg_conv);
61486         return ret_conv;
61487 }
61488
61489 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_clone(int64_t orig) {
61490         LDKProbabilisticScoringFeeParameters orig_conv;
61491         orig_conv.inner = untag_ptr(orig);
61492         orig_conv.is_owned = ptr_is_owned(orig);
61493         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61494         orig_conv.is_owned = false;
61495         LDKProbabilisticScoringFeeParameters ret_var = ProbabilisticScoringFeeParameters_clone(&orig_conv);
61496         int64_t ret_ref = 0;
61497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61499         return ret_ref;
61500 }
61501
61502 int64_t  CS_LDK_ProbabilisticScoringFeeParameters_default() {
61503         LDKProbabilisticScoringFeeParameters ret_var = ProbabilisticScoringFeeParameters_default();
61504         int64_t ret_ref = 0;
61505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61507         return ret_ref;
61508 }
61509
61510 void  CS_LDK_ProbabilisticScoringFeeParameters_add_banned(int64_t this_arg, int64_t node_id) {
61511         LDKProbabilisticScoringFeeParameters this_arg_conv;
61512         this_arg_conv.inner = untag_ptr(this_arg);
61513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61515         this_arg_conv.is_owned = false;
61516         LDKNodeId node_id_conv;
61517         node_id_conv.inner = untag_ptr(node_id);
61518         node_id_conv.is_owned = ptr_is_owned(node_id);
61519         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61520         node_id_conv.is_owned = false;
61521         ProbabilisticScoringFeeParameters_add_banned(&this_arg_conv, &node_id_conv);
61522 }
61523
61524 void  CS_LDK_ProbabilisticScoringFeeParameters_add_banned_from_list(int64_t this_arg, int64_tArray node_ids) {
61525         LDKProbabilisticScoringFeeParameters this_arg_conv;
61526         this_arg_conv.inner = untag_ptr(this_arg);
61527         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61529         this_arg_conv.is_owned = false;
61530         LDKCVec_NodeIdZ node_ids_constr;
61531         node_ids_constr.datalen = node_ids->arr_len;
61532         if (node_ids_constr.datalen > 0)
61533                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
61534         else
61535                 node_ids_constr.data = NULL;
61536         int64_t* node_ids_vals = node_ids->elems;
61537         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
61538                 int64_t node_ids_conv_8 = node_ids_vals[i];
61539                 LDKNodeId node_ids_conv_8_conv;
61540                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
61541                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
61542                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
61543                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
61544                 node_ids_constr.data[i] = node_ids_conv_8_conv;
61545         }
61546         FREE(node_ids);
61547         ProbabilisticScoringFeeParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
61548 }
61549
61550 void  CS_LDK_ProbabilisticScoringFeeParameters_remove_banned(int64_t this_arg, int64_t node_id) {
61551         LDKProbabilisticScoringFeeParameters this_arg_conv;
61552         this_arg_conv.inner = untag_ptr(this_arg);
61553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61555         this_arg_conv.is_owned = false;
61556         LDKNodeId node_id_conv;
61557         node_id_conv.inner = untag_ptr(node_id);
61558         node_id_conv.is_owned = ptr_is_owned(node_id);
61559         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61560         node_id_conv.is_owned = false;
61561         ProbabilisticScoringFeeParameters_remove_banned(&this_arg_conv, &node_id_conv);
61562 }
61563
61564 void  CS_LDK_ProbabilisticScoringFeeParameters_set_manual_penalty(int64_t this_arg, int64_t node_id, int64_t penalty) {
61565         LDKProbabilisticScoringFeeParameters this_arg_conv;
61566         this_arg_conv.inner = untag_ptr(this_arg);
61567         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61569         this_arg_conv.is_owned = false;
61570         LDKNodeId node_id_conv;
61571         node_id_conv.inner = untag_ptr(node_id);
61572         node_id_conv.is_owned = ptr_is_owned(node_id);
61573         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61574         node_id_conv.is_owned = false;
61575         ProbabilisticScoringFeeParameters_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
61576 }
61577
61578 void  CS_LDK_ProbabilisticScoringFeeParameters_remove_manual_penalty(int64_t this_arg, int64_t node_id) {
61579         LDKProbabilisticScoringFeeParameters this_arg_conv;
61580         this_arg_conv.inner = untag_ptr(this_arg);
61581         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61583         this_arg_conv.is_owned = false;
61584         LDKNodeId node_id_conv;
61585         node_id_conv.inner = untag_ptr(node_id);
61586         node_id_conv.is_owned = ptr_is_owned(node_id);
61587         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
61588         node_id_conv.is_owned = false;
61589         ProbabilisticScoringFeeParameters_remove_manual_penalty(&this_arg_conv, &node_id_conv);
61590 }
61591
61592 void  CS_LDK_ProbabilisticScoringFeeParameters_clear_manual_penalties(int64_t this_arg) {
61593         LDKProbabilisticScoringFeeParameters this_arg_conv;
61594         this_arg_conv.inner = untag_ptr(this_arg);
61595         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61597         this_arg_conv.is_owned = false;
61598         ProbabilisticScoringFeeParameters_clear_manual_penalties(&this_arg_conv);
61599 }
61600
61601 void  CS_LDK_ProbabilisticScoringDecayParameters_free(int64_t this_obj) {
61602         LDKProbabilisticScoringDecayParameters this_obj_conv;
61603         this_obj_conv.inner = untag_ptr(this_obj);
61604         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61606         ProbabilisticScoringDecayParameters_free(this_obj_conv);
61607 }
61608
61609 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(int64_t this_ptr) {
61610         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61611         this_ptr_conv.inner = untag_ptr(this_ptr);
61612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61614         this_ptr_conv.is_owned = false;
61615         int64_t ret_conv = ProbabilisticScoringDecayParameters_get_historical_no_updates_half_life(&this_ptr_conv);
61616         return ret_conv;
61617 }
61618
61619 void  CS_LDK_ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(int64_t this_ptr, int64_t val) {
61620         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61621         this_ptr_conv.inner = untag_ptr(this_ptr);
61622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61624         this_ptr_conv.is_owned = false;
61625         ProbabilisticScoringDecayParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
61626 }
61627
61628 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(int64_t this_ptr) {
61629         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61630         this_ptr_conv.inner = untag_ptr(this_ptr);
61631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61633         this_ptr_conv.is_owned = false;
61634         int64_t ret_conv = ProbabilisticScoringDecayParameters_get_liquidity_offset_half_life(&this_ptr_conv);
61635         return ret_conv;
61636 }
61637
61638 void  CS_LDK_ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(int64_t this_ptr, int64_t val) {
61639         LDKProbabilisticScoringDecayParameters this_ptr_conv;
61640         this_ptr_conv.inner = untag_ptr(this_ptr);
61641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61643         this_ptr_conv.is_owned = false;
61644         ProbabilisticScoringDecayParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
61645 }
61646
61647 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_new(int64_t historical_no_updates_half_life_arg, int64_t liquidity_offset_half_life_arg) {
61648         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_new(historical_no_updates_half_life_arg, liquidity_offset_half_life_arg);
61649         int64_t ret_ref = 0;
61650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61652         return ret_ref;
61653 }
61654
61655 static inline uint64_t ProbabilisticScoringDecayParameters_clone_ptr(LDKProbabilisticScoringDecayParameters *NONNULL_PTR arg) {
61656         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_clone(arg);
61657         int64_t ret_ref = 0;
61658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61660         return ret_ref;
61661 }
61662 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_clone_ptr(int64_t arg) {
61663         LDKProbabilisticScoringDecayParameters arg_conv;
61664         arg_conv.inner = untag_ptr(arg);
61665         arg_conv.is_owned = ptr_is_owned(arg);
61666         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
61667         arg_conv.is_owned = false;
61668         int64_t ret_conv = ProbabilisticScoringDecayParameters_clone_ptr(&arg_conv);
61669         return ret_conv;
61670 }
61671
61672 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_clone(int64_t orig) {
61673         LDKProbabilisticScoringDecayParameters orig_conv;
61674         orig_conv.inner = untag_ptr(orig);
61675         orig_conv.is_owned = ptr_is_owned(orig);
61676         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
61677         orig_conv.is_owned = false;
61678         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_clone(&orig_conv);
61679         int64_t ret_ref = 0;
61680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61681         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61682         return ret_ref;
61683 }
61684
61685 int64_t  CS_LDK_ProbabilisticScoringDecayParameters_default() {
61686         LDKProbabilisticScoringDecayParameters ret_var = ProbabilisticScoringDecayParameters_default();
61687         int64_t ret_ref = 0;
61688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61690         return ret_ref;
61691 }
61692
61693 int64_t  CS_LDK_ProbabilisticScorer_new(int64_t decay_params, int64_t network_graph, int64_t logger) {
61694         LDKProbabilisticScoringDecayParameters decay_params_conv;
61695         decay_params_conv.inner = untag_ptr(decay_params);
61696         decay_params_conv.is_owned = ptr_is_owned(decay_params);
61697         CHECK_INNER_FIELD_ACCESS_OR_NULL(decay_params_conv);
61698         decay_params_conv = ProbabilisticScoringDecayParameters_clone(&decay_params_conv);
61699         LDKNetworkGraph network_graph_conv;
61700         network_graph_conv.inner = untag_ptr(network_graph);
61701         network_graph_conv.is_owned = ptr_is_owned(network_graph);
61702         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
61703         network_graph_conv.is_owned = false;
61704         void* logger_ptr = untag_ptr(logger);
61705         CHECK_ACCESS(logger_ptr);
61706         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
61707         if (logger_conv.free == LDKLogger_JCalls_free) {
61708                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
61709                 LDKLogger_JCalls_cloned(&logger_conv);
61710         }
61711         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(decay_params_conv, &network_graph_conv, logger_conv);
61712         int64_t ret_ref = 0;
61713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61715         return ret_ref;
61716 }
61717
61718 void  CS_LDK_ProbabilisticScorer_debug_log_liquidity_stats(int64_t this_arg) {
61719         LDKProbabilisticScorer this_arg_conv;
61720         this_arg_conv.inner = untag_ptr(this_arg);
61721         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61723         this_arg_conv.is_owned = false;
61724         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
61725 }
61726
61727 int64_t  CS_LDK_ProbabilisticScorer_estimated_channel_liquidity_range(int64_t this_arg, int64_t scid, int64_t target) {
61728         LDKProbabilisticScorer this_arg_conv;
61729         this_arg_conv.inner = untag_ptr(this_arg);
61730         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61732         this_arg_conv.is_owned = false;
61733         LDKNodeId target_conv;
61734         target_conv.inner = untag_ptr(target);
61735         target_conv.is_owned = ptr_is_owned(target);
61736         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
61737         target_conv.is_owned = false;
61738         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
61739         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
61740         int64_t ret_ref = tag_ptr(ret_copy, true);
61741         return ret_ref;
61742 }
61743
61744 int64_t  CS_LDK_ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(int64_t this_arg, int64_t scid, int64_t target) {
61745         LDKProbabilisticScorer this_arg_conv;
61746         this_arg_conv.inner = untag_ptr(this_arg);
61747         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61749         this_arg_conv.is_owned = false;
61750         LDKNodeId target_conv;
61751         target_conv.inner = untag_ptr(target);
61752         target_conv.is_owned = ptr_is_owned(target);
61753         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
61754         target_conv.is_owned = false;
61755         LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ), "LDKCOption_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ");
61756         *ret_copy = ProbabilisticScorer_historical_estimated_channel_liquidity_probabilities(&this_arg_conv, scid, &target_conv);
61757         int64_t ret_ref = tag_ptr(ret_copy, true);
61758         return ret_ref;
61759 }
61760
61761 int64_t  CS_LDK_ProbabilisticScorer_historical_estimated_payment_success_probability(int64_t this_arg, int64_t scid, int64_t target, int64_t amount_msat, int64_t params) {
61762         LDKProbabilisticScorer this_arg_conv;
61763         this_arg_conv.inner = untag_ptr(this_arg);
61764         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61766         this_arg_conv.is_owned = false;
61767         LDKNodeId target_conv;
61768         target_conv.inner = untag_ptr(target);
61769         target_conv.is_owned = ptr_is_owned(target);
61770         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
61771         target_conv.is_owned = false;
61772         LDKProbabilisticScoringFeeParameters params_conv;
61773         params_conv.inner = untag_ptr(params);
61774         params_conv.is_owned = ptr_is_owned(params);
61775         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
61776         params_conv.is_owned = false;
61777         LDKCOption_f64Z *ret_copy = MALLOC(sizeof(LDKCOption_f64Z), "LDKCOption_f64Z");
61778         *ret_copy = ProbabilisticScorer_historical_estimated_payment_success_probability(&this_arg_conv, scid, &target_conv, amount_msat, &params_conv);
61779         int64_t ret_ref = tag_ptr(ret_copy, true);
61780         return ret_ref;
61781 }
61782
61783 int64_t  CS_LDK_ProbabilisticScorer_as_ScoreLookUp(int64_t this_arg) {
61784         LDKProbabilisticScorer this_arg_conv;
61785         this_arg_conv.inner = untag_ptr(this_arg);
61786         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61788         this_arg_conv.is_owned = false;
61789         LDKScoreLookUp* ret_ret = MALLOC(sizeof(LDKScoreLookUp), "LDKScoreLookUp");
61790         *ret_ret = ProbabilisticScorer_as_ScoreLookUp(&this_arg_conv);
61791         return tag_ptr(ret_ret, true);
61792 }
61793
61794 int64_t  CS_LDK_ProbabilisticScorer_as_ScoreUpdate(int64_t this_arg) {
61795         LDKProbabilisticScorer this_arg_conv;
61796         this_arg_conv.inner = untag_ptr(this_arg);
61797         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61799         this_arg_conv.is_owned = false;
61800         LDKScoreUpdate* ret_ret = MALLOC(sizeof(LDKScoreUpdate), "LDKScoreUpdate");
61801         *ret_ret = ProbabilisticScorer_as_ScoreUpdate(&this_arg_conv);
61802         return tag_ptr(ret_ret, true);
61803 }
61804
61805 int64_t  CS_LDK_ProbabilisticScorer_as_Score(int64_t this_arg) {
61806         LDKProbabilisticScorer this_arg_conv;
61807         this_arg_conv.inner = untag_ptr(this_arg);
61808         this_arg_conv.is_owned = ptr_is_owned(this_arg);
61809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
61810         this_arg_conv.is_owned = false;
61811         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
61812         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
61813         return tag_ptr(ret_ret, true);
61814 }
61815
61816 int8_tArray  CS_LDK_ProbabilisticScorer_write(int64_t obj) {
61817         LDKProbabilisticScorer obj_conv;
61818         obj_conv.inner = untag_ptr(obj);
61819         obj_conv.is_owned = ptr_is_owned(obj);
61820         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
61821         obj_conv.is_owned = false;
61822         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
61823         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
61824         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
61825         CVec_u8Z_free(ret_var);
61826         return ret_arr;
61827 }
61828
61829 int64_t  CS_LDK_ProbabilisticScorer_read(int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
61830         LDKu8slice ser_ref;
61831         ser_ref.datalen = ser->arr_len;
61832         ser_ref.data = ser->elems;
61833         LDKProbabilisticScoringDecayParameters arg_a_conv;
61834         arg_a_conv.inner = untag_ptr(arg_a);
61835         arg_a_conv.is_owned = ptr_is_owned(arg_a);
61836         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
61837         arg_a_conv = ProbabilisticScoringDecayParameters_clone(&arg_a_conv);
61838         LDKNetworkGraph arg_b_conv;
61839         arg_b_conv.inner = untag_ptr(arg_b);
61840         arg_b_conv.is_owned = ptr_is_owned(arg_b);
61841         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
61842         arg_b_conv.is_owned = false;
61843         void* arg_c_ptr = untag_ptr(arg_c);
61844         CHECK_ACCESS(arg_c_ptr);
61845         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
61846         if (arg_c_conv.free == LDKLogger_JCalls_free) {
61847                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
61848                 LDKLogger_JCalls_cloned(&arg_c_conv);
61849         }
61850         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
61851         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
61852         FREE(ser);
61853         return tag_ptr(ret_conv, true);
61854 }
61855
61856 void  CS_LDK_DelayedPaymentOutputDescriptor_free(int64_t this_obj) {
61857         LDKDelayedPaymentOutputDescriptor this_obj_conv;
61858         this_obj_conv.inner = untag_ptr(this_obj);
61859         this_obj_conv.is_owned = ptr_is_owned(this_obj);
61860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
61861         DelayedPaymentOutputDescriptor_free(this_obj_conv);
61862 }
61863
61864 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_get_outpoint(int64_t this_ptr) {
61865         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61866         this_ptr_conv.inner = untag_ptr(this_ptr);
61867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61869         this_ptr_conv.is_owned = false;
61870         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
61871         int64_t ret_ref = 0;
61872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
61873         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
61874         return ret_ref;
61875 }
61876
61877 void  CS_LDK_DelayedPaymentOutputDescriptor_set_outpoint(int64_t this_ptr, int64_t val) {
61878         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61879         this_ptr_conv.inner = untag_ptr(this_ptr);
61880         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61882         this_ptr_conv.is_owned = false;
61883         LDKOutPoint val_conv;
61884         val_conv.inner = untag_ptr(val);
61885         val_conv.is_owned = ptr_is_owned(val);
61886         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
61887         val_conv = OutPoint_clone(&val_conv);
61888         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
61889 }
61890
61891 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_get_per_commitment_point(int64_t this_ptr) {
61892         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61893         this_ptr_conv.inner = untag_ptr(this_ptr);
61894         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61896         this_ptr_conv.is_owned = false;
61897         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
61898         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
61899         return ret_arr;
61900 }
61901
61902 void  CS_LDK_DelayedPaymentOutputDescriptor_set_per_commitment_point(int64_t this_ptr, int8_tArray val) {
61903         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61904         this_ptr_conv.inner = untag_ptr(this_ptr);
61905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61907         this_ptr_conv.is_owned = false;
61908         LDKPublicKey val_ref;
61909         CHECK(val->arr_len == 33);
61910         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
61911         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
61912 }
61913
61914 int16_t  CS_LDK_DelayedPaymentOutputDescriptor_get_to_self_delay(int64_t this_ptr) {
61915         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61916         this_ptr_conv.inner = untag_ptr(this_ptr);
61917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61919         this_ptr_conv.is_owned = false;
61920         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
61921         return ret_conv;
61922 }
61923
61924 void  CS_LDK_DelayedPaymentOutputDescriptor_set_to_self_delay(int64_t this_ptr, int16_t val) {
61925         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61926         this_ptr_conv.inner = untag_ptr(this_ptr);
61927         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61929         this_ptr_conv.is_owned = false;
61930         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
61931 }
61932
61933 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_get_output(int64_t this_ptr) {
61934         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61935         this_ptr_conv.inner = untag_ptr(this_ptr);
61936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61938         this_ptr_conv.is_owned = false;
61939         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
61940         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
61941         return tag_ptr(ret_ref, true);
61942 }
61943
61944 void  CS_LDK_DelayedPaymentOutputDescriptor_set_output(int64_t this_ptr, int64_t val) {
61945         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61946         this_ptr_conv.inner = untag_ptr(this_ptr);
61947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61949         this_ptr_conv.is_owned = false;
61950         void* val_ptr = untag_ptr(val);
61951         CHECK_ACCESS(val_ptr);
61952         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
61953         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
61954         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
61955 }
61956
61957 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_get_revocation_pubkey(int64_t this_ptr) {
61958         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61959         this_ptr_conv.inner = untag_ptr(this_ptr);
61960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61962         this_ptr_conv.is_owned = false;
61963         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
61964         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
61965         return ret_arr;
61966 }
61967
61968 void  CS_LDK_DelayedPaymentOutputDescriptor_set_revocation_pubkey(int64_t this_ptr, int8_tArray val) {
61969         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61970         this_ptr_conv.inner = untag_ptr(this_ptr);
61971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61973         this_ptr_conv.is_owned = false;
61974         LDKPublicKey val_ref;
61975         CHECK(val->arr_len == 33);
61976         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
61977         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
61978 }
61979
61980 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_get_channel_keys_id(int64_t this_ptr) {
61981         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61982         this_ptr_conv.inner = untag_ptr(this_ptr);
61983         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61985         this_ptr_conv.is_owned = false;
61986         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
61987         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
61988         return ret_arr;
61989 }
61990
61991 void  CS_LDK_DelayedPaymentOutputDescriptor_set_channel_keys_id(int64_t this_ptr, int8_tArray val) {
61992         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
61993         this_ptr_conv.inner = untag_ptr(this_ptr);
61994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
61995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
61996         this_ptr_conv.is_owned = false;
61997         LDKThirtyTwoBytes val_ref;
61998         CHECK(val->arr_len == 32);
61999         memcpy(val_ref.data, val->elems, 32); FREE(val);
62000         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
62001 }
62002
62003 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(int64_t this_ptr) {
62004         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
62005         this_ptr_conv.inner = untag_ptr(this_ptr);
62006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62008         this_ptr_conv.is_owned = false;
62009         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
62010         return ret_conv;
62011 }
62012
62013 void  CS_LDK_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(int64_t this_ptr, int64_t val) {
62014         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
62015         this_ptr_conv.inner = untag_ptr(this_ptr);
62016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62018         this_ptr_conv.is_owned = false;
62019         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
62020 }
62021
62022 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_new(int64_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, int64_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
62023         LDKOutPoint outpoint_arg_conv;
62024         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
62025         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
62026         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
62027         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
62028         LDKPublicKey per_commitment_point_arg_ref;
62029         CHECK(per_commitment_point_arg->arr_len == 33);
62030         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
62031         void* output_arg_ptr = untag_ptr(output_arg);
62032         CHECK_ACCESS(output_arg_ptr);
62033         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
62034         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
62035         LDKPublicKey revocation_pubkey_arg_ref;
62036         CHECK(revocation_pubkey_arg->arr_len == 33);
62037         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
62038         LDKThirtyTwoBytes channel_keys_id_arg_ref;
62039         CHECK(channel_keys_id_arg->arr_len == 32);
62040         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
62041         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);
62042         int64_t ret_ref = 0;
62043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62045         return ret_ref;
62046 }
62047
62048 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
62049         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
62050         int64_t ret_ref = 0;
62051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62053         return ret_ref;
62054 }
62055 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_clone_ptr(int64_t arg) {
62056         LDKDelayedPaymentOutputDescriptor arg_conv;
62057         arg_conv.inner = untag_ptr(arg);
62058         arg_conv.is_owned = ptr_is_owned(arg);
62059         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62060         arg_conv.is_owned = false;
62061         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
62062         return ret_conv;
62063 }
62064
62065 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_clone(int64_t orig) {
62066         LDKDelayedPaymentOutputDescriptor orig_conv;
62067         orig_conv.inner = untag_ptr(orig);
62068         orig_conv.is_owned = ptr_is_owned(orig);
62069         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62070         orig_conv.is_owned = false;
62071         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
62072         int64_t ret_ref = 0;
62073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62074         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62075         return ret_ref;
62076 }
62077
62078 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_hash(int64_t o) {
62079         LDKDelayedPaymentOutputDescriptor o_conv;
62080         o_conv.inner = untag_ptr(o);
62081         o_conv.is_owned = ptr_is_owned(o);
62082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
62083         o_conv.is_owned = false;
62084         int64_t ret_conv = DelayedPaymentOutputDescriptor_hash(&o_conv);
62085         return ret_conv;
62086 }
62087
62088 jboolean  CS_LDK_DelayedPaymentOutputDescriptor_eq(int64_t a, int64_t b) {
62089         LDKDelayedPaymentOutputDescriptor a_conv;
62090         a_conv.inner = untag_ptr(a);
62091         a_conv.is_owned = ptr_is_owned(a);
62092         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62093         a_conv.is_owned = false;
62094         LDKDelayedPaymentOutputDescriptor b_conv;
62095         b_conv.inner = untag_ptr(b);
62096         b_conv.is_owned = ptr_is_owned(b);
62097         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62098         b_conv.is_owned = false;
62099         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
62100         return ret_conv;
62101 }
62102
62103 int8_tArray  CS_LDK_DelayedPaymentOutputDescriptor_write(int64_t obj) {
62104         LDKDelayedPaymentOutputDescriptor obj_conv;
62105         obj_conv.inner = untag_ptr(obj);
62106         obj_conv.is_owned = ptr_is_owned(obj);
62107         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62108         obj_conv.is_owned = false;
62109         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
62110         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62111         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62112         CVec_u8Z_free(ret_var);
62113         return ret_arr;
62114 }
62115
62116 int64_t  CS_LDK_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
62117         LDKu8slice ser_ref;
62118         ser_ref.datalen = ser->arr_len;
62119         ser_ref.data = ser->elems;
62120         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
62121         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
62122         FREE(ser);
62123         return tag_ptr(ret_conv, true);
62124 }
62125
62126 void  CS_LDK_StaticPaymentOutputDescriptor_free(int64_t this_obj) {
62127         LDKStaticPaymentOutputDescriptor this_obj_conv;
62128         this_obj_conv.inner = untag_ptr(this_obj);
62129         this_obj_conv.is_owned = ptr_is_owned(this_obj);
62130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
62131         StaticPaymentOutputDescriptor_free(this_obj_conv);
62132 }
62133
62134 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_outpoint(int64_t this_ptr) {
62135         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62136         this_ptr_conv.inner = untag_ptr(this_ptr);
62137         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62139         this_ptr_conv.is_owned = false;
62140         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
62141         int64_t ret_ref = 0;
62142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62143         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62144         return ret_ref;
62145 }
62146
62147 void  CS_LDK_StaticPaymentOutputDescriptor_set_outpoint(int64_t this_ptr, int64_t val) {
62148         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62149         this_ptr_conv.inner = untag_ptr(this_ptr);
62150         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62152         this_ptr_conv.is_owned = false;
62153         LDKOutPoint val_conv;
62154         val_conv.inner = untag_ptr(val);
62155         val_conv.is_owned = ptr_is_owned(val);
62156         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62157         val_conv = OutPoint_clone(&val_conv);
62158         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
62159 }
62160
62161 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_output(int64_t this_ptr) {
62162         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62163         this_ptr_conv.inner = untag_ptr(this_ptr);
62164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62166         this_ptr_conv.is_owned = false;
62167         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
62168         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
62169         return tag_ptr(ret_ref, true);
62170 }
62171
62172 void  CS_LDK_StaticPaymentOutputDescriptor_set_output(int64_t this_ptr, int64_t val) {
62173         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62174         this_ptr_conv.inner = untag_ptr(this_ptr);
62175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62177         this_ptr_conv.is_owned = false;
62178         void* val_ptr = untag_ptr(val);
62179         CHECK_ACCESS(val_ptr);
62180         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
62181         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
62182         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
62183 }
62184
62185 int8_tArray  CS_LDK_StaticPaymentOutputDescriptor_get_channel_keys_id(int64_t this_ptr) {
62186         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62187         this_ptr_conv.inner = untag_ptr(this_ptr);
62188         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62190         this_ptr_conv.is_owned = false;
62191         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
62192         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
62193         return ret_arr;
62194 }
62195
62196 void  CS_LDK_StaticPaymentOutputDescriptor_set_channel_keys_id(int64_t this_ptr, int8_tArray val) {
62197         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62198         this_ptr_conv.inner = untag_ptr(this_ptr);
62199         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62201         this_ptr_conv.is_owned = false;
62202         LDKThirtyTwoBytes val_ref;
62203         CHECK(val->arr_len == 32);
62204         memcpy(val_ref.data, val->elems, 32); FREE(val);
62205         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
62206 }
62207
62208 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_channel_value_satoshis(int64_t this_ptr) {
62209         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62210         this_ptr_conv.inner = untag_ptr(this_ptr);
62211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62213         this_ptr_conv.is_owned = false;
62214         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
62215         return ret_conv;
62216 }
62217
62218 void  CS_LDK_StaticPaymentOutputDescriptor_set_channel_value_satoshis(int64_t this_ptr, int64_t val) {
62219         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62220         this_ptr_conv.inner = untag_ptr(this_ptr);
62221         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62223         this_ptr_conv.is_owned = false;
62224         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
62225 }
62226
62227 int64_t  CS_LDK_StaticPaymentOutputDescriptor_get_channel_transaction_parameters(int64_t this_ptr) {
62228         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62229         this_ptr_conv.inner = untag_ptr(this_ptr);
62230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62232         this_ptr_conv.is_owned = false;
62233         LDKChannelTransactionParameters ret_var = StaticPaymentOutputDescriptor_get_channel_transaction_parameters(&this_ptr_conv);
62234         int64_t ret_ref = 0;
62235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62237         return ret_ref;
62238 }
62239
62240 void  CS_LDK_StaticPaymentOutputDescriptor_set_channel_transaction_parameters(int64_t this_ptr, int64_t val) {
62241         LDKStaticPaymentOutputDescriptor this_ptr_conv;
62242         this_ptr_conv.inner = untag_ptr(this_ptr);
62243         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62245         this_ptr_conv.is_owned = false;
62246         LDKChannelTransactionParameters val_conv;
62247         val_conv.inner = untag_ptr(val);
62248         val_conv.is_owned = ptr_is_owned(val);
62249         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62250         val_conv = ChannelTransactionParameters_clone(&val_conv);
62251         StaticPaymentOutputDescriptor_set_channel_transaction_parameters(&this_ptr_conv, val_conv);
62252 }
62253
62254 int64_t  CS_LDK_StaticPaymentOutputDescriptor_new(int64_t outpoint_arg, int64_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg, int64_t channel_transaction_parameters_arg) {
62255         LDKOutPoint outpoint_arg_conv;
62256         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
62257         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
62258         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
62259         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
62260         void* output_arg_ptr = untag_ptr(output_arg);
62261         CHECK_ACCESS(output_arg_ptr);
62262         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
62263         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
62264         LDKThirtyTwoBytes channel_keys_id_arg_ref;
62265         CHECK(channel_keys_id_arg->arr_len == 32);
62266         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
62267         LDKChannelTransactionParameters channel_transaction_parameters_arg_conv;
62268         channel_transaction_parameters_arg_conv.inner = untag_ptr(channel_transaction_parameters_arg);
62269         channel_transaction_parameters_arg_conv.is_owned = ptr_is_owned(channel_transaction_parameters_arg);
62270         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_transaction_parameters_arg_conv);
62271         channel_transaction_parameters_arg_conv = ChannelTransactionParameters_clone(&channel_transaction_parameters_arg_conv);
62272         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg, channel_transaction_parameters_arg_conv);
62273         int64_t ret_ref = 0;
62274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62275         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62276         return ret_ref;
62277 }
62278
62279 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
62280         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
62281         int64_t ret_ref = 0;
62282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62283         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62284         return ret_ref;
62285 }
62286 int64_t  CS_LDK_StaticPaymentOutputDescriptor_clone_ptr(int64_t arg) {
62287         LDKStaticPaymentOutputDescriptor arg_conv;
62288         arg_conv.inner = untag_ptr(arg);
62289         arg_conv.is_owned = ptr_is_owned(arg);
62290         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62291         arg_conv.is_owned = false;
62292         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
62293         return ret_conv;
62294 }
62295
62296 int64_t  CS_LDK_StaticPaymentOutputDescriptor_clone(int64_t orig) {
62297         LDKStaticPaymentOutputDescriptor orig_conv;
62298         orig_conv.inner = untag_ptr(orig);
62299         orig_conv.is_owned = ptr_is_owned(orig);
62300         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62301         orig_conv.is_owned = false;
62302         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
62303         int64_t ret_ref = 0;
62304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62305         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62306         return ret_ref;
62307 }
62308
62309 int64_t  CS_LDK_StaticPaymentOutputDescriptor_hash(int64_t o) {
62310         LDKStaticPaymentOutputDescriptor o_conv;
62311         o_conv.inner = untag_ptr(o);
62312         o_conv.is_owned = ptr_is_owned(o);
62313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
62314         o_conv.is_owned = false;
62315         int64_t ret_conv = StaticPaymentOutputDescriptor_hash(&o_conv);
62316         return ret_conv;
62317 }
62318
62319 jboolean  CS_LDK_StaticPaymentOutputDescriptor_eq(int64_t a, int64_t b) {
62320         LDKStaticPaymentOutputDescriptor a_conv;
62321         a_conv.inner = untag_ptr(a);
62322         a_conv.is_owned = ptr_is_owned(a);
62323         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62324         a_conv.is_owned = false;
62325         LDKStaticPaymentOutputDescriptor b_conv;
62326         b_conv.inner = untag_ptr(b);
62327         b_conv.is_owned = ptr_is_owned(b);
62328         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62329         b_conv.is_owned = false;
62330         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
62331         return ret_conv;
62332 }
62333
62334 int64_t  CS_LDK_StaticPaymentOutputDescriptor_witness_script(int64_t this_arg) {
62335         LDKStaticPaymentOutputDescriptor this_arg_conv;
62336         this_arg_conv.inner = untag_ptr(this_arg);
62337         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62339         this_arg_conv.is_owned = false;
62340         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
62341         *ret_copy = StaticPaymentOutputDescriptor_witness_script(&this_arg_conv);
62342         int64_t ret_ref = tag_ptr(ret_copy, true);
62343         return ret_ref;
62344 }
62345
62346 int64_t  CS_LDK_StaticPaymentOutputDescriptor_max_witness_length(int64_t this_arg) {
62347         LDKStaticPaymentOutputDescriptor this_arg_conv;
62348         this_arg_conv.inner = untag_ptr(this_arg);
62349         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62351         this_arg_conv.is_owned = false;
62352         int64_t ret_conv = StaticPaymentOutputDescriptor_max_witness_length(&this_arg_conv);
62353         return ret_conv;
62354 }
62355
62356 int8_tArray  CS_LDK_StaticPaymentOutputDescriptor_write(int64_t obj) {
62357         LDKStaticPaymentOutputDescriptor obj_conv;
62358         obj_conv.inner = untag_ptr(obj);
62359         obj_conv.is_owned = ptr_is_owned(obj);
62360         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62361         obj_conv.is_owned = false;
62362         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
62363         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62364         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62365         CVec_u8Z_free(ret_var);
62366         return ret_arr;
62367 }
62368
62369 int64_t  CS_LDK_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
62370         LDKu8slice ser_ref;
62371         ser_ref.datalen = ser->arr_len;
62372         ser_ref.data = ser->elems;
62373         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
62374         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
62375         FREE(ser);
62376         return tag_ptr(ret_conv, true);
62377 }
62378
62379 void  CS_LDK_SpendableOutputDescriptor_free(int64_t this_ptr) {
62380         if (!ptr_is_owned(this_ptr)) return;
62381         void* this_ptr_ptr = untag_ptr(this_ptr);
62382         CHECK_ACCESS(this_ptr_ptr);
62383         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
62384         FREE(untag_ptr(this_ptr));
62385         SpendableOutputDescriptor_free(this_ptr_conv);
62386 }
62387
62388 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
62389         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62390         *ret_copy = SpendableOutputDescriptor_clone(arg);
62391         int64_t ret_ref = tag_ptr(ret_copy, true);
62392         return ret_ref;
62393 }
62394 int64_t  CS_LDK_SpendableOutputDescriptor_clone_ptr(int64_t arg) {
62395         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
62396         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
62397         return ret_conv;
62398 }
62399
62400 int64_t  CS_LDK_SpendableOutputDescriptor_clone(int64_t orig) {
62401         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
62402         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62403         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
62404         int64_t ret_ref = tag_ptr(ret_copy, true);
62405         return ret_ref;
62406 }
62407
62408 int64_t  CS_LDK_SpendableOutputDescriptor_static_output(int64_t outpoint, int64_t output) {
62409         LDKOutPoint outpoint_conv;
62410         outpoint_conv.inner = untag_ptr(outpoint);
62411         outpoint_conv.is_owned = ptr_is_owned(outpoint);
62412         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
62413         outpoint_conv = OutPoint_clone(&outpoint_conv);
62414         void* output_ptr = untag_ptr(output);
62415         CHECK_ACCESS(output_ptr);
62416         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
62417         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
62418         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62419         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
62420         int64_t ret_ref = tag_ptr(ret_copy, true);
62421         return ret_ref;
62422 }
62423
62424 int64_t  CS_LDK_SpendableOutputDescriptor_delayed_payment_output(int64_t a) {
62425         LDKDelayedPaymentOutputDescriptor a_conv;
62426         a_conv.inner = untag_ptr(a);
62427         a_conv.is_owned = ptr_is_owned(a);
62428         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62429         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
62430         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62431         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
62432         int64_t ret_ref = tag_ptr(ret_copy, true);
62433         return ret_ref;
62434 }
62435
62436 int64_t  CS_LDK_SpendableOutputDescriptor_static_payment_output(int64_t a) {
62437         LDKStaticPaymentOutputDescriptor a_conv;
62438         a_conv.inner = untag_ptr(a);
62439         a_conv.is_owned = ptr_is_owned(a);
62440         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62441         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
62442         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
62443         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
62444         int64_t ret_ref = tag_ptr(ret_copy, true);
62445         return ret_ref;
62446 }
62447
62448 int64_t  CS_LDK_SpendableOutputDescriptor_hash(int64_t o) {
62449         LDKSpendableOutputDescriptor* o_conv = (LDKSpendableOutputDescriptor*)untag_ptr(o);
62450         int64_t ret_conv = SpendableOutputDescriptor_hash(o_conv);
62451         return ret_conv;
62452 }
62453
62454 jboolean  CS_LDK_SpendableOutputDescriptor_eq(int64_t a, int64_t b) {
62455         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
62456         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
62457         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
62458         return ret_conv;
62459 }
62460
62461 int8_tArray  CS_LDK_SpendableOutputDescriptor_write(int64_t obj) {
62462         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
62463         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
62464         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62465         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62466         CVec_u8Z_free(ret_var);
62467         return ret_arr;
62468 }
62469
62470 int64_t  CS_LDK_SpendableOutputDescriptor_read(int8_tArray ser) {
62471         LDKu8slice ser_ref;
62472         ser_ref.datalen = ser->arr_len;
62473         ser_ref.data = ser->elems;
62474         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
62475         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
62476         FREE(ser);
62477         return tag_ptr(ret_conv, true);
62478 }
62479
62480 int64_t  CS_LDK_SpendableOutputDescriptor_create_spendable_outputs_psbt(int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight, int64_t locktime) {
62481         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
62482         descriptors_constr.datalen = descriptors->arr_len;
62483         if (descriptors_constr.datalen > 0)
62484                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
62485         else
62486                 descriptors_constr.data = NULL;
62487         int64_t* descriptors_vals = descriptors->elems;
62488         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
62489                 int64_t descriptors_conv_27 = descriptors_vals[b];
62490                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
62491                 CHECK_ACCESS(descriptors_conv_27_ptr);
62492                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
62493                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
62494                 descriptors_constr.data[b] = descriptors_conv_27_conv;
62495         }
62496         FREE(descriptors);
62497         LDKCVec_TxOutZ outputs_constr;
62498         outputs_constr.datalen = outputs->arr_len;
62499         if (outputs_constr.datalen > 0)
62500                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
62501         else
62502                 outputs_constr.data = NULL;
62503         int64_t* outputs_vals = outputs->elems;
62504         for (size_t h = 0; h < outputs_constr.datalen; h++) {
62505                 int64_t outputs_conv_7 = outputs_vals[h];
62506                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
62507                 CHECK_ACCESS(outputs_conv_7_ptr);
62508                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
62509                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
62510                 outputs_constr.data[h] = outputs_conv_7_conv;
62511         }
62512         FREE(outputs);
62513         LDKCVec_u8Z change_destination_script_ref;
62514         change_destination_script_ref.datalen = change_destination_script->arr_len;
62515         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
62516         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
62517         void* locktime_ptr = untag_ptr(locktime);
62518         CHECK_ACCESS(locktime_ptr);
62519         LDKCOption_u32Z locktime_conv = *(LDKCOption_u32Z*)(locktime_ptr);
62520         locktime_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(locktime));
62521         LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ), "LDKCResult_C2Tuple_CVec_u8ZusizeZNoneZ");
62522         *ret_conv = SpendableOutputDescriptor_create_spendable_outputs_psbt(descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight, locktime_conv);
62523         return tag_ptr(ret_conv, true);
62524 }
62525
62526 void  CS_LDK_ChannelDerivationParameters_free(int64_t this_obj) {
62527         LDKChannelDerivationParameters this_obj_conv;
62528         this_obj_conv.inner = untag_ptr(this_obj);
62529         this_obj_conv.is_owned = ptr_is_owned(this_obj);
62530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
62531         ChannelDerivationParameters_free(this_obj_conv);
62532 }
62533
62534 int64_t  CS_LDK_ChannelDerivationParameters_get_value_satoshis(int64_t this_ptr) {
62535         LDKChannelDerivationParameters this_ptr_conv;
62536         this_ptr_conv.inner = untag_ptr(this_ptr);
62537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62539         this_ptr_conv.is_owned = false;
62540         int64_t ret_conv = ChannelDerivationParameters_get_value_satoshis(&this_ptr_conv);
62541         return ret_conv;
62542 }
62543
62544 void  CS_LDK_ChannelDerivationParameters_set_value_satoshis(int64_t this_ptr, int64_t val) {
62545         LDKChannelDerivationParameters this_ptr_conv;
62546         this_ptr_conv.inner = untag_ptr(this_ptr);
62547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62549         this_ptr_conv.is_owned = false;
62550         ChannelDerivationParameters_set_value_satoshis(&this_ptr_conv, val);
62551 }
62552
62553 int8_tArray  CS_LDK_ChannelDerivationParameters_get_keys_id(int64_t this_ptr) {
62554         LDKChannelDerivationParameters this_ptr_conv;
62555         this_ptr_conv.inner = untag_ptr(this_ptr);
62556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62558         this_ptr_conv.is_owned = false;
62559         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
62560         memcpy(ret_arr->elems, *ChannelDerivationParameters_get_keys_id(&this_ptr_conv), 32);
62561         return ret_arr;
62562 }
62563
62564 void  CS_LDK_ChannelDerivationParameters_set_keys_id(int64_t this_ptr, int8_tArray val) {
62565         LDKChannelDerivationParameters this_ptr_conv;
62566         this_ptr_conv.inner = untag_ptr(this_ptr);
62567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62569         this_ptr_conv.is_owned = false;
62570         LDKThirtyTwoBytes val_ref;
62571         CHECK(val->arr_len == 32);
62572         memcpy(val_ref.data, val->elems, 32); FREE(val);
62573         ChannelDerivationParameters_set_keys_id(&this_ptr_conv, val_ref);
62574 }
62575
62576 int64_t  CS_LDK_ChannelDerivationParameters_get_transaction_parameters(int64_t this_ptr) {
62577         LDKChannelDerivationParameters this_ptr_conv;
62578         this_ptr_conv.inner = untag_ptr(this_ptr);
62579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62581         this_ptr_conv.is_owned = false;
62582         LDKChannelTransactionParameters ret_var = ChannelDerivationParameters_get_transaction_parameters(&this_ptr_conv);
62583         int64_t ret_ref = 0;
62584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62586         return ret_ref;
62587 }
62588
62589 void  CS_LDK_ChannelDerivationParameters_set_transaction_parameters(int64_t this_ptr, int64_t val) {
62590         LDKChannelDerivationParameters this_ptr_conv;
62591         this_ptr_conv.inner = untag_ptr(this_ptr);
62592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62594         this_ptr_conv.is_owned = false;
62595         LDKChannelTransactionParameters val_conv;
62596         val_conv.inner = untag_ptr(val);
62597         val_conv.is_owned = ptr_is_owned(val);
62598         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62599         val_conv = ChannelTransactionParameters_clone(&val_conv);
62600         ChannelDerivationParameters_set_transaction_parameters(&this_ptr_conv, val_conv);
62601 }
62602
62603 int64_t  CS_LDK_ChannelDerivationParameters_new(int64_t value_satoshis_arg, int8_tArray keys_id_arg, int64_t transaction_parameters_arg) {
62604         LDKThirtyTwoBytes keys_id_arg_ref;
62605         CHECK(keys_id_arg->arr_len == 32);
62606         memcpy(keys_id_arg_ref.data, keys_id_arg->elems, 32); FREE(keys_id_arg);
62607         LDKChannelTransactionParameters transaction_parameters_arg_conv;
62608         transaction_parameters_arg_conv.inner = untag_ptr(transaction_parameters_arg);
62609         transaction_parameters_arg_conv.is_owned = ptr_is_owned(transaction_parameters_arg);
62610         CHECK_INNER_FIELD_ACCESS_OR_NULL(transaction_parameters_arg_conv);
62611         transaction_parameters_arg_conv = ChannelTransactionParameters_clone(&transaction_parameters_arg_conv);
62612         LDKChannelDerivationParameters ret_var = ChannelDerivationParameters_new(value_satoshis_arg, keys_id_arg_ref, transaction_parameters_arg_conv);
62613         int64_t ret_ref = 0;
62614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62615         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62616         return ret_ref;
62617 }
62618
62619 static inline uint64_t ChannelDerivationParameters_clone_ptr(LDKChannelDerivationParameters *NONNULL_PTR arg) {
62620         LDKChannelDerivationParameters ret_var = ChannelDerivationParameters_clone(arg);
62621         int64_t ret_ref = 0;
62622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62623         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62624         return ret_ref;
62625 }
62626 int64_t  CS_LDK_ChannelDerivationParameters_clone_ptr(int64_t arg) {
62627         LDKChannelDerivationParameters arg_conv;
62628         arg_conv.inner = untag_ptr(arg);
62629         arg_conv.is_owned = ptr_is_owned(arg);
62630         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62631         arg_conv.is_owned = false;
62632         int64_t ret_conv = ChannelDerivationParameters_clone_ptr(&arg_conv);
62633         return ret_conv;
62634 }
62635
62636 int64_t  CS_LDK_ChannelDerivationParameters_clone(int64_t orig) {
62637         LDKChannelDerivationParameters orig_conv;
62638         orig_conv.inner = untag_ptr(orig);
62639         orig_conv.is_owned = ptr_is_owned(orig);
62640         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62641         orig_conv.is_owned = false;
62642         LDKChannelDerivationParameters ret_var = ChannelDerivationParameters_clone(&orig_conv);
62643         int64_t ret_ref = 0;
62644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62645         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62646         return ret_ref;
62647 }
62648
62649 jboolean  CS_LDK_ChannelDerivationParameters_eq(int64_t a, int64_t b) {
62650         LDKChannelDerivationParameters a_conv;
62651         a_conv.inner = untag_ptr(a);
62652         a_conv.is_owned = ptr_is_owned(a);
62653         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62654         a_conv.is_owned = false;
62655         LDKChannelDerivationParameters b_conv;
62656         b_conv.inner = untag_ptr(b);
62657         b_conv.is_owned = ptr_is_owned(b);
62658         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62659         b_conv.is_owned = false;
62660         jboolean ret_conv = ChannelDerivationParameters_eq(&a_conv, &b_conv);
62661         return ret_conv;
62662 }
62663
62664 int8_tArray  CS_LDK_ChannelDerivationParameters_write(int64_t obj) {
62665         LDKChannelDerivationParameters obj_conv;
62666         obj_conv.inner = untag_ptr(obj);
62667         obj_conv.is_owned = ptr_is_owned(obj);
62668         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62669         obj_conv.is_owned = false;
62670         LDKCVec_u8Z ret_var = ChannelDerivationParameters_write(&obj_conv);
62671         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62672         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62673         CVec_u8Z_free(ret_var);
62674         return ret_arr;
62675 }
62676
62677 int64_t  CS_LDK_ChannelDerivationParameters_read(int8_tArray ser) {
62678         LDKu8slice ser_ref;
62679         ser_ref.datalen = ser->arr_len;
62680         ser_ref.data = ser->elems;
62681         LDKCResult_ChannelDerivationParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDerivationParametersDecodeErrorZ), "LDKCResult_ChannelDerivationParametersDecodeErrorZ");
62682         *ret_conv = ChannelDerivationParameters_read(ser_ref);
62683         FREE(ser);
62684         return tag_ptr(ret_conv, true);
62685 }
62686
62687 void  CS_LDK_HTLCDescriptor_free(int64_t this_obj) {
62688         LDKHTLCDescriptor this_obj_conv;
62689         this_obj_conv.inner = untag_ptr(this_obj);
62690         this_obj_conv.is_owned = ptr_is_owned(this_obj);
62691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
62692         HTLCDescriptor_free(this_obj_conv);
62693 }
62694
62695 int64_t  CS_LDK_HTLCDescriptor_get_channel_derivation_parameters(int64_t this_ptr) {
62696         LDKHTLCDescriptor this_ptr_conv;
62697         this_ptr_conv.inner = untag_ptr(this_ptr);
62698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62700         this_ptr_conv.is_owned = false;
62701         LDKChannelDerivationParameters ret_var = HTLCDescriptor_get_channel_derivation_parameters(&this_ptr_conv);
62702         int64_t ret_ref = 0;
62703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62704         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62705         return ret_ref;
62706 }
62707
62708 void  CS_LDK_HTLCDescriptor_set_channel_derivation_parameters(int64_t this_ptr, int64_t val) {
62709         LDKHTLCDescriptor this_ptr_conv;
62710         this_ptr_conv.inner = untag_ptr(this_ptr);
62711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62713         this_ptr_conv.is_owned = false;
62714         LDKChannelDerivationParameters val_conv;
62715         val_conv.inner = untag_ptr(val);
62716         val_conv.is_owned = ptr_is_owned(val);
62717         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62718         val_conv = ChannelDerivationParameters_clone(&val_conv);
62719         HTLCDescriptor_set_channel_derivation_parameters(&this_ptr_conv, val_conv);
62720 }
62721
62722 int64_t  CS_LDK_HTLCDescriptor_get_per_commitment_number(int64_t this_ptr) {
62723         LDKHTLCDescriptor this_ptr_conv;
62724         this_ptr_conv.inner = untag_ptr(this_ptr);
62725         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62727         this_ptr_conv.is_owned = false;
62728         int64_t ret_conv = HTLCDescriptor_get_per_commitment_number(&this_ptr_conv);
62729         return ret_conv;
62730 }
62731
62732 void  CS_LDK_HTLCDescriptor_set_per_commitment_number(int64_t this_ptr, int64_t val) {
62733         LDKHTLCDescriptor this_ptr_conv;
62734         this_ptr_conv.inner = untag_ptr(this_ptr);
62735         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62737         this_ptr_conv.is_owned = false;
62738         HTLCDescriptor_set_per_commitment_number(&this_ptr_conv, val);
62739 }
62740
62741 int8_tArray  CS_LDK_HTLCDescriptor_get_per_commitment_point(int64_t this_ptr) {
62742         LDKHTLCDescriptor this_ptr_conv;
62743         this_ptr_conv.inner = untag_ptr(this_ptr);
62744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62746         this_ptr_conv.is_owned = false;
62747         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
62748         memcpy(ret_arr->elems, HTLCDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
62749         return ret_arr;
62750 }
62751
62752 void  CS_LDK_HTLCDescriptor_set_per_commitment_point(int64_t this_ptr, int8_tArray val) {
62753         LDKHTLCDescriptor this_ptr_conv;
62754         this_ptr_conv.inner = untag_ptr(this_ptr);
62755         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62757         this_ptr_conv.is_owned = false;
62758         LDKPublicKey val_ref;
62759         CHECK(val->arr_len == 33);
62760         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
62761         HTLCDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
62762 }
62763
62764 int32_t  CS_LDK_HTLCDescriptor_get_feerate_per_kw(int64_t this_ptr) {
62765         LDKHTLCDescriptor this_ptr_conv;
62766         this_ptr_conv.inner = untag_ptr(this_ptr);
62767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62769         this_ptr_conv.is_owned = false;
62770         int32_t ret_conv = HTLCDescriptor_get_feerate_per_kw(&this_ptr_conv);
62771         return ret_conv;
62772 }
62773
62774 void  CS_LDK_HTLCDescriptor_set_feerate_per_kw(int64_t this_ptr, int32_t val) {
62775         LDKHTLCDescriptor this_ptr_conv;
62776         this_ptr_conv.inner = untag_ptr(this_ptr);
62777         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62779         this_ptr_conv.is_owned = false;
62780         HTLCDescriptor_set_feerate_per_kw(&this_ptr_conv, val);
62781 }
62782
62783 int64_t  CS_LDK_HTLCDescriptor_get_htlc(int64_t this_ptr) {
62784         LDKHTLCDescriptor this_ptr_conv;
62785         this_ptr_conv.inner = untag_ptr(this_ptr);
62786         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62788         this_ptr_conv.is_owned = false;
62789         LDKHTLCOutputInCommitment ret_var = HTLCDescriptor_get_htlc(&this_ptr_conv);
62790         int64_t ret_ref = 0;
62791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62792         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62793         return ret_ref;
62794 }
62795
62796 void  CS_LDK_HTLCDescriptor_set_htlc(int64_t this_ptr, int64_t val) {
62797         LDKHTLCDescriptor this_ptr_conv;
62798         this_ptr_conv.inner = untag_ptr(this_ptr);
62799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62801         this_ptr_conv.is_owned = false;
62802         LDKHTLCOutputInCommitment val_conv;
62803         val_conv.inner = untag_ptr(val);
62804         val_conv.is_owned = ptr_is_owned(val);
62805         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
62806         val_conv = HTLCOutputInCommitment_clone(&val_conv);
62807         HTLCDescriptor_set_htlc(&this_ptr_conv, val_conv);
62808 }
62809
62810 int64_t  CS_LDK_HTLCDescriptor_get_preimage(int64_t this_ptr) {
62811         LDKHTLCDescriptor this_ptr_conv;
62812         this_ptr_conv.inner = untag_ptr(this_ptr);
62813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62815         this_ptr_conv.is_owned = false;
62816         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
62817         *ret_copy = HTLCDescriptor_get_preimage(&this_ptr_conv);
62818         int64_t ret_ref = tag_ptr(ret_copy, true);
62819         return ret_ref;
62820 }
62821
62822 void  CS_LDK_HTLCDescriptor_set_preimage(int64_t this_ptr, int64_t val) {
62823         LDKHTLCDescriptor this_ptr_conv;
62824         this_ptr_conv.inner = untag_ptr(this_ptr);
62825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62827         this_ptr_conv.is_owned = false;
62828         void* val_ptr = untag_ptr(val);
62829         CHECK_ACCESS(val_ptr);
62830         LDKCOption_ThirtyTwoBytesZ val_conv = *(LDKCOption_ThirtyTwoBytesZ*)(val_ptr);
62831         val_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(val));
62832         HTLCDescriptor_set_preimage(&this_ptr_conv, val_conv);
62833 }
62834
62835 int8_tArray  CS_LDK_HTLCDescriptor_get_counterparty_sig(int64_t this_ptr) {
62836         LDKHTLCDescriptor this_ptr_conv;
62837         this_ptr_conv.inner = untag_ptr(this_ptr);
62838         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62840         this_ptr_conv.is_owned = false;
62841         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
62842         memcpy(ret_arr->elems, HTLCDescriptor_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
62843         return ret_arr;
62844 }
62845
62846 void  CS_LDK_HTLCDescriptor_set_counterparty_sig(int64_t this_ptr, int8_tArray val) {
62847         LDKHTLCDescriptor this_ptr_conv;
62848         this_ptr_conv.inner = untag_ptr(this_ptr);
62849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
62850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
62851         this_ptr_conv.is_owned = false;
62852         LDKECDSASignature val_ref;
62853         CHECK(val->arr_len == 64);
62854         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
62855         HTLCDescriptor_set_counterparty_sig(&this_ptr_conv, val_ref);
62856 }
62857
62858 static inline uint64_t HTLCDescriptor_clone_ptr(LDKHTLCDescriptor *NONNULL_PTR arg) {
62859         LDKHTLCDescriptor ret_var = HTLCDescriptor_clone(arg);
62860         int64_t ret_ref = 0;
62861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62863         return ret_ref;
62864 }
62865 int64_t  CS_LDK_HTLCDescriptor_clone_ptr(int64_t arg) {
62866         LDKHTLCDescriptor arg_conv;
62867         arg_conv.inner = untag_ptr(arg);
62868         arg_conv.is_owned = ptr_is_owned(arg);
62869         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
62870         arg_conv.is_owned = false;
62871         int64_t ret_conv = HTLCDescriptor_clone_ptr(&arg_conv);
62872         return ret_conv;
62873 }
62874
62875 int64_t  CS_LDK_HTLCDescriptor_clone(int64_t orig) {
62876         LDKHTLCDescriptor orig_conv;
62877         orig_conv.inner = untag_ptr(orig);
62878         orig_conv.is_owned = ptr_is_owned(orig);
62879         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
62880         orig_conv.is_owned = false;
62881         LDKHTLCDescriptor ret_var = HTLCDescriptor_clone(&orig_conv);
62882         int64_t ret_ref = 0;
62883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62885         return ret_ref;
62886 }
62887
62888 jboolean  CS_LDK_HTLCDescriptor_eq(int64_t a, int64_t b) {
62889         LDKHTLCDescriptor a_conv;
62890         a_conv.inner = untag_ptr(a);
62891         a_conv.is_owned = ptr_is_owned(a);
62892         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
62893         a_conv.is_owned = false;
62894         LDKHTLCDescriptor b_conv;
62895         b_conv.inner = untag_ptr(b);
62896         b_conv.is_owned = ptr_is_owned(b);
62897         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
62898         b_conv.is_owned = false;
62899         jboolean ret_conv = HTLCDescriptor_eq(&a_conv, &b_conv);
62900         return ret_conv;
62901 }
62902
62903 int8_tArray  CS_LDK_HTLCDescriptor_write(int64_t obj) {
62904         LDKHTLCDescriptor obj_conv;
62905         obj_conv.inner = untag_ptr(obj);
62906         obj_conv.is_owned = ptr_is_owned(obj);
62907         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
62908         obj_conv.is_owned = false;
62909         LDKCVec_u8Z ret_var = HTLCDescriptor_write(&obj_conv);
62910         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62911         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62912         CVec_u8Z_free(ret_var);
62913         return ret_arr;
62914 }
62915
62916 int64_t  CS_LDK_HTLCDescriptor_read(int8_tArray ser) {
62917         LDKu8slice ser_ref;
62918         ser_ref.datalen = ser->arr_len;
62919         ser_ref.data = ser->elems;
62920         LDKCResult_HTLCDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCDescriptorDecodeErrorZ), "LDKCResult_HTLCDescriptorDecodeErrorZ");
62921         *ret_conv = HTLCDescriptor_read(ser_ref);
62922         FREE(ser);
62923         return tag_ptr(ret_conv, true);
62924 }
62925
62926 int64_t  CS_LDK_HTLCDescriptor_outpoint(int64_t this_arg) {
62927         LDKHTLCDescriptor this_arg_conv;
62928         this_arg_conv.inner = untag_ptr(this_arg);
62929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62931         this_arg_conv.is_owned = false;
62932         LDKOutPoint ret_var = HTLCDescriptor_outpoint(&this_arg_conv);
62933         int64_t ret_ref = 0;
62934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
62935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
62936         return ret_ref;
62937 }
62938
62939 int64_t  CS_LDK_HTLCDescriptor_previous_utxo(int64_t this_arg) {
62940         LDKHTLCDescriptor this_arg_conv;
62941         this_arg_conv.inner = untag_ptr(this_arg);
62942         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62944         this_arg_conv.is_owned = false;
62945         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
62946         *ret_ref = HTLCDescriptor_previous_utxo(&this_arg_conv);
62947         return tag_ptr(ret_ref, true);
62948 }
62949
62950 int64_t  CS_LDK_HTLCDescriptor_unsigned_tx_input(int64_t this_arg) {
62951         LDKHTLCDescriptor this_arg_conv;
62952         this_arg_conv.inner = untag_ptr(this_arg);
62953         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62955         this_arg_conv.is_owned = false;
62956         LDKTxIn* ret_ref = MALLOC(sizeof(LDKTxIn), "LDKTxIn");
62957         *ret_ref = HTLCDescriptor_unsigned_tx_input(&this_arg_conv);
62958         return tag_ptr(ret_ref, true);
62959 }
62960
62961 int64_t  CS_LDK_HTLCDescriptor_tx_output(int64_t this_arg) {
62962         LDKHTLCDescriptor this_arg_conv;
62963         this_arg_conv.inner = untag_ptr(this_arg);
62964         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62966         this_arg_conv.is_owned = false;
62967         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
62968         *ret_ref = HTLCDescriptor_tx_output(&this_arg_conv);
62969         return tag_ptr(ret_ref, true);
62970 }
62971
62972 int8_tArray  CS_LDK_HTLCDescriptor_witness_script(int64_t this_arg) {
62973         LDKHTLCDescriptor this_arg_conv;
62974         this_arg_conv.inner = untag_ptr(this_arg);
62975         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62977         this_arg_conv.is_owned = false;
62978         LDKCVec_u8Z ret_var = HTLCDescriptor_witness_script(&this_arg_conv);
62979         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62980         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
62981         CVec_u8Z_free(ret_var);
62982         return ret_arr;
62983 }
62984
62985 int8_tArray  CS_LDK_HTLCDescriptor_tx_input_witness(int64_t this_arg, int8_tArray signature, int8_tArray witness_script) {
62986         LDKHTLCDescriptor this_arg_conv;
62987         this_arg_conv.inner = untag_ptr(this_arg);
62988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
62989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
62990         this_arg_conv.is_owned = false;
62991         LDKECDSASignature signature_ref;
62992         CHECK(signature->arr_len == 64);
62993         memcpy(signature_ref.compact_form, signature->elems, 64); FREE(signature);
62994         LDKu8slice witness_script_ref;
62995         witness_script_ref.datalen = witness_script->arr_len;
62996         witness_script_ref.data = witness_script->elems;
62997         LDKWitness ret_var = HTLCDescriptor_tx_input_witness(&this_arg_conv, signature_ref, witness_script_ref);
62998         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
62999         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
63000         Witness_free(ret_var);
63001         FREE(witness_script);
63002         return ret_arr;
63003 }
63004
63005 int64_t  CS_LDK_HTLCDescriptor_derive_channel_signer(int64_t this_arg, int64_t signer_provider) {
63006         LDKHTLCDescriptor this_arg_conv;
63007         this_arg_conv.inner = untag_ptr(this_arg);
63008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63010         this_arg_conv.is_owned = false;
63011         void* signer_provider_ptr = untag_ptr(signer_provider);
63012         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
63013         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
63014         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63015         *ret_ret = HTLCDescriptor_derive_channel_signer(&this_arg_conv, signer_provider_conv);
63016         return tag_ptr(ret_ret, true);
63017 }
63018
63019 void  CS_LDK_ChannelSigner_free(int64_t this_ptr) {
63020         if (!ptr_is_owned(this_ptr)) return;
63021         void* this_ptr_ptr = untag_ptr(this_ptr);
63022         CHECK_ACCESS(this_ptr_ptr);
63023         LDKChannelSigner this_ptr_conv = *(LDKChannelSigner*)(this_ptr_ptr);
63024         FREE(untag_ptr(this_ptr));
63025         ChannelSigner_free(this_ptr_conv);
63026 }
63027
63028 void  CS_LDK_EcdsaChannelSigner_free(int64_t this_ptr) {
63029         if (!ptr_is_owned(this_ptr)) return;
63030         void* this_ptr_ptr = untag_ptr(this_ptr);
63031         CHECK_ACCESS(this_ptr_ptr);
63032         LDKEcdsaChannelSigner this_ptr_conv = *(LDKEcdsaChannelSigner*)(this_ptr_ptr);
63033         FREE(untag_ptr(this_ptr));
63034         EcdsaChannelSigner_free(this_ptr_conv);
63035 }
63036
63037 static inline uint64_t WriteableEcdsaChannelSigner_clone_ptr(LDKWriteableEcdsaChannelSigner *NONNULL_PTR arg) {
63038         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63039         *ret_ret = WriteableEcdsaChannelSigner_clone(arg);
63040         return tag_ptr(ret_ret, true);
63041 }
63042 int64_t  CS_LDK_WriteableEcdsaChannelSigner_clone_ptr(int64_t arg) {
63043         void* arg_ptr = untag_ptr(arg);
63044         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
63045         LDKWriteableEcdsaChannelSigner* arg_conv = (LDKWriteableEcdsaChannelSigner*)arg_ptr;
63046         int64_t ret_conv = WriteableEcdsaChannelSigner_clone_ptr(arg_conv);
63047         return ret_conv;
63048 }
63049
63050 int64_t  CS_LDK_WriteableEcdsaChannelSigner_clone(int64_t orig) {
63051         void* orig_ptr = untag_ptr(orig);
63052         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
63053         LDKWriteableEcdsaChannelSigner* orig_conv = (LDKWriteableEcdsaChannelSigner*)orig_ptr;
63054         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63055         *ret_ret = WriteableEcdsaChannelSigner_clone(orig_conv);
63056         return tag_ptr(ret_ret, true);
63057 }
63058
63059 void  CS_LDK_WriteableEcdsaChannelSigner_free(int64_t this_ptr) {
63060         if (!ptr_is_owned(this_ptr)) return;
63061         void* this_ptr_ptr = untag_ptr(this_ptr);
63062         CHECK_ACCESS(this_ptr_ptr);
63063         LDKWriteableEcdsaChannelSigner this_ptr_conv = *(LDKWriteableEcdsaChannelSigner*)(this_ptr_ptr);
63064         FREE(untag_ptr(this_ptr));
63065         WriteableEcdsaChannelSigner_free(this_ptr_conv);
63066 }
63067
63068 int32_t  CS_LDK_Recipient_clone(int64_t orig) {
63069         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
63070         int32_t ret_conv = LDKRecipient_to_cs(Recipient_clone(orig_conv));
63071         return ret_conv;
63072 }
63073
63074 int32_t  CS_LDK_Recipient_node() {
63075         int32_t ret_conv = LDKRecipient_to_cs(Recipient_node());
63076         return ret_conv;
63077 }
63078
63079 int32_t  CS_LDK_Recipient_phantom_node() {
63080         int32_t ret_conv = LDKRecipient_to_cs(Recipient_phantom_node());
63081         return ret_conv;
63082 }
63083
63084 void  CS_LDK_EntropySource_free(int64_t this_ptr) {
63085         if (!ptr_is_owned(this_ptr)) return;
63086         void* this_ptr_ptr = untag_ptr(this_ptr);
63087         CHECK_ACCESS(this_ptr_ptr);
63088         LDKEntropySource this_ptr_conv = *(LDKEntropySource*)(this_ptr_ptr);
63089         FREE(untag_ptr(this_ptr));
63090         EntropySource_free(this_ptr_conv);
63091 }
63092
63093 void  CS_LDK_NodeSigner_free(int64_t this_ptr) {
63094         if (!ptr_is_owned(this_ptr)) return;
63095         void* this_ptr_ptr = untag_ptr(this_ptr);
63096         CHECK_ACCESS(this_ptr_ptr);
63097         LDKNodeSigner this_ptr_conv = *(LDKNodeSigner*)(this_ptr_ptr);
63098         FREE(untag_ptr(this_ptr));
63099         NodeSigner_free(this_ptr_conv);
63100 }
63101
63102 void  CS_LDK_SignerProvider_free(int64_t this_ptr) {
63103         if (!ptr_is_owned(this_ptr)) return;
63104         void* this_ptr_ptr = untag_ptr(this_ptr);
63105         CHECK_ACCESS(this_ptr_ptr);
63106         LDKSignerProvider this_ptr_conv = *(LDKSignerProvider*)(this_ptr_ptr);
63107         FREE(untag_ptr(this_ptr));
63108         SignerProvider_free(this_ptr_conv);
63109 }
63110
63111 void  CS_LDK_InMemorySigner_free(int64_t this_obj) {
63112         LDKInMemorySigner this_obj_conv;
63113         this_obj_conv.inner = untag_ptr(this_obj);
63114         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63116         InMemorySigner_free(this_obj_conv);
63117 }
63118
63119 int8_tArray  CS_LDK_InMemorySigner_get_funding_key(int64_t this_ptr) {
63120         LDKInMemorySigner this_ptr_conv;
63121         this_ptr_conv.inner = untag_ptr(this_ptr);
63122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63124         this_ptr_conv.is_owned = false;
63125         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63126         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
63127         return ret_arr;
63128 }
63129
63130 void  CS_LDK_InMemorySigner_set_funding_key(int64_t this_ptr, int8_tArray val) {
63131         LDKInMemorySigner this_ptr_conv;
63132         this_ptr_conv.inner = untag_ptr(this_ptr);
63133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63135         this_ptr_conv.is_owned = false;
63136         LDKSecretKey val_ref;
63137         CHECK(val->arr_len == 32);
63138         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63139         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
63140 }
63141
63142 int8_tArray  CS_LDK_InMemorySigner_get_revocation_base_key(int64_t this_ptr) {
63143         LDKInMemorySigner this_ptr_conv;
63144         this_ptr_conv.inner = untag_ptr(this_ptr);
63145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63147         this_ptr_conv.is_owned = false;
63148         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63149         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
63150         return ret_arr;
63151 }
63152
63153 void  CS_LDK_InMemorySigner_set_revocation_base_key(int64_t this_ptr, int8_tArray val) {
63154         LDKInMemorySigner this_ptr_conv;
63155         this_ptr_conv.inner = untag_ptr(this_ptr);
63156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63158         this_ptr_conv.is_owned = false;
63159         LDKSecretKey val_ref;
63160         CHECK(val->arr_len == 32);
63161         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63162         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
63163 }
63164
63165 int8_tArray  CS_LDK_InMemorySigner_get_payment_key(int64_t this_ptr) {
63166         LDKInMemorySigner this_ptr_conv;
63167         this_ptr_conv.inner = untag_ptr(this_ptr);
63168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63170         this_ptr_conv.is_owned = false;
63171         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63172         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
63173         return ret_arr;
63174 }
63175
63176 void  CS_LDK_InMemorySigner_set_payment_key(int64_t this_ptr, int8_tArray val) {
63177         LDKInMemorySigner this_ptr_conv;
63178         this_ptr_conv.inner = untag_ptr(this_ptr);
63179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63181         this_ptr_conv.is_owned = false;
63182         LDKSecretKey val_ref;
63183         CHECK(val->arr_len == 32);
63184         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63185         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
63186 }
63187
63188 int8_tArray  CS_LDK_InMemorySigner_get_delayed_payment_base_key(int64_t this_ptr) {
63189         LDKInMemorySigner this_ptr_conv;
63190         this_ptr_conv.inner = untag_ptr(this_ptr);
63191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63193         this_ptr_conv.is_owned = false;
63194         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63195         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
63196         return ret_arr;
63197 }
63198
63199 void  CS_LDK_InMemorySigner_set_delayed_payment_base_key(int64_t this_ptr, int8_tArray val) {
63200         LDKInMemorySigner this_ptr_conv;
63201         this_ptr_conv.inner = untag_ptr(this_ptr);
63202         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63204         this_ptr_conv.is_owned = false;
63205         LDKSecretKey val_ref;
63206         CHECK(val->arr_len == 32);
63207         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63208         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
63209 }
63210
63211 int8_tArray  CS_LDK_InMemorySigner_get_htlc_base_key(int64_t this_ptr) {
63212         LDKInMemorySigner this_ptr_conv;
63213         this_ptr_conv.inner = untag_ptr(this_ptr);
63214         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63216         this_ptr_conv.is_owned = false;
63217         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63218         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
63219         return ret_arr;
63220 }
63221
63222 void  CS_LDK_InMemorySigner_set_htlc_base_key(int64_t this_ptr, int8_tArray val) {
63223         LDKInMemorySigner this_ptr_conv;
63224         this_ptr_conv.inner = untag_ptr(this_ptr);
63225         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63227         this_ptr_conv.is_owned = false;
63228         LDKSecretKey val_ref;
63229         CHECK(val->arr_len == 32);
63230         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
63231         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
63232 }
63233
63234 int8_tArray  CS_LDK_InMemorySigner_get_commitment_seed(int64_t this_ptr) {
63235         LDKInMemorySigner this_ptr_conv;
63236         this_ptr_conv.inner = untag_ptr(this_ptr);
63237         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63239         this_ptr_conv.is_owned = false;
63240         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63241         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
63242         return ret_arr;
63243 }
63244
63245 void  CS_LDK_InMemorySigner_set_commitment_seed(int64_t this_ptr, int8_tArray val) {
63246         LDKInMemorySigner this_ptr_conv;
63247         this_ptr_conv.inner = untag_ptr(this_ptr);
63248         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63250         this_ptr_conv.is_owned = false;
63251         LDKThirtyTwoBytes val_ref;
63252         CHECK(val->arr_len == 32);
63253         memcpy(val_ref.data, val->elems, 32); FREE(val);
63254         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
63255 }
63256
63257 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
63258         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
63259         int64_t ret_ref = 0;
63260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63261         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63262         return ret_ref;
63263 }
63264 int64_t  CS_LDK_InMemorySigner_clone_ptr(int64_t arg) {
63265         LDKInMemorySigner arg_conv;
63266         arg_conv.inner = untag_ptr(arg);
63267         arg_conv.is_owned = ptr_is_owned(arg);
63268         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
63269         arg_conv.is_owned = false;
63270         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
63271         return ret_conv;
63272 }
63273
63274 int64_t  CS_LDK_InMemorySigner_clone(int64_t orig) {
63275         LDKInMemorySigner orig_conv;
63276         orig_conv.inner = untag_ptr(orig);
63277         orig_conv.is_owned = ptr_is_owned(orig);
63278         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
63279         orig_conv.is_owned = false;
63280         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
63281         int64_t ret_ref = 0;
63282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63283         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63284         return ret_ref;
63285 }
63286
63287 int64_t  CS_LDK_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, int8_tArray rand_bytes_unique_start) {
63288         LDKSecretKey funding_key_ref;
63289         CHECK(funding_key->arr_len == 32);
63290         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
63291         LDKSecretKey revocation_base_key_ref;
63292         CHECK(revocation_base_key->arr_len == 32);
63293         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
63294         LDKSecretKey payment_key_ref;
63295         CHECK(payment_key->arr_len == 32);
63296         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
63297         LDKSecretKey delayed_payment_base_key_ref;
63298         CHECK(delayed_payment_base_key->arr_len == 32);
63299         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
63300         LDKSecretKey htlc_base_key_ref;
63301         CHECK(htlc_base_key->arr_len == 32);
63302         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
63303         LDKThirtyTwoBytes commitment_seed_ref;
63304         CHECK(commitment_seed->arr_len == 32);
63305         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
63306         LDKThirtyTwoBytes channel_keys_id_ref;
63307         CHECK(channel_keys_id->arr_len == 32);
63308         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
63309         LDKThirtyTwoBytes rand_bytes_unique_start_ref;
63310         CHECK(rand_bytes_unique_start->arr_len == 32);
63311         memcpy(rand_bytes_unique_start_ref.data, rand_bytes_unique_start->elems, 32); FREE(rand_bytes_unique_start);
63312         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, rand_bytes_unique_start_ref);
63313         int64_t ret_ref = 0;
63314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63316         return ret_ref;
63317 }
63318
63319 int64_t  CS_LDK_InMemorySigner_counterparty_pubkeys(int64_t this_arg) {
63320         LDKInMemorySigner this_arg_conv;
63321         this_arg_conv.inner = untag_ptr(this_arg);
63322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63324         this_arg_conv.is_owned = false;
63325         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
63326         int64_t ret_ref = 0;
63327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63329         return ret_ref;
63330 }
63331
63332 int64_t  CS_LDK_InMemorySigner_counterparty_selected_contest_delay(int64_t this_arg) {
63333         LDKInMemorySigner this_arg_conv;
63334         this_arg_conv.inner = untag_ptr(this_arg);
63335         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63337         this_arg_conv.is_owned = false;
63338         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
63339         *ret_copy = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
63340         int64_t ret_ref = tag_ptr(ret_copy, true);
63341         return ret_ref;
63342 }
63343
63344 int64_t  CS_LDK_InMemorySigner_holder_selected_contest_delay(int64_t this_arg) {
63345         LDKInMemorySigner this_arg_conv;
63346         this_arg_conv.inner = untag_ptr(this_arg);
63347         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63349         this_arg_conv.is_owned = false;
63350         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
63351         *ret_copy = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
63352         int64_t ret_ref = tag_ptr(ret_copy, true);
63353         return ret_ref;
63354 }
63355
63356 int64_t  CS_LDK_InMemorySigner_is_outbound(int64_t this_arg) {
63357         LDKInMemorySigner this_arg_conv;
63358         this_arg_conv.inner = untag_ptr(this_arg);
63359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63361         this_arg_conv.is_owned = false;
63362         LDKCOption_boolZ *ret_copy = MALLOC(sizeof(LDKCOption_boolZ), "LDKCOption_boolZ");
63363         *ret_copy = InMemorySigner_is_outbound(&this_arg_conv);
63364         int64_t ret_ref = tag_ptr(ret_copy, true);
63365         return ret_ref;
63366 }
63367
63368 int64_t  CS_LDK_InMemorySigner_funding_outpoint(int64_t this_arg) {
63369         LDKInMemorySigner this_arg_conv;
63370         this_arg_conv.inner = untag_ptr(this_arg);
63371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63373         this_arg_conv.is_owned = false;
63374         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
63375         int64_t ret_ref = 0;
63376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63377         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63378         return ret_ref;
63379 }
63380
63381 int64_t  CS_LDK_InMemorySigner_get_channel_parameters(int64_t this_arg) {
63382         LDKInMemorySigner this_arg_conv;
63383         this_arg_conv.inner = untag_ptr(this_arg);
63384         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63386         this_arg_conv.is_owned = false;
63387         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
63388         int64_t ret_ref = 0;
63389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63390         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63391         return ret_ref;
63392 }
63393
63394 int64_t  CS_LDK_InMemorySigner_channel_type_features(int64_t this_arg) {
63395         LDKInMemorySigner this_arg_conv;
63396         this_arg_conv.inner = untag_ptr(this_arg);
63397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63399         this_arg_conv.is_owned = false;
63400         LDKChannelTypeFeatures ret_var = InMemorySigner_channel_type_features(&this_arg_conv);
63401         int64_t ret_ref = 0;
63402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63404         return ret_ref;
63405 }
63406
63407 int64_t  CS_LDK_InMemorySigner_sign_counterparty_payment_input(int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
63408         LDKInMemorySigner this_arg_conv;
63409         this_arg_conv.inner = untag_ptr(this_arg);
63410         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63412         this_arg_conv.is_owned = false;
63413         LDKTransaction spend_tx_ref;
63414         spend_tx_ref.datalen = spend_tx->arr_len;
63415         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
63416         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
63417         spend_tx_ref.data_is_owned = true;
63418         LDKStaticPaymentOutputDescriptor descriptor_conv;
63419         descriptor_conv.inner = untag_ptr(descriptor);
63420         descriptor_conv.is_owned = ptr_is_owned(descriptor);
63421         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
63422         descriptor_conv.is_owned = false;
63423         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
63424         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
63425         return tag_ptr(ret_conv, true);
63426 }
63427
63428 int64_t  CS_LDK_InMemorySigner_sign_dynamic_p2wsh_input(int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
63429         LDKInMemorySigner this_arg_conv;
63430         this_arg_conv.inner = untag_ptr(this_arg);
63431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63433         this_arg_conv.is_owned = false;
63434         LDKTransaction spend_tx_ref;
63435         spend_tx_ref.datalen = spend_tx->arr_len;
63436         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
63437         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
63438         spend_tx_ref.data_is_owned = true;
63439         LDKDelayedPaymentOutputDescriptor descriptor_conv;
63440         descriptor_conv.inner = untag_ptr(descriptor);
63441         descriptor_conv.is_owned = ptr_is_owned(descriptor);
63442         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
63443         descriptor_conv.is_owned = false;
63444         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
63445         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
63446         return tag_ptr(ret_conv, true);
63447 }
63448
63449 int64_t  CS_LDK_InMemorySigner_as_EntropySource(int64_t this_arg) {
63450         LDKInMemorySigner this_arg_conv;
63451         this_arg_conv.inner = untag_ptr(this_arg);
63452         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63454         this_arg_conv.is_owned = false;
63455         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
63456         *ret_ret = InMemorySigner_as_EntropySource(&this_arg_conv);
63457         return tag_ptr(ret_ret, true);
63458 }
63459
63460 int64_t  CS_LDK_InMemorySigner_as_ChannelSigner(int64_t this_arg) {
63461         LDKInMemorySigner this_arg_conv;
63462         this_arg_conv.inner = untag_ptr(this_arg);
63463         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63465         this_arg_conv.is_owned = false;
63466         LDKChannelSigner* ret_ret = MALLOC(sizeof(LDKChannelSigner), "LDKChannelSigner");
63467         *ret_ret = InMemorySigner_as_ChannelSigner(&this_arg_conv);
63468         return tag_ptr(ret_ret, true);
63469 }
63470
63471 int64_t  CS_LDK_InMemorySigner_as_EcdsaChannelSigner(int64_t this_arg) {
63472         LDKInMemorySigner this_arg_conv;
63473         this_arg_conv.inner = untag_ptr(this_arg);
63474         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63476         this_arg_conv.is_owned = false;
63477         LDKEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKEcdsaChannelSigner), "LDKEcdsaChannelSigner");
63478         *ret_ret = InMemorySigner_as_EcdsaChannelSigner(&this_arg_conv);
63479         return tag_ptr(ret_ret, true);
63480 }
63481
63482 int64_t  CS_LDK_InMemorySigner_as_WriteableEcdsaChannelSigner(int64_t this_arg) {
63483         LDKInMemorySigner this_arg_conv;
63484         this_arg_conv.inner = untag_ptr(this_arg);
63485         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63487         this_arg_conv.is_owned = false;
63488         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
63489         *ret_ret = InMemorySigner_as_WriteableEcdsaChannelSigner(&this_arg_conv);
63490         return tag_ptr(ret_ret, true);
63491 }
63492
63493 int8_tArray  CS_LDK_InMemorySigner_write(int64_t obj) {
63494         LDKInMemorySigner obj_conv;
63495         obj_conv.inner = untag_ptr(obj);
63496         obj_conv.is_owned = ptr_is_owned(obj);
63497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
63498         obj_conv.is_owned = false;
63499         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
63500         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
63501         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
63502         CVec_u8Z_free(ret_var);
63503         return ret_arr;
63504 }
63505
63506 int64_t  CS_LDK_InMemorySigner_read(int8_tArray ser, int64_t arg) {
63507         LDKu8slice ser_ref;
63508         ser_ref.datalen = ser->arr_len;
63509         ser_ref.data = ser->elems;
63510         void* arg_ptr = untag_ptr(arg);
63511         CHECK_ACCESS(arg_ptr);
63512         LDKEntropySource arg_conv = *(LDKEntropySource*)(arg_ptr);
63513         if (arg_conv.free == LDKEntropySource_JCalls_free) {
63514                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
63515                 LDKEntropySource_JCalls_cloned(&arg_conv);
63516         }
63517         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
63518         *ret_conv = InMemorySigner_read(ser_ref, arg_conv);
63519         FREE(ser);
63520         return tag_ptr(ret_conv, true);
63521 }
63522
63523 void  CS_LDK_KeysManager_free(int64_t this_obj) {
63524         LDKKeysManager this_obj_conv;
63525         this_obj_conv.inner = untag_ptr(this_obj);
63526         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63528         KeysManager_free(this_obj_conv);
63529 }
63530
63531 int64_t  CS_LDK_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
63532         uint8_t seed_arr[32];
63533         CHECK(seed->arr_len == 32);
63534         memcpy(seed_arr, seed->elems, 32); FREE(seed);
63535         uint8_t (*seed_ref)[32] = &seed_arr;
63536         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
63537         int64_t ret_ref = 0;
63538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63539         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63540         return ret_ref;
63541 }
63542
63543 int8_tArray  CS_LDK_KeysManager_get_node_secret_key(int64_t this_arg) {
63544         LDKKeysManager this_arg_conv;
63545         this_arg_conv.inner = untag_ptr(this_arg);
63546         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63548         this_arg_conv.is_owned = false;
63549         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63550         memcpy(ret_arr->elems, KeysManager_get_node_secret_key(&this_arg_conv).bytes, 32);
63551         return ret_arr;
63552 }
63553
63554 int64_t  CS_LDK_KeysManager_derive_channel_keys(int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
63555         LDKKeysManager this_arg_conv;
63556         this_arg_conv.inner = untag_ptr(this_arg);
63557         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63559         this_arg_conv.is_owned = false;
63560         uint8_t params_arr[32];
63561         CHECK(params->arr_len == 32);
63562         memcpy(params_arr, params->elems, 32); FREE(params);
63563         uint8_t (*params_ref)[32] = &params_arr;
63564         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
63565         int64_t ret_ref = 0;
63566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63567         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63568         return ret_ref;
63569 }
63570
63571 int64_t  CS_LDK_KeysManager_sign_spendable_outputs_psbt(int64_t this_arg, int64_tArray descriptors, int8_tArray psbt) {
63572         LDKKeysManager this_arg_conv;
63573         this_arg_conv.inner = untag_ptr(this_arg);
63574         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63576         this_arg_conv.is_owned = false;
63577         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
63578         descriptors_constr.datalen = descriptors->arr_len;
63579         if (descriptors_constr.datalen > 0)
63580                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
63581         else
63582                 descriptors_constr.data = NULL;
63583         int64_t* descriptors_vals = descriptors->elems;
63584         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
63585                 int64_t descriptors_conv_27 = descriptors_vals[b];
63586                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
63587                 CHECK_ACCESS(descriptors_conv_27_ptr);
63588                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
63589                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
63590                 descriptors_constr.data[b] = descriptors_conv_27_conv;
63591         }
63592         FREE(descriptors);
63593         LDKCVec_u8Z psbt_ref;
63594         psbt_ref.datalen = psbt->arr_len;
63595         psbt_ref.data = MALLOC(psbt_ref.datalen, "LDKCVec_u8Z Bytes");
63596         memcpy(psbt_ref.data, psbt->elems, psbt_ref.datalen); FREE(psbt);
63597         LDKCResult_CVec_u8ZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZNoneZ), "LDKCResult_CVec_u8ZNoneZ");
63598         *ret_conv = KeysManager_sign_spendable_outputs_psbt(&this_arg_conv, descriptors_constr, psbt_ref);
63599         return tag_ptr(ret_conv, true);
63600 }
63601
63602 int64_t  CS_LDK_KeysManager_spend_spendable_outputs(int64_t this_arg, int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight, int64_t locktime) {
63603         LDKKeysManager this_arg_conv;
63604         this_arg_conv.inner = untag_ptr(this_arg);
63605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63607         this_arg_conv.is_owned = false;
63608         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
63609         descriptors_constr.datalen = descriptors->arr_len;
63610         if (descriptors_constr.datalen > 0)
63611                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
63612         else
63613                 descriptors_constr.data = NULL;
63614         int64_t* descriptors_vals = descriptors->elems;
63615         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
63616                 int64_t descriptors_conv_27 = descriptors_vals[b];
63617                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
63618                 CHECK_ACCESS(descriptors_conv_27_ptr);
63619                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
63620                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
63621                 descriptors_constr.data[b] = descriptors_conv_27_conv;
63622         }
63623         FREE(descriptors);
63624         LDKCVec_TxOutZ outputs_constr;
63625         outputs_constr.datalen = outputs->arr_len;
63626         if (outputs_constr.datalen > 0)
63627                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
63628         else
63629                 outputs_constr.data = NULL;
63630         int64_t* outputs_vals = outputs->elems;
63631         for (size_t h = 0; h < outputs_constr.datalen; h++) {
63632                 int64_t outputs_conv_7 = outputs_vals[h];
63633                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
63634                 CHECK_ACCESS(outputs_conv_7_ptr);
63635                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
63636                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
63637                 outputs_constr.data[h] = outputs_conv_7_conv;
63638         }
63639         FREE(outputs);
63640         LDKCVec_u8Z change_destination_script_ref;
63641         change_destination_script_ref.datalen = change_destination_script->arr_len;
63642         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
63643         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
63644         void* locktime_ptr = untag_ptr(locktime);
63645         CHECK_ACCESS(locktime_ptr);
63646         LDKCOption_u32Z locktime_conv = *(LDKCOption_u32Z*)(locktime_ptr);
63647         locktime_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(locktime));
63648         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
63649         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight, locktime_conv);
63650         return tag_ptr(ret_conv, true);
63651 }
63652
63653 int64_t  CS_LDK_KeysManager_as_EntropySource(int64_t this_arg) {
63654         LDKKeysManager this_arg_conv;
63655         this_arg_conv.inner = untag_ptr(this_arg);
63656         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63658         this_arg_conv.is_owned = false;
63659         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
63660         *ret_ret = KeysManager_as_EntropySource(&this_arg_conv);
63661         return tag_ptr(ret_ret, true);
63662 }
63663
63664 int64_t  CS_LDK_KeysManager_as_NodeSigner(int64_t this_arg) {
63665         LDKKeysManager this_arg_conv;
63666         this_arg_conv.inner = untag_ptr(this_arg);
63667         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63669         this_arg_conv.is_owned = false;
63670         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
63671         *ret_ret = KeysManager_as_NodeSigner(&this_arg_conv);
63672         return tag_ptr(ret_ret, true);
63673 }
63674
63675 int64_t  CS_LDK_KeysManager_as_SignerProvider(int64_t this_arg) {
63676         LDKKeysManager this_arg_conv;
63677         this_arg_conv.inner = untag_ptr(this_arg);
63678         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63680         this_arg_conv.is_owned = false;
63681         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
63682         *ret_ret = KeysManager_as_SignerProvider(&this_arg_conv);
63683         return tag_ptr(ret_ret, true);
63684 }
63685
63686 void  CS_LDK_PhantomKeysManager_free(int64_t this_obj) {
63687         LDKPhantomKeysManager this_obj_conv;
63688         this_obj_conv.inner = untag_ptr(this_obj);
63689         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63691         PhantomKeysManager_free(this_obj_conv);
63692 }
63693
63694 int64_t  CS_LDK_PhantomKeysManager_as_EntropySource(int64_t this_arg) {
63695         LDKPhantomKeysManager this_arg_conv;
63696         this_arg_conv.inner = untag_ptr(this_arg);
63697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63699         this_arg_conv.is_owned = false;
63700         LDKEntropySource* ret_ret = MALLOC(sizeof(LDKEntropySource), "LDKEntropySource");
63701         *ret_ret = PhantomKeysManager_as_EntropySource(&this_arg_conv);
63702         return tag_ptr(ret_ret, true);
63703 }
63704
63705 int64_t  CS_LDK_PhantomKeysManager_as_NodeSigner(int64_t this_arg) {
63706         LDKPhantomKeysManager this_arg_conv;
63707         this_arg_conv.inner = untag_ptr(this_arg);
63708         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63710         this_arg_conv.is_owned = false;
63711         LDKNodeSigner* ret_ret = MALLOC(sizeof(LDKNodeSigner), "LDKNodeSigner");
63712         *ret_ret = PhantomKeysManager_as_NodeSigner(&this_arg_conv);
63713         return tag_ptr(ret_ret, true);
63714 }
63715
63716 int64_t  CS_LDK_PhantomKeysManager_as_SignerProvider(int64_t this_arg) {
63717         LDKPhantomKeysManager this_arg_conv;
63718         this_arg_conv.inner = untag_ptr(this_arg);
63719         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63721         this_arg_conv.is_owned = false;
63722         LDKSignerProvider* ret_ret = MALLOC(sizeof(LDKSignerProvider), "LDKSignerProvider");
63723         *ret_ret = PhantomKeysManager_as_SignerProvider(&this_arg_conv);
63724         return tag_ptr(ret_ret, true);
63725 }
63726
63727 int64_t  CS_LDK_PhantomKeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos, int8_tArray cross_node_seed) {
63728         uint8_t seed_arr[32];
63729         CHECK(seed->arr_len == 32);
63730         memcpy(seed_arr, seed->elems, 32); FREE(seed);
63731         uint8_t (*seed_ref)[32] = &seed_arr;
63732         uint8_t cross_node_seed_arr[32];
63733         CHECK(cross_node_seed->arr_len == 32);
63734         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
63735         uint8_t (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
63736         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
63737         int64_t ret_ref = 0;
63738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63740         return ret_ref;
63741 }
63742
63743 int64_t  CS_LDK_PhantomKeysManager_spend_spendable_outputs(int64_t this_arg, int64_tArray descriptors, int64_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight, int64_t locktime) {
63744         LDKPhantomKeysManager this_arg_conv;
63745         this_arg_conv.inner = untag_ptr(this_arg);
63746         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63748         this_arg_conv.is_owned = false;
63749         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
63750         descriptors_constr.datalen = descriptors->arr_len;
63751         if (descriptors_constr.datalen > 0)
63752                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
63753         else
63754                 descriptors_constr.data = NULL;
63755         int64_t* descriptors_vals = descriptors->elems;
63756         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
63757                 int64_t descriptors_conv_27 = descriptors_vals[b];
63758                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
63759                 CHECK_ACCESS(descriptors_conv_27_ptr);
63760                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
63761                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
63762                 descriptors_constr.data[b] = descriptors_conv_27_conv;
63763         }
63764         FREE(descriptors);
63765         LDKCVec_TxOutZ outputs_constr;
63766         outputs_constr.datalen = outputs->arr_len;
63767         if (outputs_constr.datalen > 0)
63768                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
63769         else
63770                 outputs_constr.data = NULL;
63771         int64_t* outputs_vals = outputs->elems;
63772         for (size_t h = 0; h < outputs_constr.datalen; h++) {
63773                 int64_t outputs_conv_7 = outputs_vals[h];
63774                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
63775                 CHECK_ACCESS(outputs_conv_7_ptr);
63776                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
63777                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
63778                 outputs_constr.data[h] = outputs_conv_7_conv;
63779         }
63780         FREE(outputs);
63781         LDKCVec_u8Z change_destination_script_ref;
63782         change_destination_script_ref.datalen = change_destination_script->arr_len;
63783         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
63784         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
63785         void* locktime_ptr = untag_ptr(locktime);
63786         CHECK_ACCESS(locktime_ptr);
63787         LDKCOption_u32Z locktime_conv = *(LDKCOption_u32Z*)(locktime_ptr);
63788         locktime_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(locktime));
63789         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
63790         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight, locktime_conv);
63791         return tag_ptr(ret_conv, true);
63792 }
63793
63794 int64_t  CS_LDK_PhantomKeysManager_derive_channel_keys(int64_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
63795         LDKPhantomKeysManager this_arg_conv;
63796         this_arg_conv.inner = untag_ptr(this_arg);
63797         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63799         this_arg_conv.is_owned = false;
63800         uint8_t params_arr[32];
63801         CHECK(params->arr_len == 32);
63802         memcpy(params_arr, params->elems, 32); FREE(params);
63803         uint8_t (*params_ref)[32] = &params_arr;
63804         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
63805         int64_t ret_ref = 0;
63806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63807         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63808         return ret_ref;
63809 }
63810
63811 int8_tArray  CS_LDK_PhantomKeysManager_get_node_secret_key(int64_t this_arg) {
63812         LDKPhantomKeysManager this_arg_conv;
63813         this_arg_conv.inner = untag_ptr(this_arg);
63814         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63816         this_arg_conv.is_owned = false;
63817         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63818         memcpy(ret_arr->elems, PhantomKeysManager_get_node_secret_key(&this_arg_conv).bytes, 32);
63819         return ret_arr;
63820 }
63821
63822 int8_tArray  CS_LDK_PhantomKeysManager_get_phantom_node_secret_key(int64_t this_arg) {
63823         LDKPhantomKeysManager this_arg_conv;
63824         this_arg_conv.inner = untag_ptr(this_arg);
63825         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63827         this_arg_conv.is_owned = false;
63828         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
63829         memcpy(ret_arr->elems, PhantomKeysManager_get_phantom_node_secret_key(&this_arg_conv).bytes, 32);
63830         return ret_arr;
63831 }
63832
63833 void  CS_LDK_OnionMessenger_free(int64_t this_obj) {
63834         LDKOnionMessenger this_obj_conv;
63835         this_obj_conv.inner = untag_ptr(this_obj);
63836         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63838         OnionMessenger_free(this_obj_conv);
63839 }
63840
63841 void  CS_LDK_MessageRouter_free(int64_t this_ptr) {
63842         if (!ptr_is_owned(this_ptr)) return;
63843         void* this_ptr_ptr = untag_ptr(this_ptr);
63844         CHECK_ACCESS(this_ptr_ptr);
63845         LDKMessageRouter this_ptr_conv = *(LDKMessageRouter*)(this_ptr_ptr);
63846         FREE(untag_ptr(this_ptr));
63847         MessageRouter_free(this_ptr_conv);
63848 }
63849
63850 void  CS_LDK_DefaultMessageRouter_free(int64_t this_obj) {
63851         LDKDefaultMessageRouter this_obj_conv;
63852         this_obj_conv.inner = untag_ptr(this_obj);
63853         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63855         DefaultMessageRouter_free(this_obj_conv);
63856 }
63857
63858 int64_t  CS_LDK_DefaultMessageRouter_new() {
63859         LDKDefaultMessageRouter ret_var = DefaultMessageRouter_new();
63860         int64_t ret_ref = 0;
63861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63862         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63863         return ret_ref;
63864 }
63865
63866 int64_t  CS_LDK_DefaultMessageRouter_as_MessageRouter(int64_t this_arg) {
63867         LDKDefaultMessageRouter this_arg_conv;
63868         this_arg_conv.inner = untag_ptr(this_arg);
63869         this_arg_conv.is_owned = ptr_is_owned(this_arg);
63870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
63871         this_arg_conv.is_owned = false;
63872         LDKMessageRouter* ret_ret = MALLOC(sizeof(LDKMessageRouter), "LDKMessageRouter");
63873         *ret_ret = DefaultMessageRouter_as_MessageRouter(&this_arg_conv);
63874         return tag_ptr(ret_ret, true);
63875 }
63876
63877 void  CS_LDK_OnionMessagePath_free(int64_t this_obj) {
63878         LDKOnionMessagePath this_obj_conv;
63879         this_obj_conv.inner = untag_ptr(this_obj);
63880         this_obj_conv.is_owned = ptr_is_owned(this_obj);
63881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
63882         OnionMessagePath_free(this_obj_conv);
63883 }
63884
63885 ptrArray  CS_LDK_OnionMessagePath_get_intermediate_nodes(int64_t this_ptr) {
63886         LDKOnionMessagePath this_ptr_conv;
63887         this_ptr_conv.inner = untag_ptr(this_ptr);
63888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63890         this_ptr_conv.is_owned = false;
63891         LDKCVec_PublicKeyZ ret_var = OnionMessagePath_get_intermediate_nodes(&this_ptr_conv);
63892         ptrArray ret_arr = NULL;
63893         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
63894         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 8);
63895         for (size_t i = 0; i < ret_var.datalen; i++) {
63896                 int8_tArray ret_conv_8_arr = init_int8_tArray(33, __LINE__);
63897                 memcpy(ret_conv_8_arr->elems, ret_var.data[i].compressed_form, 33);
63898                 ret_arr_ptr[i] = ret_conv_8_arr;
63899         }
63900         
63901         FREE(ret_var.data);
63902         return ret_arr;
63903 }
63904
63905 void  CS_LDK_OnionMessagePath_set_intermediate_nodes(int64_t this_ptr, ptrArray val) {
63906         LDKOnionMessagePath this_ptr_conv;
63907         this_ptr_conv.inner = untag_ptr(this_ptr);
63908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63910         this_ptr_conv.is_owned = false;
63911         LDKCVec_PublicKeyZ val_constr;
63912         val_constr.datalen = val->arr_len;
63913         if (val_constr.datalen > 0)
63914                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
63915         else
63916                 val_constr.data = NULL;
63917         int8_tArray* val_vals = (void*) val->elems;
63918         for (size_t i = 0; i < val_constr.datalen; i++) {
63919                 int8_tArray val_conv_8 = val_vals[i];
63920                 LDKPublicKey val_conv_8_ref;
63921                 CHECK(val_conv_8->arr_len == 33);
63922                 memcpy(val_conv_8_ref.compressed_form, val_conv_8->elems, 33); FREE(val_conv_8);
63923                 val_constr.data[i] = val_conv_8_ref;
63924         }
63925         FREE(val);
63926         OnionMessagePath_set_intermediate_nodes(&this_ptr_conv, val_constr);
63927 }
63928
63929 int64_t  CS_LDK_OnionMessagePath_get_destination(int64_t this_ptr) {
63930         LDKOnionMessagePath this_ptr_conv;
63931         this_ptr_conv.inner = untag_ptr(this_ptr);
63932         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63934         this_ptr_conv.is_owned = false;
63935         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
63936         *ret_copy = OnionMessagePath_get_destination(&this_ptr_conv);
63937         int64_t ret_ref = tag_ptr(ret_copy, true);
63938         return ret_ref;
63939 }
63940
63941 void  CS_LDK_OnionMessagePath_set_destination(int64_t this_ptr, int64_t val) {
63942         LDKOnionMessagePath this_ptr_conv;
63943         this_ptr_conv.inner = untag_ptr(this_ptr);
63944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
63945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
63946         this_ptr_conv.is_owned = false;
63947         void* val_ptr = untag_ptr(val);
63948         CHECK_ACCESS(val_ptr);
63949         LDKDestination val_conv = *(LDKDestination*)(val_ptr);
63950         val_conv = Destination_clone((LDKDestination*)untag_ptr(val));
63951         OnionMessagePath_set_destination(&this_ptr_conv, val_conv);
63952 }
63953
63954 int64_t  CS_LDK_OnionMessagePath_new(ptrArray intermediate_nodes_arg, int64_t destination_arg) {
63955         LDKCVec_PublicKeyZ intermediate_nodes_arg_constr;
63956         intermediate_nodes_arg_constr.datalen = intermediate_nodes_arg->arr_len;
63957         if (intermediate_nodes_arg_constr.datalen > 0)
63958                 intermediate_nodes_arg_constr.data = MALLOC(intermediate_nodes_arg_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
63959         else
63960                 intermediate_nodes_arg_constr.data = NULL;
63961         int8_tArray* intermediate_nodes_arg_vals = (void*) intermediate_nodes_arg->elems;
63962         for (size_t i = 0; i < intermediate_nodes_arg_constr.datalen; i++) {
63963                 int8_tArray intermediate_nodes_arg_conv_8 = intermediate_nodes_arg_vals[i];
63964                 LDKPublicKey intermediate_nodes_arg_conv_8_ref;
63965                 CHECK(intermediate_nodes_arg_conv_8->arr_len == 33);
63966                 memcpy(intermediate_nodes_arg_conv_8_ref.compressed_form, intermediate_nodes_arg_conv_8->elems, 33); FREE(intermediate_nodes_arg_conv_8);
63967                 intermediate_nodes_arg_constr.data[i] = intermediate_nodes_arg_conv_8_ref;
63968         }
63969         FREE(intermediate_nodes_arg);
63970         void* destination_arg_ptr = untag_ptr(destination_arg);
63971         CHECK_ACCESS(destination_arg_ptr);
63972         LDKDestination destination_arg_conv = *(LDKDestination*)(destination_arg_ptr);
63973         destination_arg_conv = Destination_clone((LDKDestination*)untag_ptr(destination_arg));
63974         LDKOnionMessagePath ret_var = OnionMessagePath_new(intermediate_nodes_arg_constr, destination_arg_conv);
63975         int64_t ret_ref = 0;
63976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63977         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63978         return ret_ref;
63979 }
63980
63981 static inline uint64_t OnionMessagePath_clone_ptr(LDKOnionMessagePath *NONNULL_PTR arg) {
63982         LDKOnionMessagePath ret_var = OnionMessagePath_clone(arg);
63983         int64_t ret_ref = 0;
63984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
63985         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
63986         return ret_ref;
63987 }
63988 int64_t  CS_LDK_OnionMessagePath_clone_ptr(int64_t arg) {
63989         LDKOnionMessagePath arg_conv;
63990         arg_conv.inner = untag_ptr(arg);
63991         arg_conv.is_owned = ptr_is_owned(arg);
63992         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
63993         arg_conv.is_owned = false;
63994         int64_t ret_conv = OnionMessagePath_clone_ptr(&arg_conv);
63995         return ret_conv;
63996 }
63997
63998 int64_t  CS_LDK_OnionMessagePath_clone(int64_t orig) {
63999         LDKOnionMessagePath orig_conv;
64000         orig_conv.inner = untag_ptr(orig);
64001         orig_conv.is_owned = ptr_is_owned(orig);
64002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
64003         orig_conv.is_owned = false;
64004         LDKOnionMessagePath ret_var = OnionMessagePath_clone(&orig_conv);
64005         int64_t ret_ref = 0;
64006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64008         return ret_ref;
64009 }
64010
64011 void  CS_LDK_Destination_free(int64_t this_ptr) {
64012         if (!ptr_is_owned(this_ptr)) return;
64013         void* this_ptr_ptr = untag_ptr(this_ptr);
64014         CHECK_ACCESS(this_ptr_ptr);
64015         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
64016         FREE(untag_ptr(this_ptr));
64017         Destination_free(this_ptr_conv);
64018 }
64019
64020 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
64021         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64022         *ret_copy = Destination_clone(arg);
64023         int64_t ret_ref = tag_ptr(ret_copy, true);
64024         return ret_ref;
64025 }
64026 int64_t  CS_LDK_Destination_clone_ptr(int64_t arg) {
64027         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
64028         int64_t ret_conv = Destination_clone_ptr(arg_conv);
64029         return ret_conv;
64030 }
64031
64032 int64_t  CS_LDK_Destination_clone(int64_t orig) {
64033         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
64034         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64035         *ret_copy = Destination_clone(orig_conv);
64036         int64_t ret_ref = tag_ptr(ret_copy, true);
64037         return ret_ref;
64038 }
64039
64040 int64_t  CS_LDK_Destination_node(int8_tArray a) {
64041         LDKPublicKey a_ref;
64042         CHECK(a->arr_len == 33);
64043         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
64044         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64045         *ret_copy = Destination_node(a_ref);
64046         int64_t ret_ref = tag_ptr(ret_copy, true);
64047         return ret_ref;
64048 }
64049
64050 int64_t  CS_LDK_Destination_blinded_path(int64_t a) {
64051         LDKBlindedPath a_conv;
64052         a_conv.inner = untag_ptr(a);
64053         a_conv.is_owned = ptr_is_owned(a);
64054         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64055         a_conv = BlindedPath_clone(&a_conv);
64056         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
64057         *ret_copy = Destination_blinded_path(a_conv);
64058         int64_t ret_ref = tag_ptr(ret_copy, true);
64059         return ret_ref;
64060 }
64061
64062 void  CS_LDK_SendError_free(int64_t this_ptr) {
64063         if (!ptr_is_owned(this_ptr)) return;
64064         void* this_ptr_ptr = untag_ptr(this_ptr);
64065         CHECK_ACCESS(this_ptr_ptr);
64066         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
64067         FREE(untag_ptr(this_ptr));
64068         SendError_free(this_ptr_conv);
64069 }
64070
64071 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
64072         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64073         *ret_copy = SendError_clone(arg);
64074         int64_t ret_ref = tag_ptr(ret_copy, true);
64075         return ret_ref;
64076 }
64077 int64_t  CS_LDK_SendError_clone_ptr(int64_t arg) {
64078         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
64079         int64_t ret_conv = SendError_clone_ptr(arg_conv);
64080         return ret_conv;
64081 }
64082
64083 int64_t  CS_LDK_SendError_clone(int64_t orig) {
64084         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
64085         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64086         *ret_copy = SendError_clone(orig_conv);
64087         int64_t ret_ref = tag_ptr(ret_copy, true);
64088         return ret_ref;
64089 }
64090
64091 int64_t  CS_LDK_SendError_secp256k1(int32_t a) {
64092         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_cs(a);
64093         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64094         *ret_copy = SendError_secp256k1(a_conv);
64095         int64_t ret_ref = tag_ptr(ret_copy, true);
64096         return ret_ref;
64097 }
64098
64099 int64_t  CS_LDK_SendError_too_big_packet() {
64100         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64101         *ret_copy = SendError_too_big_packet();
64102         int64_t ret_ref = tag_ptr(ret_copy, true);
64103         return ret_ref;
64104 }
64105
64106 int64_t  CS_LDK_SendError_too_few_blinded_hops() {
64107         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64108         *ret_copy = SendError_too_few_blinded_hops();
64109         int64_t ret_ref = tag_ptr(ret_copy, true);
64110         return ret_ref;
64111 }
64112
64113 int64_t  CS_LDK_SendError_invalid_first_hop() {
64114         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64115         *ret_copy = SendError_invalid_first_hop();
64116         int64_t ret_ref = tag_ptr(ret_copy, true);
64117         return ret_ref;
64118 }
64119
64120 int64_t  CS_LDK_SendError_invalid_message() {
64121         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64122         *ret_copy = SendError_invalid_message();
64123         int64_t ret_ref = tag_ptr(ret_copy, true);
64124         return ret_ref;
64125 }
64126
64127 int64_t  CS_LDK_SendError_buffer_full() {
64128         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64129         *ret_copy = SendError_buffer_full();
64130         int64_t ret_ref = tag_ptr(ret_copy, true);
64131         return ret_ref;
64132 }
64133
64134 int64_t  CS_LDK_SendError_get_node_id_failed() {
64135         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64136         *ret_copy = SendError_get_node_id_failed();
64137         int64_t ret_ref = tag_ptr(ret_copy, true);
64138         return ret_ref;
64139 }
64140
64141 int64_t  CS_LDK_SendError_blinded_path_advance_failed() {
64142         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
64143         *ret_copy = SendError_blinded_path_advance_failed();
64144         int64_t ret_ref = tag_ptr(ret_copy, true);
64145         return ret_ref;
64146 }
64147
64148 jboolean  CS_LDK_SendError_eq(int64_t a, int64_t b) {
64149         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
64150         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
64151         jboolean ret_conv = SendError_eq(a_conv, b_conv);
64152         return ret_conv;
64153 }
64154
64155 void  CS_LDK_CustomOnionMessageHandler_free(int64_t this_ptr) {
64156         if (!ptr_is_owned(this_ptr)) return;
64157         void* this_ptr_ptr = untag_ptr(this_ptr);
64158         CHECK_ACCESS(this_ptr_ptr);
64159         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
64160         FREE(untag_ptr(this_ptr));
64161         CustomOnionMessageHandler_free(this_ptr_conv);
64162 }
64163
64164 void  CS_LDK_PeeledOnion_free(int64_t this_ptr) {
64165         if (!ptr_is_owned(this_ptr)) return;
64166         void* this_ptr_ptr = untag_ptr(this_ptr);
64167         CHECK_ACCESS(this_ptr_ptr);
64168         LDKPeeledOnion this_ptr_conv = *(LDKPeeledOnion*)(this_ptr_ptr);
64169         FREE(untag_ptr(this_ptr));
64170         PeeledOnion_free(this_ptr_conv);
64171 }
64172
64173 static inline uint64_t PeeledOnion_clone_ptr(LDKPeeledOnion *NONNULL_PTR arg) {
64174         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64175         *ret_copy = PeeledOnion_clone(arg);
64176         int64_t ret_ref = tag_ptr(ret_copy, true);
64177         return ret_ref;
64178 }
64179 int64_t  CS_LDK_PeeledOnion_clone_ptr(int64_t arg) {
64180         LDKPeeledOnion* arg_conv = (LDKPeeledOnion*)untag_ptr(arg);
64181         int64_t ret_conv = PeeledOnion_clone_ptr(arg_conv);
64182         return ret_conv;
64183 }
64184
64185 int64_t  CS_LDK_PeeledOnion_clone(int64_t orig) {
64186         LDKPeeledOnion* orig_conv = (LDKPeeledOnion*)untag_ptr(orig);
64187         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64188         *ret_copy = PeeledOnion_clone(orig_conv);
64189         int64_t ret_ref = tag_ptr(ret_copy, true);
64190         return ret_ref;
64191 }
64192
64193 int64_t  CS_LDK_PeeledOnion_forward(int8_tArray a, int64_t b) {
64194         LDKPublicKey a_ref;
64195         CHECK(a->arr_len == 33);
64196         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
64197         LDKOnionMessage b_conv;
64198         b_conv.inner = untag_ptr(b);
64199         b_conv.is_owned = ptr_is_owned(b);
64200         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
64201         b_conv = OnionMessage_clone(&b_conv);
64202         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64203         *ret_copy = PeeledOnion_forward(a_ref, b_conv);
64204         int64_t ret_ref = tag_ptr(ret_copy, true);
64205         return ret_ref;
64206 }
64207
64208 int64_t  CS_LDK_PeeledOnion_receive(int64_t a, int8_tArray b, int64_t c) {
64209         void* a_ptr = untag_ptr(a);
64210         CHECK_ACCESS(a_ptr);
64211         LDKParsedOnionMessageContents a_conv = *(LDKParsedOnionMessageContents*)(a_ptr);
64212         a_conv = ParsedOnionMessageContents_clone((LDKParsedOnionMessageContents*)untag_ptr(a));
64213         LDKThirtyTwoBytes b_ref;
64214         CHECK(b->arr_len == 32);
64215         memcpy(b_ref.data, b->elems, 32); FREE(b);
64216         LDKBlindedPath c_conv;
64217         c_conv.inner = untag_ptr(c);
64218         c_conv.is_owned = ptr_is_owned(c);
64219         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
64220         c_conv = BlindedPath_clone(&c_conv);
64221         LDKPeeledOnion *ret_copy = MALLOC(sizeof(LDKPeeledOnion), "LDKPeeledOnion");
64222         *ret_copy = PeeledOnion_receive(a_conv, b_ref, c_conv);
64223         int64_t ret_ref = tag_ptr(ret_copy, true);
64224         return ret_ref;
64225 }
64226
64227 int64_t  CS_LDK_create_onion_message(int64_t entropy_source, int64_t node_signer, int64_t path, int64_t contents, int64_t reply_path) {
64228         void* entropy_source_ptr = untag_ptr(entropy_source);
64229         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
64230         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
64231         void* node_signer_ptr = untag_ptr(node_signer);
64232         if (ptr_is_owned(node_signer)) { CHECK_ACCESS(node_signer_ptr); }
64233         LDKNodeSigner* node_signer_conv = (LDKNodeSigner*)node_signer_ptr;
64234         LDKOnionMessagePath path_conv;
64235         path_conv.inner = untag_ptr(path);
64236         path_conv.is_owned = ptr_is_owned(path);
64237         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
64238         path_conv = OnionMessagePath_clone(&path_conv);
64239         void* contents_ptr = untag_ptr(contents);
64240         CHECK_ACCESS(contents_ptr);
64241         LDKOnionMessageContents contents_conv = *(LDKOnionMessageContents*)(contents_ptr);
64242         if (contents_conv.free == LDKOnionMessageContents_JCalls_free) {
64243                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64244                 LDKOnionMessageContents_JCalls_cloned(&contents_conv);
64245         }
64246         LDKBlindedPath reply_path_conv;
64247         reply_path_conv.inner = untag_ptr(reply_path);
64248         reply_path_conv.is_owned = ptr_is_owned(reply_path);
64249         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
64250         reply_path_conv = BlindedPath_clone(&reply_path_conv);
64251         LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ), "LDKCResult_C2Tuple_PublicKeyOnionMessageZSendErrorZ");
64252         *ret_conv = create_onion_message(entropy_source_conv, node_signer_conv, path_conv, contents_conv, reply_path_conv);
64253         return tag_ptr(ret_conv, true);
64254 }
64255
64256 int64_t  CS_LDK_peel_onion_message(int64_t msg, int64_t node_signer, int64_t logger, int64_t custom_handler) {
64257         LDKOnionMessage msg_conv;
64258         msg_conv.inner = untag_ptr(msg);
64259         msg_conv.is_owned = ptr_is_owned(msg);
64260         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
64261         msg_conv.is_owned = false;
64262         void* node_signer_ptr = untag_ptr(node_signer);
64263         CHECK_ACCESS(node_signer_ptr);
64264         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
64265         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
64266                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64267                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
64268         }
64269         void* logger_ptr = untag_ptr(logger);
64270         CHECK_ACCESS(logger_ptr);
64271         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
64272         if (logger_conv.free == LDKLogger_JCalls_free) {
64273                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64274                 LDKLogger_JCalls_cloned(&logger_conv);
64275         }
64276         void* custom_handler_ptr = untag_ptr(custom_handler);
64277         CHECK_ACCESS(custom_handler_ptr);
64278         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
64279         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
64280                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64281                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
64282         }
64283         LDKCResult_PeeledOnionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PeeledOnionNoneZ), "LDKCResult_PeeledOnionNoneZ");
64284         *ret_conv = peel_onion_message(&msg_conv, node_signer_conv, logger_conv, custom_handler_conv);
64285         return tag_ptr(ret_conv, true);
64286 }
64287
64288 int64_t  CS_LDK_OnionMessenger_new(int64_t entropy_source, int64_t node_signer, int64_t logger, int64_t message_router, int64_t offers_handler, int64_t custom_handler) {
64289         void* entropy_source_ptr = untag_ptr(entropy_source);
64290         CHECK_ACCESS(entropy_source_ptr);
64291         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
64292         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
64293                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64294                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
64295         }
64296         void* node_signer_ptr = untag_ptr(node_signer);
64297         CHECK_ACCESS(node_signer_ptr);
64298         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
64299         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
64300                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64301                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
64302         }
64303         void* logger_ptr = untag_ptr(logger);
64304         CHECK_ACCESS(logger_ptr);
64305         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
64306         if (logger_conv.free == LDKLogger_JCalls_free) {
64307                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64308                 LDKLogger_JCalls_cloned(&logger_conv);
64309         }
64310         void* message_router_ptr = untag_ptr(message_router);
64311         CHECK_ACCESS(message_router_ptr);
64312         LDKMessageRouter message_router_conv = *(LDKMessageRouter*)(message_router_ptr);
64313         if (message_router_conv.free == LDKMessageRouter_JCalls_free) {
64314                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64315                 LDKMessageRouter_JCalls_cloned(&message_router_conv);
64316         }
64317         void* offers_handler_ptr = untag_ptr(offers_handler);
64318         CHECK_ACCESS(offers_handler_ptr);
64319         LDKOffersMessageHandler offers_handler_conv = *(LDKOffersMessageHandler*)(offers_handler_ptr);
64320         if (offers_handler_conv.free == LDKOffersMessageHandler_JCalls_free) {
64321                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64322                 LDKOffersMessageHandler_JCalls_cloned(&offers_handler_conv);
64323         }
64324         void* custom_handler_ptr = untag_ptr(custom_handler);
64325         CHECK_ACCESS(custom_handler_ptr);
64326         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
64327         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
64328                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64329                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
64330         }
64331         LDKOnionMessenger ret_var = OnionMessenger_new(entropy_source_conv, node_signer_conv, logger_conv, message_router_conv, offers_handler_conv, custom_handler_conv);
64332         int64_t ret_ref = 0;
64333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64334         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64335         return ret_ref;
64336 }
64337
64338 int64_t  CS_LDK_OnionMessenger_send_onion_message(int64_t this_arg, int64_t path, int64_t contents, int64_t reply_path) {
64339         LDKOnionMessenger this_arg_conv;
64340         this_arg_conv.inner = untag_ptr(this_arg);
64341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
64342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
64343         this_arg_conv.is_owned = false;
64344         LDKOnionMessagePath path_conv;
64345         path_conv.inner = untag_ptr(path);
64346         path_conv.is_owned = ptr_is_owned(path);
64347         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
64348         path_conv = OnionMessagePath_clone(&path_conv);
64349         void* contents_ptr = untag_ptr(contents);
64350         CHECK_ACCESS(contents_ptr);
64351         LDKOnionMessageContents contents_conv = *(LDKOnionMessageContents*)(contents_ptr);
64352         if (contents_conv.free == LDKOnionMessageContents_JCalls_free) {
64353                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64354                 LDKOnionMessageContents_JCalls_cloned(&contents_conv);
64355         }
64356         LDKBlindedPath reply_path_conv;
64357         reply_path_conv.inner = untag_ptr(reply_path);
64358         reply_path_conv.is_owned = ptr_is_owned(reply_path);
64359         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
64360         reply_path_conv = BlindedPath_clone(&reply_path_conv);
64361         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
64362         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, path_conv, contents_conv, reply_path_conv);
64363         return tag_ptr(ret_conv, true);
64364 }
64365
64366 int64_t  CS_LDK_OnionMessenger_as_OnionMessageHandler(int64_t this_arg) {
64367         LDKOnionMessenger this_arg_conv;
64368         this_arg_conv.inner = untag_ptr(this_arg);
64369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
64370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
64371         this_arg_conv.is_owned = false;
64372         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
64373         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
64374         return tag_ptr(ret_ret, true);
64375 }
64376
64377 void  CS_LDK_OffersMessageHandler_free(int64_t this_ptr) {
64378         if (!ptr_is_owned(this_ptr)) return;
64379         void* this_ptr_ptr = untag_ptr(this_ptr);
64380         CHECK_ACCESS(this_ptr_ptr);
64381         LDKOffersMessageHandler this_ptr_conv = *(LDKOffersMessageHandler*)(this_ptr_ptr);
64382         FREE(untag_ptr(this_ptr));
64383         OffersMessageHandler_free(this_ptr_conv);
64384 }
64385
64386 void  CS_LDK_OffersMessage_free(int64_t this_ptr) {
64387         if (!ptr_is_owned(this_ptr)) return;
64388         void* this_ptr_ptr = untag_ptr(this_ptr);
64389         CHECK_ACCESS(this_ptr_ptr);
64390         LDKOffersMessage this_ptr_conv = *(LDKOffersMessage*)(this_ptr_ptr);
64391         FREE(untag_ptr(this_ptr));
64392         OffersMessage_free(this_ptr_conv);
64393 }
64394
64395 static inline uint64_t OffersMessage_clone_ptr(LDKOffersMessage *NONNULL_PTR arg) {
64396         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64397         *ret_copy = OffersMessage_clone(arg);
64398         int64_t ret_ref = tag_ptr(ret_copy, true);
64399         return ret_ref;
64400 }
64401 int64_t  CS_LDK_OffersMessage_clone_ptr(int64_t arg) {
64402         LDKOffersMessage* arg_conv = (LDKOffersMessage*)untag_ptr(arg);
64403         int64_t ret_conv = OffersMessage_clone_ptr(arg_conv);
64404         return ret_conv;
64405 }
64406
64407 int64_t  CS_LDK_OffersMessage_clone(int64_t orig) {
64408         LDKOffersMessage* orig_conv = (LDKOffersMessage*)untag_ptr(orig);
64409         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64410         *ret_copy = OffersMessage_clone(orig_conv);
64411         int64_t ret_ref = tag_ptr(ret_copy, true);
64412         return ret_ref;
64413 }
64414
64415 int64_t  CS_LDK_OffersMessage_invoice_request(int64_t a) {
64416         LDKInvoiceRequest a_conv;
64417         a_conv.inner = untag_ptr(a);
64418         a_conv.is_owned = ptr_is_owned(a);
64419         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64420         a_conv = InvoiceRequest_clone(&a_conv);
64421         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64422         *ret_copy = OffersMessage_invoice_request(a_conv);
64423         int64_t ret_ref = tag_ptr(ret_copy, true);
64424         return ret_ref;
64425 }
64426
64427 int64_t  CS_LDK_OffersMessage_invoice(int64_t a) {
64428         LDKBolt12Invoice a_conv;
64429         a_conv.inner = untag_ptr(a);
64430         a_conv.is_owned = ptr_is_owned(a);
64431         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64432         a_conv = Bolt12Invoice_clone(&a_conv);
64433         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64434         *ret_copy = OffersMessage_invoice(a_conv);
64435         int64_t ret_ref = tag_ptr(ret_copy, true);
64436         return ret_ref;
64437 }
64438
64439 int64_t  CS_LDK_OffersMessage_invoice_error(int64_t a) {
64440         LDKInvoiceError a_conv;
64441         a_conv.inner = untag_ptr(a);
64442         a_conv.is_owned = ptr_is_owned(a);
64443         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64444         a_conv = InvoiceError_clone(&a_conv);
64445         LDKOffersMessage *ret_copy = MALLOC(sizeof(LDKOffersMessage), "LDKOffersMessage");
64446         *ret_copy = OffersMessage_invoice_error(a_conv);
64447         int64_t ret_ref = tag_ptr(ret_copy, true);
64448         return ret_ref;
64449 }
64450
64451 jboolean  CS_LDK_OffersMessage_is_known_type(int64_t tlv_type) {
64452         jboolean ret_conv = OffersMessage_is_known_type(tlv_type);
64453         return ret_conv;
64454 }
64455
64456 int8_tArray  CS_LDK_OffersMessage_write(int64_t obj) {
64457         LDKOffersMessage* obj_conv = (LDKOffersMessage*)untag_ptr(obj);
64458         LDKCVec_u8Z ret_var = OffersMessage_write(obj_conv);
64459         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64460         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64461         CVec_u8Z_free(ret_var);
64462         return ret_arr;
64463 }
64464
64465 int64_t  CS_LDK_OffersMessage_read(int8_tArray ser, int64_t arg_a, int64_t arg_b) {
64466         LDKu8slice ser_ref;
64467         ser_ref.datalen = ser->arr_len;
64468         ser_ref.data = ser->elems;
64469         void* arg_b_ptr = untag_ptr(arg_b);
64470         if (ptr_is_owned(arg_b)) { CHECK_ACCESS(arg_b_ptr); }
64471         LDKLogger* arg_b_conv = (LDKLogger*)arg_b_ptr;
64472         LDKCResult_OffersMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OffersMessageDecodeErrorZ), "LDKCResult_OffersMessageDecodeErrorZ");
64473         *ret_conv = OffersMessage_read(ser_ref, arg_a, arg_b_conv);
64474         FREE(ser);
64475         return tag_ptr(ret_conv, true);
64476 }
64477
64478 void  CS_LDK_Packet_free(int64_t this_obj) {
64479         LDKPacket this_obj_conv;
64480         this_obj_conv.inner = untag_ptr(this_obj);
64481         this_obj_conv.is_owned = ptr_is_owned(this_obj);
64482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
64483         Packet_free(this_obj_conv);
64484 }
64485
64486 int8_t  CS_LDK_Packet_get_version(int64_t this_ptr) {
64487         LDKPacket this_ptr_conv;
64488         this_ptr_conv.inner = untag_ptr(this_ptr);
64489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64491         this_ptr_conv.is_owned = false;
64492         int8_t ret_conv = Packet_get_version(&this_ptr_conv);
64493         return ret_conv;
64494 }
64495
64496 void  CS_LDK_Packet_set_version(int64_t this_ptr, int8_t val) {
64497         LDKPacket this_ptr_conv;
64498         this_ptr_conv.inner = untag_ptr(this_ptr);
64499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64501         this_ptr_conv.is_owned = false;
64502         Packet_set_version(&this_ptr_conv, val);
64503 }
64504
64505 int8_tArray  CS_LDK_Packet_get_public_key(int64_t this_ptr) {
64506         LDKPacket this_ptr_conv;
64507         this_ptr_conv.inner = untag_ptr(this_ptr);
64508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64510         this_ptr_conv.is_owned = false;
64511         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64512         memcpy(ret_arr->elems, Packet_get_public_key(&this_ptr_conv).compressed_form, 33);
64513         return ret_arr;
64514 }
64515
64516 void  CS_LDK_Packet_set_public_key(int64_t this_ptr, int8_tArray val) {
64517         LDKPacket this_ptr_conv;
64518         this_ptr_conv.inner = untag_ptr(this_ptr);
64519         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64521         this_ptr_conv.is_owned = false;
64522         LDKPublicKey val_ref;
64523         CHECK(val->arr_len == 33);
64524         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64525         Packet_set_public_key(&this_ptr_conv, val_ref);
64526 }
64527
64528 int8_tArray  CS_LDK_Packet_get_hop_data(int64_t this_ptr) {
64529         LDKPacket this_ptr_conv;
64530         this_ptr_conv.inner = untag_ptr(this_ptr);
64531         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64533         this_ptr_conv.is_owned = false;
64534         LDKCVec_u8Z ret_var = Packet_get_hop_data(&this_ptr_conv);
64535         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64536         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64537         CVec_u8Z_free(ret_var);
64538         return ret_arr;
64539 }
64540
64541 void  CS_LDK_Packet_set_hop_data(int64_t this_ptr, int8_tArray val) {
64542         LDKPacket this_ptr_conv;
64543         this_ptr_conv.inner = untag_ptr(this_ptr);
64544         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64546         this_ptr_conv.is_owned = false;
64547         LDKCVec_u8Z val_ref;
64548         val_ref.datalen = val->arr_len;
64549         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
64550         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
64551         Packet_set_hop_data(&this_ptr_conv, val_ref);
64552 }
64553
64554 int8_tArray  CS_LDK_Packet_get_hmac(int64_t this_ptr) {
64555         LDKPacket this_ptr_conv;
64556         this_ptr_conv.inner = untag_ptr(this_ptr);
64557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64559         this_ptr_conv.is_owned = false;
64560         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
64561         memcpy(ret_arr->elems, *Packet_get_hmac(&this_ptr_conv), 32);
64562         return ret_arr;
64563 }
64564
64565 void  CS_LDK_Packet_set_hmac(int64_t this_ptr, int8_tArray val) {
64566         LDKPacket this_ptr_conv;
64567         this_ptr_conv.inner = untag_ptr(this_ptr);
64568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64570         this_ptr_conv.is_owned = false;
64571         LDKThirtyTwoBytes val_ref;
64572         CHECK(val->arr_len == 32);
64573         memcpy(val_ref.data, val->elems, 32); FREE(val);
64574         Packet_set_hmac(&this_ptr_conv, val_ref);
64575 }
64576
64577 int64_t  CS_LDK_Packet_new(int8_t version_arg, int8_tArray public_key_arg, int8_tArray hop_data_arg, int8_tArray hmac_arg) {
64578         LDKPublicKey public_key_arg_ref;
64579         CHECK(public_key_arg->arr_len == 33);
64580         memcpy(public_key_arg_ref.compressed_form, public_key_arg->elems, 33); FREE(public_key_arg);
64581         LDKCVec_u8Z hop_data_arg_ref;
64582         hop_data_arg_ref.datalen = hop_data_arg->arr_len;
64583         hop_data_arg_ref.data = MALLOC(hop_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
64584         memcpy(hop_data_arg_ref.data, hop_data_arg->elems, hop_data_arg_ref.datalen); FREE(hop_data_arg);
64585         LDKThirtyTwoBytes hmac_arg_ref;
64586         CHECK(hmac_arg->arr_len == 32);
64587         memcpy(hmac_arg_ref.data, hmac_arg->elems, 32); FREE(hmac_arg);
64588         LDKPacket ret_var = Packet_new(version_arg, public_key_arg_ref, hop_data_arg_ref, hmac_arg_ref);
64589         int64_t ret_ref = 0;
64590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64591         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64592         return ret_ref;
64593 }
64594
64595 static inline uint64_t Packet_clone_ptr(LDKPacket *NONNULL_PTR arg) {
64596         LDKPacket ret_var = Packet_clone(arg);
64597         int64_t ret_ref = 0;
64598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64599         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64600         return ret_ref;
64601 }
64602 int64_t  CS_LDK_Packet_clone_ptr(int64_t arg) {
64603         LDKPacket arg_conv;
64604         arg_conv.inner = untag_ptr(arg);
64605         arg_conv.is_owned = ptr_is_owned(arg);
64606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
64607         arg_conv.is_owned = false;
64608         int64_t ret_conv = Packet_clone_ptr(&arg_conv);
64609         return ret_conv;
64610 }
64611
64612 int64_t  CS_LDK_Packet_clone(int64_t orig) {
64613         LDKPacket orig_conv;
64614         orig_conv.inner = untag_ptr(orig);
64615         orig_conv.is_owned = ptr_is_owned(orig);
64616         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
64617         orig_conv.is_owned = false;
64618         LDKPacket ret_var = Packet_clone(&orig_conv);
64619         int64_t ret_ref = 0;
64620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64621         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64622         return ret_ref;
64623 }
64624
64625 jboolean  CS_LDK_Packet_eq(int64_t a, int64_t b) {
64626         LDKPacket a_conv;
64627         a_conv.inner = untag_ptr(a);
64628         a_conv.is_owned = ptr_is_owned(a);
64629         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64630         a_conv.is_owned = false;
64631         LDKPacket b_conv;
64632         b_conv.inner = untag_ptr(b);
64633         b_conv.is_owned = ptr_is_owned(b);
64634         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
64635         b_conv.is_owned = false;
64636         jboolean ret_conv = Packet_eq(&a_conv, &b_conv);
64637         return ret_conv;
64638 }
64639
64640 int8_tArray  CS_LDK_Packet_write(int64_t obj) {
64641         LDKPacket obj_conv;
64642         obj_conv.inner = untag_ptr(obj);
64643         obj_conv.is_owned = ptr_is_owned(obj);
64644         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
64645         obj_conv.is_owned = false;
64646         LDKCVec_u8Z ret_var = Packet_write(&obj_conv);
64647         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64648         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64649         CVec_u8Z_free(ret_var);
64650         return ret_arr;
64651 }
64652
64653 void  CS_LDK_ParsedOnionMessageContents_free(int64_t this_ptr) {
64654         if (!ptr_is_owned(this_ptr)) return;
64655         void* this_ptr_ptr = untag_ptr(this_ptr);
64656         CHECK_ACCESS(this_ptr_ptr);
64657         LDKParsedOnionMessageContents this_ptr_conv = *(LDKParsedOnionMessageContents*)(this_ptr_ptr);
64658         FREE(untag_ptr(this_ptr));
64659         ParsedOnionMessageContents_free(this_ptr_conv);
64660 }
64661
64662 static inline uint64_t ParsedOnionMessageContents_clone_ptr(LDKParsedOnionMessageContents *NONNULL_PTR arg) {
64663         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64664         *ret_copy = ParsedOnionMessageContents_clone(arg);
64665         int64_t ret_ref = tag_ptr(ret_copy, true);
64666         return ret_ref;
64667 }
64668 int64_t  CS_LDK_ParsedOnionMessageContents_clone_ptr(int64_t arg) {
64669         LDKParsedOnionMessageContents* arg_conv = (LDKParsedOnionMessageContents*)untag_ptr(arg);
64670         int64_t ret_conv = ParsedOnionMessageContents_clone_ptr(arg_conv);
64671         return ret_conv;
64672 }
64673
64674 int64_t  CS_LDK_ParsedOnionMessageContents_clone(int64_t orig) {
64675         LDKParsedOnionMessageContents* orig_conv = (LDKParsedOnionMessageContents*)untag_ptr(orig);
64676         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64677         *ret_copy = ParsedOnionMessageContents_clone(orig_conv);
64678         int64_t ret_ref = tag_ptr(ret_copy, true);
64679         return ret_ref;
64680 }
64681
64682 int64_t  CS_LDK_ParsedOnionMessageContents_offers(int64_t a) {
64683         void* a_ptr = untag_ptr(a);
64684         CHECK_ACCESS(a_ptr);
64685         LDKOffersMessage a_conv = *(LDKOffersMessage*)(a_ptr);
64686         a_conv = OffersMessage_clone((LDKOffersMessage*)untag_ptr(a));
64687         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64688         *ret_copy = ParsedOnionMessageContents_offers(a_conv);
64689         int64_t ret_ref = tag_ptr(ret_copy, true);
64690         return ret_ref;
64691 }
64692
64693 int64_t  CS_LDK_ParsedOnionMessageContents_custom(int64_t a) {
64694         void* a_ptr = untag_ptr(a);
64695         CHECK_ACCESS(a_ptr);
64696         LDKOnionMessageContents a_conv = *(LDKOnionMessageContents*)(a_ptr);
64697         if (a_conv.free == LDKOnionMessageContents_JCalls_free) {
64698                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
64699                 LDKOnionMessageContents_JCalls_cloned(&a_conv);
64700         }
64701         LDKParsedOnionMessageContents *ret_copy = MALLOC(sizeof(LDKParsedOnionMessageContents), "LDKParsedOnionMessageContents");
64702         *ret_copy = ParsedOnionMessageContents_custom(a_conv);
64703         int64_t ret_ref = tag_ptr(ret_copy, true);
64704         return ret_ref;
64705 }
64706
64707 int64_t  CS_LDK_ParsedOnionMessageContents_as_OnionMessageContents(int64_t this_arg) {
64708         LDKParsedOnionMessageContents* this_arg_conv = (LDKParsedOnionMessageContents*)untag_ptr(this_arg);
64709         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
64710         *ret_ret = ParsedOnionMessageContents_as_OnionMessageContents(this_arg_conv);
64711         return tag_ptr(ret_ret, true);
64712 }
64713
64714 int8_tArray  CS_LDK_ParsedOnionMessageContents_write(int64_t obj) {
64715         LDKParsedOnionMessageContents* obj_conv = (LDKParsedOnionMessageContents*)untag_ptr(obj);
64716         LDKCVec_u8Z ret_var = ParsedOnionMessageContents_write(obj_conv);
64717         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64718         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64719         CVec_u8Z_free(ret_var);
64720         return ret_arr;
64721 }
64722
64723 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
64724         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
64725         *ret_ret = OnionMessageContents_clone(arg);
64726         return tag_ptr(ret_ret, true);
64727 }
64728 int64_t  CS_LDK_OnionMessageContents_clone_ptr(int64_t arg) {
64729         void* arg_ptr = untag_ptr(arg);
64730         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
64731         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)arg_ptr;
64732         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
64733         return ret_conv;
64734 }
64735
64736 int64_t  CS_LDK_OnionMessageContents_clone(int64_t orig) {
64737         void* orig_ptr = untag_ptr(orig);
64738         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
64739         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)orig_ptr;
64740         LDKOnionMessageContents* ret_ret = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
64741         *ret_ret = OnionMessageContents_clone(orig_conv);
64742         return tag_ptr(ret_ret, true);
64743 }
64744
64745 void  CS_LDK_OnionMessageContents_free(int64_t this_ptr) {
64746         if (!ptr_is_owned(this_ptr)) return;
64747         void* this_ptr_ptr = untag_ptr(this_ptr);
64748         CHECK_ACCESS(this_ptr_ptr);
64749         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
64750         FREE(untag_ptr(this_ptr));
64751         OnionMessageContents_free(this_ptr_conv);
64752 }
64753
64754 void  CS_LDK_BlindedPath_free(int64_t this_obj) {
64755         LDKBlindedPath this_obj_conv;
64756         this_obj_conv.inner = untag_ptr(this_obj);
64757         this_obj_conv.is_owned = ptr_is_owned(this_obj);
64758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
64759         BlindedPath_free(this_obj_conv);
64760 }
64761
64762 int8_tArray  CS_LDK_BlindedPath_get_introduction_node_id(int64_t this_ptr) {
64763         LDKBlindedPath this_ptr_conv;
64764         this_ptr_conv.inner = untag_ptr(this_ptr);
64765         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64767         this_ptr_conv.is_owned = false;
64768         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64769         memcpy(ret_arr->elems, BlindedPath_get_introduction_node_id(&this_ptr_conv).compressed_form, 33);
64770         return ret_arr;
64771 }
64772
64773 void  CS_LDK_BlindedPath_set_introduction_node_id(int64_t this_ptr, int8_tArray val) {
64774         LDKBlindedPath this_ptr_conv;
64775         this_ptr_conv.inner = untag_ptr(this_ptr);
64776         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64778         this_ptr_conv.is_owned = false;
64779         LDKPublicKey val_ref;
64780         CHECK(val->arr_len == 33);
64781         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64782         BlindedPath_set_introduction_node_id(&this_ptr_conv, val_ref);
64783 }
64784
64785 int8_tArray  CS_LDK_BlindedPath_get_blinding_point(int64_t this_ptr) {
64786         LDKBlindedPath this_ptr_conv;
64787         this_ptr_conv.inner = untag_ptr(this_ptr);
64788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64790         this_ptr_conv.is_owned = false;
64791         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64792         memcpy(ret_arr->elems, BlindedPath_get_blinding_point(&this_ptr_conv).compressed_form, 33);
64793         return ret_arr;
64794 }
64795
64796 void  CS_LDK_BlindedPath_set_blinding_point(int64_t this_ptr, int8_tArray val) {
64797         LDKBlindedPath this_ptr_conv;
64798         this_ptr_conv.inner = untag_ptr(this_ptr);
64799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64801         this_ptr_conv.is_owned = false;
64802         LDKPublicKey val_ref;
64803         CHECK(val->arr_len == 33);
64804         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64805         BlindedPath_set_blinding_point(&this_ptr_conv, val_ref);
64806 }
64807
64808 int64_tArray  CS_LDK_BlindedPath_get_blinded_hops(int64_t this_ptr) {
64809         LDKBlindedPath this_ptr_conv;
64810         this_ptr_conv.inner = untag_ptr(this_ptr);
64811         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64813         this_ptr_conv.is_owned = false;
64814         LDKCVec_BlindedHopZ ret_var = BlindedPath_get_blinded_hops(&this_ptr_conv);
64815         int64_tArray ret_arr = NULL;
64816         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
64817         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
64818         for (size_t m = 0; m < ret_var.datalen; m++) {
64819                 LDKBlindedHop ret_conv_12_var = ret_var.data[m];
64820                 int64_t ret_conv_12_ref = 0;
64821                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_var);
64822                 ret_conv_12_ref = tag_ptr(ret_conv_12_var.inner, ret_conv_12_var.is_owned);
64823                 ret_arr_ptr[m] = ret_conv_12_ref;
64824         }
64825         
64826         FREE(ret_var.data);
64827         return ret_arr;
64828 }
64829
64830 void  CS_LDK_BlindedPath_set_blinded_hops(int64_t this_ptr, int64_tArray val) {
64831         LDKBlindedPath this_ptr_conv;
64832         this_ptr_conv.inner = untag_ptr(this_ptr);
64833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64835         this_ptr_conv.is_owned = false;
64836         LDKCVec_BlindedHopZ val_constr;
64837         val_constr.datalen = val->arr_len;
64838         if (val_constr.datalen > 0)
64839                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
64840         else
64841                 val_constr.data = NULL;
64842         int64_t* val_vals = val->elems;
64843         for (size_t m = 0; m < val_constr.datalen; m++) {
64844                 int64_t val_conv_12 = val_vals[m];
64845                 LDKBlindedHop val_conv_12_conv;
64846                 val_conv_12_conv.inner = untag_ptr(val_conv_12);
64847                 val_conv_12_conv.is_owned = ptr_is_owned(val_conv_12);
64848                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv);
64849                 val_conv_12_conv = BlindedHop_clone(&val_conv_12_conv);
64850                 val_constr.data[m] = val_conv_12_conv;
64851         }
64852         FREE(val);
64853         BlindedPath_set_blinded_hops(&this_ptr_conv, val_constr);
64854 }
64855
64856 int64_t  CS_LDK_BlindedPath_new(int8_tArray introduction_node_id_arg, int8_tArray blinding_point_arg, int64_tArray blinded_hops_arg) {
64857         LDKPublicKey introduction_node_id_arg_ref;
64858         CHECK(introduction_node_id_arg->arr_len == 33);
64859         memcpy(introduction_node_id_arg_ref.compressed_form, introduction_node_id_arg->elems, 33); FREE(introduction_node_id_arg);
64860         LDKPublicKey blinding_point_arg_ref;
64861         CHECK(blinding_point_arg->arr_len == 33);
64862         memcpy(blinding_point_arg_ref.compressed_form, blinding_point_arg->elems, 33); FREE(blinding_point_arg);
64863         LDKCVec_BlindedHopZ blinded_hops_arg_constr;
64864         blinded_hops_arg_constr.datalen = blinded_hops_arg->arr_len;
64865         if (blinded_hops_arg_constr.datalen > 0)
64866                 blinded_hops_arg_constr.data = MALLOC(blinded_hops_arg_constr.datalen * sizeof(LDKBlindedHop), "LDKCVec_BlindedHopZ Elements");
64867         else
64868                 blinded_hops_arg_constr.data = NULL;
64869         int64_t* blinded_hops_arg_vals = blinded_hops_arg->elems;
64870         for (size_t m = 0; m < blinded_hops_arg_constr.datalen; m++) {
64871                 int64_t blinded_hops_arg_conv_12 = blinded_hops_arg_vals[m];
64872                 LDKBlindedHop blinded_hops_arg_conv_12_conv;
64873                 blinded_hops_arg_conv_12_conv.inner = untag_ptr(blinded_hops_arg_conv_12);
64874                 blinded_hops_arg_conv_12_conv.is_owned = ptr_is_owned(blinded_hops_arg_conv_12);
64875                 CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_hops_arg_conv_12_conv);
64876                 blinded_hops_arg_conv_12_conv = BlindedHop_clone(&blinded_hops_arg_conv_12_conv);
64877                 blinded_hops_arg_constr.data[m] = blinded_hops_arg_conv_12_conv;
64878         }
64879         FREE(blinded_hops_arg);
64880         LDKBlindedPath ret_var = BlindedPath_new(introduction_node_id_arg_ref, blinding_point_arg_ref, blinded_hops_arg_constr);
64881         int64_t ret_ref = 0;
64882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64884         return ret_ref;
64885 }
64886
64887 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
64888         LDKBlindedPath ret_var = BlindedPath_clone(arg);
64889         int64_t ret_ref = 0;
64890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64892         return ret_ref;
64893 }
64894 int64_t  CS_LDK_BlindedPath_clone_ptr(int64_t arg) {
64895         LDKBlindedPath arg_conv;
64896         arg_conv.inner = untag_ptr(arg);
64897         arg_conv.is_owned = ptr_is_owned(arg);
64898         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
64899         arg_conv.is_owned = false;
64900         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
64901         return ret_conv;
64902 }
64903
64904 int64_t  CS_LDK_BlindedPath_clone(int64_t orig) {
64905         LDKBlindedPath orig_conv;
64906         orig_conv.inner = untag_ptr(orig);
64907         orig_conv.is_owned = ptr_is_owned(orig);
64908         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
64909         orig_conv.is_owned = false;
64910         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
64911         int64_t ret_ref = 0;
64912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
64913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
64914         return ret_ref;
64915 }
64916
64917 int64_t  CS_LDK_BlindedPath_hash(int64_t o) {
64918         LDKBlindedPath o_conv;
64919         o_conv.inner = untag_ptr(o);
64920         o_conv.is_owned = ptr_is_owned(o);
64921         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
64922         o_conv.is_owned = false;
64923         int64_t ret_conv = BlindedPath_hash(&o_conv);
64924         return ret_conv;
64925 }
64926
64927 jboolean  CS_LDK_BlindedPath_eq(int64_t a, int64_t b) {
64928         LDKBlindedPath a_conv;
64929         a_conv.inner = untag_ptr(a);
64930         a_conv.is_owned = ptr_is_owned(a);
64931         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
64932         a_conv.is_owned = false;
64933         LDKBlindedPath b_conv;
64934         b_conv.inner = untag_ptr(b);
64935         b_conv.is_owned = ptr_is_owned(b);
64936         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
64937         b_conv.is_owned = false;
64938         jboolean ret_conv = BlindedPath_eq(&a_conv, &b_conv);
64939         return ret_conv;
64940 }
64941
64942 void  CS_LDK_BlindedHop_free(int64_t this_obj) {
64943         LDKBlindedHop this_obj_conv;
64944         this_obj_conv.inner = untag_ptr(this_obj);
64945         this_obj_conv.is_owned = ptr_is_owned(this_obj);
64946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
64947         BlindedHop_free(this_obj_conv);
64948 }
64949
64950 int8_tArray  CS_LDK_BlindedHop_get_blinded_node_id(int64_t this_ptr) {
64951         LDKBlindedHop this_ptr_conv;
64952         this_ptr_conv.inner = untag_ptr(this_ptr);
64953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64955         this_ptr_conv.is_owned = false;
64956         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
64957         memcpy(ret_arr->elems, BlindedHop_get_blinded_node_id(&this_ptr_conv).compressed_form, 33);
64958         return ret_arr;
64959 }
64960
64961 void  CS_LDK_BlindedHop_set_blinded_node_id(int64_t this_ptr, int8_tArray val) {
64962         LDKBlindedHop this_ptr_conv;
64963         this_ptr_conv.inner = untag_ptr(this_ptr);
64964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64966         this_ptr_conv.is_owned = false;
64967         LDKPublicKey val_ref;
64968         CHECK(val->arr_len == 33);
64969         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
64970         BlindedHop_set_blinded_node_id(&this_ptr_conv, val_ref);
64971 }
64972
64973 int8_tArray  CS_LDK_BlindedHop_get_encrypted_payload(int64_t this_ptr) {
64974         LDKBlindedHop this_ptr_conv;
64975         this_ptr_conv.inner = untag_ptr(this_ptr);
64976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64978         this_ptr_conv.is_owned = false;
64979         LDKCVec_u8Z ret_var = BlindedHop_get_encrypted_payload(&this_ptr_conv);
64980         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
64981         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
64982         CVec_u8Z_free(ret_var);
64983         return ret_arr;
64984 }
64985
64986 void  CS_LDK_BlindedHop_set_encrypted_payload(int64_t this_ptr, int8_tArray val) {
64987         LDKBlindedHop this_ptr_conv;
64988         this_ptr_conv.inner = untag_ptr(this_ptr);
64989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
64990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
64991         this_ptr_conv.is_owned = false;
64992         LDKCVec_u8Z val_ref;
64993         val_ref.datalen = val->arr_len;
64994         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
64995         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
64996         BlindedHop_set_encrypted_payload(&this_ptr_conv, val_ref);
64997 }
64998
64999 int64_t  CS_LDK_BlindedHop_new(int8_tArray blinded_node_id_arg, int8_tArray encrypted_payload_arg) {
65000         LDKPublicKey blinded_node_id_arg_ref;
65001         CHECK(blinded_node_id_arg->arr_len == 33);
65002         memcpy(blinded_node_id_arg_ref.compressed_form, blinded_node_id_arg->elems, 33); FREE(blinded_node_id_arg);
65003         LDKCVec_u8Z encrypted_payload_arg_ref;
65004         encrypted_payload_arg_ref.datalen = encrypted_payload_arg->arr_len;
65005         encrypted_payload_arg_ref.data = MALLOC(encrypted_payload_arg_ref.datalen, "LDKCVec_u8Z Bytes");
65006         memcpy(encrypted_payload_arg_ref.data, encrypted_payload_arg->elems, encrypted_payload_arg_ref.datalen); FREE(encrypted_payload_arg);
65007         LDKBlindedHop ret_var = BlindedHop_new(blinded_node_id_arg_ref, encrypted_payload_arg_ref);
65008         int64_t ret_ref = 0;
65009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65011         return ret_ref;
65012 }
65013
65014 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
65015         LDKBlindedHop ret_var = BlindedHop_clone(arg);
65016         int64_t ret_ref = 0;
65017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65018         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65019         return ret_ref;
65020 }
65021 int64_t  CS_LDK_BlindedHop_clone_ptr(int64_t arg) {
65022         LDKBlindedHop arg_conv;
65023         arg_conv.inner = untag_ptr(arg);
65024         arg_conv.is_owned = ptr_is_owned(arg);
65025         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65026         arg_conv.is_owned = false;
65027         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
65028         return ret_conv;
65029 }
65030
65031 int64_t  CS_LDK_BlindedHop_clone(int64_t orig) {
65032         LDKBlindedHop orig_conv;
65033         orig_conv.inner = untag_ptr(orig);
65034         orig_conv.is_owned = ptr_is_owned(orig);
65035         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65036         orig_conv.is_owned = false;
65037         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
65038         int64_t ret_ref = 0;
65039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65041         return ret_ref;
65042 }
65043
65044 int64_t  CS_LDK_BlindedHop_hash(int64_t o) {
65045         LDKBlindedHop o_conv;
65046         o_conv.inner = untag_ptr(o);
65047         o_conv.is_owned = ptr_is_owned(o);
65048         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
65049         o_conv.is_owned = false;
65050         int64_t ret_conv = BlindedHop_hash(&o_conv);
65051         return ret_conv;
65052 }
65053
65054 jboolean  CS_LDK_BlindedHop_eq(int64_t a, int64_t b) {
65055         LDKBlindedHop a_conv;
65056         a_conv.inner = untag_ptr(a);
65057         a_conv.is_owned = ptr_is_owned(a);
65058         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
65059         a_conv.is_owned = false;
65060         LDKBlindedHop b_conv;
65061         b_conv.inner = untag_ptr(b);
65062         b_conv.is_owned = ptr_is_owned(b);
65063         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
65064         b_conv.is_owned = false;
65065         jboolean ret_conv = BlindedHop_eq(&a_conv, &b_conv);
65066         return ret_conv;
65067 }
65068
65069 int64_t  CS_LDK_BlindedPath_one_hop_for_message(int8_tArray recipient_node_id, int64_t entropy_source) {
65070         LDKPublicKey recipient_node_id_ref;
65071         CHECK(recipient_node_id->arr_len == 33);
65072         memcpy(recipient_node_id_ref.compressed_form, recipient_node_id->elems, 33); FREE(recipient_node_id);
65073         void* entropy_source_ptr = untag_ptr(entropy_source);
65074         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
65075         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
65076         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
65077         *ret_conv = BlindedPath_one_hop_for_message(recipient_node_id_ref, entropy_source_conv);
65078         return tag_ptr(ret_conv, true);
65079 }
65080
65081 int64_t  CS_LDK_BlindedPath_new_for_message(ptrArray node_pks, int64_t entropy_source) {
65082         LDKCVec_PublicKeyZ node_pks_constr;
65083         node_pks_constr.datalen = node_pks->arr_len;
65084         if (node_pks_constr.datalen > 0)
65085                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
65086         else
65087                 node_pks_constr.data = NULL;
65088         int8_tArray* node_pks_vals = (void*) node_pks->elems;
65089         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
65090                 int8_tArray node_pks_conv_8 = node_pks_vals[i];
65091                 LDKPublicKey node_pks_conv_8_ref;
65092                 CHECK(node_pks_conv_8->arr_len == 33);
65093                 memcpy(node_pks_conv_8_ref.compressed_form, node_pks_conv_8->elems, 33); FREE(node_pks_conv_8);
65094                 node_pks_constr.data[i] = node_pks_conv_8_ref;
65095         }
65096         FREE(node_pks);
65097         void* entropy_source_ptr = untag_ptr(entropy_source);
65098         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
65099         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
65100         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
65101         *ret_conv = BlindedPath_new_for_message(node_pks_constr, entropy_source_conv);
65102         return tag_ptr(ret_conv, true);
65103 }
65104
65105 int64_t  CS_LDK_BlindedPath_one_hop_for_payment(int8_tArray payee_node_id, int64_t payee_tlvs, int64_t entropy_source) {
65106         LDKPublicKey payee_node_id_ref;
65107         CHECK(payee_node_id->arr_len == 33);
65108         memcpy(payee_node_id_ref.compressed_form, payee_node_id->elems, 33); FREE(payee_node_id);
65109         LDKReceiveTlvs payee_tlvs_conv;
65110         payee_tlvs_conv.inner = untag_ptr(payee_tlvs);
65111         payee_tlvs_conv.is_owned = ptr_is_owned(payee_tlvs);
65112         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_tlvs_conv);
65113         payee_tlvs_conv = ReceiveTlvs_clone(&payee_tlvs_conv);
65114         void* entropy_source_ptr = untag_ptr(entropy_source);
65115         if (ptr_is_owned(entropy_source)) { CHECK_ACCESS(entropy_source_ptr); }
65116         LDKEntropySource* entropy_source_conv = (LDKEntropySource*)entropy_source_ptr;
65117         LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ), "LDKCResult_C2Tuple_BlindedPayInfoBlindedPathZNoneZ");
65118         *ret_conv = BlindedPath_one_hop_for_payment(payee_node_id_ref, payee_tlvs_conv, entropy_source_conv);
65119         return tag_ptr(ret_conv, true);
65120 }
65121
65122 int8_tArray  CS_LDK_BlindedPath_write(int64_t obj) {
65123         LDKBlindedPath obj_conv;
65124         obj_conv.inner = untag_ptr(obj);
65125         obj_conv.is_owned = ptr_is_owned(obj);
65126         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65127         obj_conv.is_owned = false;
65128         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
65129         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65130         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65131         CVec_u8Z_free(ret_var);
65132         return ret_arr;
65133 }
65134
65135 int64_t  CS_LDK_BlindedPath_read(int8_tArray ser) {
65136         LDKu8slice ser_ref;
65137         ser_ref.datalen = ser->arr_len;
65138         ser_ref.data = ser->elems;
65139         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
65140         *ret_conv = BlindedPath_read(ser_ref);
65141         FREE(ser);
65142         return tag_ptr(ret_conv, true);
65143 }
65144
65145 int8_tArray  CS_LDK_BlindedHop_write(int64_t obj) {
65146         LDKBlindedHop obj_conv;
65147         obj_conv.inner = untag_ptr(obj);
65148         obj_conv.is_owned = ptr_is_owned(obj);
65149         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65150         obj_conv.is_owned = false;
65151         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
65152         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65153         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65154         CVec_u8Z_free(ret_var);
65155         return ret_arr;
65156 }
65157
65158 int64_t  CS_LDK_BlindedHop_read(int8_tArray ser) {
65159         LDKu8slice ser_ref;
65160         ser_ref.datalen = ser->arr_len;
65161         ser_ref.data = ser->elems;
65162         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
65163         *ret_conv = BlindedHop_read(ser_ref);
65164         FREE(ser);
65165         return tag_ptr(ret_conv, true);
65166 }
65167
65168 void  CS_LDK_ForwardNode_free(int64_t this_obj) {
65169         LDKForwardNode this_obj_conv;
65170         this_obj_conv.inner = untag_ptr(this_obj);
65171         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65173         ForwardNode_free(this_obj_conv);
65174 }
65175
65176 int64_t  CS_LDK_ForwardNode_get_tlvs(int64_t this_ptr) {
65177         LDKForwardNode this_ptr_conv;
65178         this_ptr_conv.inner = untag_ptr(this_ptr);
65179         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65181         this_ptr_conv.is_owned = false;
65182         LDKForwardTlvs ret_var = ForwardNode_get_tlvs(&this_ptr_conv);
65183         int64_t ret_ref = 0;
65184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65186         return ret_ref;
65187 }
65188
65189 void  CS_LDK_ForwardNode_set_tlvs(int64_t this_ptr, int64_t val) {
65190         LDKForwardNode this_ptr_conv;
65191         this_ptr_conv.inner = untag_ptr(this_ptr);
65192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65194         this_ptr_conv.is_owned = false;
65195         LDKForwardTlvs val_conv;
65196         val_conv.inner = untag_ptr(val);
65197         val_conv.is_owned = ptr_is_owned(val);
65198         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65199         val_conv = ForwardTlvs_clone(&val_conv);
65200         ForwardNode_set_tlvs(&this_ptr_conv, val_conv);
65201 }
65202
65203 int8_tArray  CS_LDK_ForwardNode_get_node_id(int64_t this_ptr) {
65204         LDKForwardNode this_ptr_conv;
65205         this_ptr_conv.inner = untag_ptr(this_ptr);
65206         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65208         this_ptr_conv.is_owned = false;
65209         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
65210         memcpy(ret_arr->elems, ForwardNode_get_node_id(&this_ptr_conv).compressed_form, 33);
65211         return ret_arr;
65212 }
65213
65214 void  CS_LDK_ForwardNode_set_node_id(int64_t this_ptr, int8_tArray val) {
65215         LDKForwardNode this_ptr_conv;
65216         this_ptr_conv.inner = untag_ptr(this_ptr);
65217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65219         this_ptr_conv.is_owned = false;
65220         LDKPublicKey val_ref;
65221         CHECK(val->arr_len == 33);
65222         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
65223         ForwardNode_set_node_id(&this_ptr_conv, val_ref);
65224 }
65225
65226 int64_t  CS_LDK_ForwardNode_get_htlc_maximum_msat(int64_t this_ptr) {
65227         LDKForwardNode this_ptr_conv;
65228         this_ptr_conv.inner = untag_ptr(this_ptr);
65229         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65231         this_ptr_conv.is_owned = false;
65232         int64_t ret_conv = ForwardNode_get_htlc_maximum_msat(&this_ptr_conv);
65233         return ret_conv;
65234 }
65235
65236 void  CS_LDK_ForwardNode_set_htlc_maximum_msat(int64_t this_ptr, int64_t val) {
65237         LDKForwardNode this_ptr_conv;
65238         this_ptr_conv.inner = untag_ptr(this_ptr);
65239         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65241         this_ptr_conv.is_owned = false;
65242         ForwardNode_set_htlc_maximum_msat(&this_ptr_conv, val);
65243 }
65244
65245 int64_t  CS_LDK_ForwardNode_new(int64_t tlvs_arg, int8_tArray node_id_arg, int64_t htlc_maximum_msat_arg) {
65246         LDKForwardTlvs tlvs_arg_conv;
65247         tlvs_arg_conv.inner = untag_ptr(tlvs_arg);
65248         tlvs_arg_conv.is_owned = ptr_is_owned(tlvs_arg);
65249         CHECK_INNER_FIELD_ACCESS_OR_NULL(tlvs_arg_conv);
65250         tlvs_arg_conv = ForwardTlvs_clone(&tlvs_arg_conv);
65251         LDKPublicKey node_id_arg_ref;
65252         CHECK(node_id_arg->arr_len == 33);
65253         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
65254         LDKForwardNode ret_var = ForwardNode_new(tlvs_arg_conv, node_id_arg_ref, htlc_maximum_msat_arg);
65255         int64_t ret_ref = 0;
65256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65258         return ret_ref;
65259 }
65260
65261 static inline uint64_t ForwardNode_clone_ptr(LDKForwardNode *NONNULL_PTR arg) {
65262         LDKForwardNode ret_var = ForwardNode_clone(arg);
65263         int64_t ret_ref = 0;
65264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65266         return ret_ref;
65267 }
65268 int64_t  CS_LDK_ForwardNode_clone_ptr(int64_t arg) {
65269         LDKForwardNode arg_conv;
65270         arg_conv.inner = untag_ptr(arg);
65271         arg_conv.is_owned = ptr_is_owned(arg);
65272         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65273         arg_conv.is_owned = false;
65274         int64_t ret_conv = ForwardNode_clone_ptr(&arg_conv);
65275         return ret_conv;
65276 }
65277
65278 int64_t  CS_LDK_ForwardNode_clone(int64_t orig) {
65279         LDKForwardNode orig_conv;
65280         orig_conv.inner = untag_ptr(orig);
65281         orig_conv.is_owned = ptr_is_owned(orig);
65282         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65283         orig_conv.is_owned = false;
65284         LDKForwardNode ret_var = ForwardNode_clone(&orig_conv);
65285         int64_t ret_ref = 0;
65286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65288         return ret_ref;
65289 }
65290
65291 void  CS_LDK_ForwardTlvs_free(int64_t this_obj) {
65292         LDKForwardTlvs this_obj_conv;
65293         this_obj_conv.inner = untag_ptr(this_obj);
65294         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65296         ForwardTlvs_free(this_obj_conv);
65297 }
65298
65299 int64_t  CS_LDK_ForwardTlvs_get_short_channel_id(int64_t this_ptr) {
65300         LDKForwardTlvs this_ptr_conv;
65301         this_ptr_conv.inner = untag_ptr(this_ptr);
65302         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65304         this_ptr_conv.is_owned = false;
65305         int64_t ret_conv = ForwardTlvs_get_short_channel_id(&this_ptr_conv);
65306         return ret_conv;
65307 }
65308
65309 void  CS_LDK_ForwardTlvs_set_short_channel_id(int64_t this_ptr, int64_t val) {
65310         LDKForwardTlvs this_ptr_conv;
65311         this_ptr_conv.inner = untag_ptr(this_ptr);
65312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65314         this_ptr_conv.is_owned = false;
65315         ForwardTlvs_set_short_channel_id(&this_ptr_conv, val);
65316 }
65317
65318 int64_t  CS_LDK_ForwardTlvs_get_payment_relay(int64_t this_ptr) {
65319         LDKForwardTlvs this_ptr_conv;
65320         this_ptr_conv.inner = untag_ptr(this_ptr);
65321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65323         this_ptr_conv.is_owned = false;
65324         LDKPaymentRelay ret_var = ForwardTlvs_get_payment_relay(&this_ptr_conv);
65325         int64_t ret_ref = 0;
65326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65327         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65328         return ret_ref;
65329 }
65330
65331 void  CS_LDK_ForwardTlvs_set_payment_relay(int64_t this_ptr, int64_t val) {
65332         LDKForwardTlvs this_ptr_conv;
65333         this_ptr_conv.inner = untag_ptr(this_ptr);
65334         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65336         this_ptr_conv.is_owned = false;
65337         LDKPaymentRelay val_conv;
65338         val_conv.inner = untag_ptr(val);
65339         val_conv.is_owned = ptr_is_owned(val);
65340         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65341         val_conv = PaymentRelay_clone(&val_conv);
65342         ForwardTlvs_set_payment_relay(&this_ptr_conv, val_conv);
65343 }
65344
65345 int64_t  CS_LDK_ForwardTlvs_get_payment_constraints(int64_t this_ptr) {
65346         LDKForwardTlvs this_ptr_conv;
65347         this_ptr_conv.inner = untag_ptr(this_ptr);
65348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65350         this_ptr_conv.is_owned = false;
65351         LDKPaymentConstraints ret_var = ForwardTlvs_get_payment_constraints(&this_ptr_conv);
65352         int64_t ret_ref = 0;
65353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65354         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65355         return ret_ref;
65356 }
65357
65358 void  CS_LDK_ForwardTlvs_set_payment_constraints(int64_t this_ptr, int64_t val) {
65359         LDKForwardTlvs this_ptr_conv;
65360         this_ptr_conv.inner = untag_ptr(this_ptr);
65361         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65363         this_ptr_conv.is_owned = false;
65364         LDKPaymentConstraints val_conv;
65365         val_conv.inner = untag_ptr(val);
65366         val_conv.is_owned = ptr_is_owned(val);
65367         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65368         val_conv = PaymentConstraints_clone(&val_conv);
65369         ForwardTlvs_set_payment_constraints(&this_ptr_conv, val_conv);
65370 }
65371
65372 int64_t  CS_LDK_ForwardTlvs_get_features(int64_t this_ptr) {
65373         LDKForwardTlvs this_ptr_conv;
65374         this_ptr_conv.inner = untag_ptr(this_ptr);
65375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65377         this_ptr_conv.is_owned = false;
65378         LDKBlindedHopFeatures ret_var = ForwardTlvs_get_features(&this_ptr_conv);
65379         int64_t ret_ref = 0;
65380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65382         return ret_ref;
65383 }
65384
65385 void  CS_LDK_ForwardTlvs_set_features(int64_t this_ptr, int64_t val) {
65386         LDKForwardTlvs this_ptr_conv;
65387         this_ptr_conv.inner = untag_ptr(this_ptr);
65388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65390         this_ptr_conv.is_owned = false;
65391         LDKBlindedHopFeatures val_conv;
65392         val_conv.inner = untag_ptr(val);
65393         val_conv.is_owned = ptr_is_owned(val);
65394         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65395         val_conv = BlindedHopFeatures_clone(&val_conv);
65396         ForwardTlvs_set_features(&this_ptr_conv, val_conv);
65397 }
65398
65399 int64_t  CS_LDK_ForwardTlvs_new(int64_t short_channel_id_arg, int64_t payment_relay_arg, int64_t payment_constraints_arg, int64_t features_arg) {
65400         LDKPaymentRelay payment_relay_arg_conv;
65401         payment_relay_arg_conv.inner = untag_ptr(payment_relay_arg);
65402         payment_relay_arg_conv.is_owned = ptr_is_owned(payment_relay_arg);
65403         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_relay_arg_conv);
65404         payment_relay_arg_conv = PaymentRelay_clone(&payment_relay_arg_conv);
65405         LDKPaymentConstraints payment_constraints_arg_conv;
65406         payment_constraints_arg_conv.inner = untag_ptr(payment_constraints_arg);
65407         payment_constraints_arg_conv.is_owned = ptr_is_owned(payment_constraints_arg);
65408         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_constraints_arg_conv);
65409         payment_constraints_arg_conv = PaymentConstraints_clone(&payment_constraints_arg_conv);
65410         LDKBlindedHopFeatures features_arg_conv;
65411         features_arg_conv.inner = untag_ptr(features_arg);
65412         features_arg_conv.is_owned = ptr_is_owned(features_arg);
65413         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
65414         features_arg_conv = BlindedHopFeatures_clone(&features_arg_conv);
65415         LDKForwardTlvs ret_var = ForwardTlvs_new(short_channel_id_arg, payment_relay_arg_conv, payment_constraints_arg_conv, features_arg_conv);
65416         int64_t ret_ref = 0;
65417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65418         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65419         return ret_ref;
65420 }
65421
65422 static inline uint64_t ForwardTlvs_clone_ptr(LDKForwardTlvs *NONNULL_PTR arg) {
65423         LDKForwardTlvs ret_var = ForwardTlvs_clone(arg);
65424         int64_t ret_ref = 0;
65425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65426         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65427         return ret_ref;
65428 }
65429 int64_t  CS_LDK_ForwardTlvs_clone_ptr(int64_t arg) {
65430         LDKForwardTlvs arg_conv;
65431         arg_conv.inner = untag_ptr(arg);
65432         arg_conv.is_owned = ptr_is_owned(arg);
65433         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65434         arg_conv.is_owned = false;
65435         int64_t ret_conv = ForwardTlvs_clone_ptr(&arg_conv);
65436         return ret_conv;
65437 }
65438
65439 int64_t  CS_LDK_ForwardTlvs_clone(int64_t orig) {
65440         LDKForwardTlvs orig_conv;
65441         orig_conv.inner = untag_ptr(orig);
65442         orig_conv.is_owned = ptr_is_owned(orig);
65443         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65444         orig_conv.is_owned = false;
65445         LDKForwardTlvs ret_var = ForwardTlvs_clone(&orig_conv);
65446         int64_t ret_ref = 0;
65447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65449         return ret_ref;
65450 }
65451
65452 void  CS_LDK_ReceiveTlvs_free(int64_t this_obj) {
65453         LDKReceiveTlvs this_obj_conv;
65454         this_obj_conv.inner = untag_ptr(this_obj);
65455         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65457         ReceiveTlvs_free(this_obj_conv);
65458 }
65459
65460 int8_tArray  CS_LDK_ReceiveTlvs_get_payment_secret(int64_t this_ptr) {
65461         LDKReceiveTlvs this_ptr_conv;
65462         this_ptr_conv.inner = untag_ptr(this_ptr);
65463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65465         this_ptr_conv.is_owned = false;
65466         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
65467         memcpy(ret_arr->elems, *ReceiveTlvs_get_payment_secret(&this_ptr_conv), 32);
65468         return ret_arr;
65469 }
65470
65471 void  CS_LDK_ReceiveTlvs_set_payment_secret(int64_t this_ptr, int8_tArray val) {
65472         LDKReceiveTlvs this_ptr_conv;
65473         this_ptr_conv.inner = untag_ptr(this_ptr);
65474         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65476         this_ptr_conv.is_owned = false;
65477         LDKThirtyTwoBytes val_ref;
65478         CHECK(val->arr_len == 32);
65479         memcpy(val_ref.data, val->elems, 32); FREE(val);
65480         ReceiveTlvs_set_payment_secret(&this_ptr_conv, val_ref);
65481 }
65482
65483 int64_t  CS_LDK_ReceiveTlvs_get_payment_constraints(int64_t this_ptr) {
65484         LDKReceiveTlvs this_ptr_conv;
65485         this_ptr_conv.inner = untag_ptr(this_ptr);
65486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65488         this_ptr_conv.is_owned = false;
65489         LDKPaymentConstraints ret_var = ReceiveTlvs_get_payment_constraints(&this_ptr_conv);
65490         int64_t ret_ref = 0;
65491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65493         return ret_ref;
65494 }
65495
65496 void  CS_LDK_ReceiveTlvs_set_payment_constraints(int64_t this_ptr, int64_t val) {
65497         LDKReceiveTlvs this_ptr_conv;
65498         this_ptr_conv.inner = untag_ptr(this_ptr);
65499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65501         this_ptr_conv.is_owned = false;
65502         LDKPaymentConstraints val_conv;
65503         val_conv.inner = untag_ptr(val);
65504         val_conv.is_owned = ptr_is_owned(val);
65505         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
65506         val_conv = PaymentConstraints_clone(&val_conv);
65507         ReceiveTlvs_set_payment_constraints(&this_ptr_conv, val_conv);
65508 }
65509
65510 int64_t  CS_LDK_ReceiveTlvs_new(int8_tArray payment_secret_arg, int64_t payment_constraints_arg) {
65511         LDKThirtyTwoBytes payment_secret_arg_ref;
65512         CHECK(payment_secret_arg->arr_len == 32);
65513         memcpy(payment_secret_arg_ref.data, payment_secret_arg->elems, 32); FREE(payment_secret_arg);
65514         LDKPaymentConstraints payment_constraints_arg_conv;
65515         payment_constraints_arg_conv.inner = untag_ptr(payment_constraints_arg);
65516         payment_constraints_arg_conv.is_owned = ptr_is_owned(payment_constraints_arg);
65517         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_constraints_arg_conv);
65518         payment_constraints_arg_conv = PaymentConstraints_clone(&payment_constraints_arg_conv);
65519         LDKReceiveTlvs ret_var = ReceiveTlvs_new(payment_secret_arg_ref, payment_constraints_arg_conv);
65520         int64_t ret_ref = 0;
65521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65523         return ret_ref;
65524 }
65525
65526 static inline uint64_t ReceiveTlvs_clone_ptr(LDKReceiveTlvs *NONNULL_PTR arg) {
65527         LDKReceiveTlvs ret_var = ReceiveTlvs_clone(arg);
65528         int64_t ret_ref = 0;
65529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65531         return ret_ref;
65532 }
65533 int64_t  CS_LDK_ReceiveTlvs_clone_ptr(int64_t arg) {
65534         LDKReceiveTlvs arg_conv;
65535         arg_conv.inner = untag_ptr(arg);
65536         arg_conv.is_owned = ptr_is_owned(arg);
65537         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65538         arg_conv.is_owned = false;
65539         int64_t ret_conv = ReceiveTlvs_clone_ptr(&arg_conv);
65540         return ret_conv;
65541 }
65542
65543 int64_t  CS_LDK_ReceiveTlvs_clone(int64_t orig) {
65544         LDKReceiveTlvs orig_conv;
65545         orig_conv.inner = untag_ptr(orig);
65546         orig_conv.is_owned = ptr_is_owned(orig);
65547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65548         orig_conv.is_owned = false;
65549         LDKReceiveTlvs ret_var = ReceiveTlvs_clone(&orig_conv);
65550         int64_t ret_ref = 0;
65551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65553         return ret_ref;
65554 }
65555
65556 void  CS_LDK_PaymentRelay_free(int64_t this_obj) {
65557         LDKPaymentRelay this_obj_conv;
65558         this_obj_conv.inner = untag_ptr(this_obj);
65559         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65561         PaymentRelay_free(this_obj_conv);
65562 }
65563
65564 int16_t  CS_LDK_PaymentRelay_get_cltv_expiry_delta(int64_t this_ptr) {
65565         LDKPaymentRelay this_ptr_conv;
65566         this_ptr_conv.inner = untag_ptr(this_ptr);
65567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65569         this_ptr_conv.is_owned = false;
65570         int16_t ret_conv = PaymentRelay_get_cltv_expiry_delta(&this_ptr_conv);
65571         return ret_conv;
65572 }
65573
65574 void  CS_LDK_PaymentRelay_set_cltv_expiry_delta(int64_t this_ptr, int16_t val) {
65575         LDKPaymentRelay this_ptr_conv;
65576         this_ptr_conv.inner = untag_ptr(this_ptr);
65577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65579         this_ptr_conv.is_owned = false;
65580         PaymentRelay_set_cltv_expiry_delta(&this_ptr_conv, val);
65581 }
65582
65583 int32_t  CS_LDK_PaymentRelay_get_fee_proportional_millionths(int64_t this_ptr) {
65584         LDKPaymentRelay this_ptr_conv;
65585         this_ptr_conv.inner = untag_ptr(this_ptr);
65586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65588         this_ptr_conv.is_owned = false;
65589         int32_t ret_conv = PaymentRelay_get_fee_proportional_millionths(&this_ptr_conv);
65590         return ret_conv;
65591 }
65592
65593 void  CS_LDK_PaymentRelay_set_fee_proportional_millionths(int64_t this_ptr, int32_t val) {
65594         LDKPaymentRelay this_ptr_conv;
65595         this_ptr_conv.inner = untag_ptr(this_ptr);
65596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65598         this_ptr_conv.is_owned = false;
65599         PaymentRelay_set_fee_proportional_millionths(&this_ptr_conv, val);
65600 }
65601
65602 int32_t  CS_LDK_PaymentRelay_get_fee_base_msat(int64_t this_ptr) {
65603         LDKPaymentRelay this_ptr_conv;
65604         this_ptr_conv.inner = untag_ptr(this_ptr);
65605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65607         this_ptr_conv.is_owned = false;
65608         int32_t ret_conv = PaymentRelay_get_fee_base_msat(&this_ptr_conv);
65609         return ret_conv;
65610 }
65611
65612 void  CS_LDK_PaymentRelay_set_fee_base_msat(int64_t this_ptr, int32_t val) {
65613         LDKPaymentRelay this_ptr_conv;
65614         this_ptr_conv.inner = untag_ptr(this_ptr);
65615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65617         this_ptr_conv.is_owned = false;
65618         PaymentRelay_set_fee_base_msat(&this_ptr_conv, val);
65619 }
65620
65621 int64_t  CS_LDK_PaymentRelay_new(int16_t cltv_expiry_delta_arg, int32_t fee_proportional_millionths_arg, int32_t fee_base_msat_arg) {
65622         LDKPaymentRelay ret_var = PaymentRelay_new(cltv_expiry_delta_arg, fee_proportional_millionths_arg, fee_base_msat_arg);
65623         int64_t ret_ref = 0;
65624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65626         return ret_ref;
65627 }
65628
65629 static inline uint64_t PaymentRelay_clone_ptr(LDKPaymentRelay *NONNULL_PTR arg) {
65630         LDKPaymentRelay ret_var = PaymentRelay_clone(arg);
65631         int64_t ret_ref = 0;
65632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65634         return ret_ref;
65635 }
65636 int64_t  CS_LDK_PaymentRelay_clone_ptr(int64_t arg) {
65637         LDKPaymentRelay arg_conv;
65638         arg_conv.inner = untag_ptr(arg);
65639         arg_conv.is_owned = ptr_is_owned(arg);
65640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65641         arg_conv.is_owned = false;
65642         int64_t ret_conv = PaymentRelay_clone_ptr(&arg_conv);
65643         return ret_conv;
65644 }
65645
65646 int64_t  CS_LDK_PaymentRelay_clone(int64_t orig) {
65647         LDKPaymentRelay orig_conv;
65648         orig_conv.inner = untag_ptr(orig);
65649         orig_conv.is_owned = ptr_is_owned(orig);
65650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65651         orig_conv.is_owned = false;
65652         LDKPaymentRelay ret_var = PaymentRelay_clone(&orig_conv);
65653         int64_t ret_ref = 0;
65654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65656         return ret_ref;
65657 }
65658
65659 void  CS_LDK_PaymentConstraints_free(int64_t this_obj) {
65660         LDKPaymentConstraints this_obj_conv;
65661         this_obj_conv.inner = untag_ptr(this_obj);
65662         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65664         PaymentConstraints_free(this_obj_conv);
65665 }
65666
65667 int32_t  CS_LDK_PaymentConstraints_get_max_cltv_expiry(int64_t this_ptr) {
65668         LDKPaymentConstraints this_ptr_conv;
65669         this_ptr_conv.inner = untag_ptr(this_ptr);
65670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65672         this_ptr_conv.is_owned = false;
65673         int32_t ret_conv = PaymentConstraints_get_max_cltv_expiry(&this_ptr_conv);
65674         return ret_conv;
65675 }
65676
65677 void  CS_LDK_PaymentConstraints_set_max_cltv_expiry(int64_t this_ptr, int32_t val) {
65678         LDKPaymentConstraints this_ptr_conv;
65679         this_ptr_conv.inner = untag_ptr(this_ptr);
65680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65682         this_ptr_conv.is_owned = false;
65683         PaymentConstraints_set_max_cltv_expiry(&this_ptr_conv, val);
65684 }
65685
65686 int64_t  CS_LDK_PaymentConstraints_get_htlc_minimum_msat(int64_t this_ptr) {
65687         LDKPaymentConstraints this_ptr_conv;
65688         this_ptr_conv.inner = untag_ptr(this_ptr);
65689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65691         this_ptr_conv.is_owned = false;
65692         int64_t ret_conv = PaymentConstraints_get_htlc_minimum_msat(&this_ptr_conv);
65693         return ret_conv;
65694 }
65695
65696 void  CS_LDK_PaymentConstraints_set_htlc_minimum_msat(int64_t this_ptr, int64_t val) {
65697         LDKPaymentConstraints this_ptr_conv;
65698         this_ptr_conv.inner = untag_ptr(this_ptr);
65699         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65701         this_ptr_conv.is_owned = false;
65702         PaymentConstraints_set_htlc_minimum_msat(&this_ptr_conv, val);
65703 }
65704
65705 int64_t  CS_LDK_PaymentConstraints_new(int32_t max_cltv_expiry_arg, int64_t htlc_minimum_msat_arg) {
65706         LDKPaymentConstraints ret_var = PaymentConstraints_new(max_cltv_expiry_arg, htlc_minimum_msat_arg);
65707         int64_t ret_ref = 0;
65708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65709         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65710         return ret_ref;
65711 }
65712
65713 static inline uint64_t PaymentConstraints_clone_ptr(LDKPaymentConstraints *NONNULL_PTR arg) {
65714         LDKPaymentConstraints ret_var = PaymentConstraints_clone(arg);
65715         int64_t ret_ref = 0;
65716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65718         return ret_ref;
65719 }
65720 int64_t  CS_LDK_PaymentConstraints_clone_ptr(int64_t arg) {
65721         LDKPaymentConstraints arg_conv;
65722         arg_conv.inner = untag_ptr(arg);
65723         arg_conv.is_owned = ptr_is_owned(arg);
65724         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
65725         arg_conv.is_owned = false;
65726         int64_t ret_conv = PaymentConstraints_clone_ptr(&arg_conv);
65727         return ret_conv;
65728 }
65729
65730 int64_t  CS_LDK_PaymentConstraints_clone(int64_t orig) {
65731         LDKPaymentConstraints orig_conv;
65732         orig_conv.inner = untag_ptr(orig);
65733         orig_conv.is_owned = ptr_is_owned(orig);
65734         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
65735         orig_conv.is_owned = false;
65736         LDKPaymentConstraints ret_var = PaymentConstraints_clone(&orig_conv);
65737         int64_t ret_ref = 0;
65738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
65739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
65740         return ret_ref;
65741 }
65742
65743 int8_tArray  CS_LDK_ForwardTlvs_write(int64_t obj) {
65744         LDKForwardTlvs obj_conv;
65745         obj_conv.inner = untag_ptr(obj);
65746         obj_conv.is_owned = ptr_is_owned(obj);
65747         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65748         obj_conv.is_owned = false;
65749         LDKCVec_u8Z ret_var = ForwardTlvs_write(&obj_conv);
65750         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65751         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65752         CVec_u8Z_free(ret_var);
65753         return ret_arr;
65754 }
65755
65756 int8_tArray  CS_LDK_ReceiveTlvs_write(int64_t obj) {
65757         LDKReceiveTlvs obj_conv;
65758         obj_conv.inner = untag_ptr(obj);
65759         obj_conv.is_owned = ptr_is_owned(obj);
65760         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65761         obj_conv.is_owned = false;
65762         LDKCVec_u8Z ret_var = ReceiveTlvs_write(&obj_conv);
65763         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65764         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65765         CVec_u8Z_free(ret_var);
65766         return ret_arr;
65767 }
65768
65769 int64_t  CS_LDK_ReceiveTlvs_read(int8_tArray ser) {
65770         LDKu8slice ser_ref;
65771         ser_ref.datalen = ser->arr_len;
65772         ser_ref.data = ser->elems;
65773         LDKCResult_ReceiveTlvsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReceiveTlvsDecodeErrorZ), "LDKCResult_ReceiveTlvsDecodeErrorZ");
65774         *ret_conv = ReceiveTlvs_read(ser_ref);
65775         FREE(ser);
65776         return tag_ptr(ret_conv, true);
65777 }
65778
65779 int8_tArray  CS_LDK_PaymentRelay_write(int64_t obj) {
65780         LDKPaymentRelay obj_conv;
65781         obj_conv.inner = untag_ptr(obj);
65782         obj_conv.is_owned = ptr_is_owned(obj);
65783         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65784         obj_conv.is_owned = false;
65785         LDKCVec_u8Z ret_var = PaymentRelay_write(&obj_conv);
65786         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65787         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65788         CVec_u8Z_free(ret_var);
65789         return ret_arr;
65790 }
65791
65792 int64_t  CS_LDK_PaymentRelay_read(int8_tArray ser) {
65793         LDKu8slice ser_ref;
65794         ser_ref.datalen = ser->arr_len;
65795         ser_ref.data = ser->elems;
65796         LDKCResult_PaymentRelayDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentRelayDecodeErrorZ), "LDKCResult_PaymentRelayDecodeErrorZ");
65797         *ret_conv = PaymentRelay_read(ser_ref);
65798         FREE(ser);
65799         return tag_ptr(ret_conv, true);
65800 }
65801
65802 int8_tArray  CS_LDK_PaymentConstraints_write(int64_t obj) {
65803         LDKPaymentConstraints obj_conv;
65804         obj_conv.inner = untag_ptr(obj);
65805         obj_conv.is_owned = ptr_is_owned(obj);
65806         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
65807         obj_conv.is_owned = false;
65808         LDKCVec_u8Z ret_var = PaymentConstraints_write(&obj_conv);
65809         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65810         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65811         CVec_u8Z_free(ret_var);
65812         return ret_arr;
65813 }
65814
65815 int64_t  CS_LDK_PaymentConstraints_read(int8_tArray ser) {
65816         LDKu8slice ser_ref;
65817         ser_ref.datalen = ser->arr_len;
65818         ser_ref.data = ser->elems;
65819         LDKCResult_PaymentConstraintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentConstraintsDecodeErrorZ), "LDKCResult_PaymentConstraintsDecodeErrorZ");
65820         *ret_conv = PaymentConstraints_read(ser_ref);
65821         FREE(ser);
65822         return tag_ptr(ret_conv, true);
65823 }
65824
65825 void  CS_LDK_PaymentPurpose_free(int64_t this_ptr) {
65826         if (!ptr_is_owned(this_ptr)) return;
65827         void* this_ptr_ptr = untag_ptr(this_ptr);
65828         CHECK_ACCESS(this_ptr_ptr);
65829         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
65830         FREE(untag_ptr(this_ptr));
65831         PaymentPurpose_free(this_ptr_conv);
65832 }
65833
65834 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
65835         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65836         *ret_copy = PaymentPurpose_clone(arg);
65837         int64_t ret_ref = tag_ptr(ret_copy, true);
65838         return ret_ref;
65839 }
65840 int64_t  CS_LDK_PaymentPurpose_clone_ptr(int64_t arg) {
65841         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
65842         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
65843         return ret_conv;
65844 }
65845
65846 int64_t  CS_LDK_PaymentPurpose_clone(int64_t orig) {
65847         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
65848         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65849         *ret_copy = PaymentPurpose_clone(orig_conv);
65850         int64_t ret_ref = tag_ptr(ret_copy, true);
65851         return ret_ref;
65852 }
65853
65854 int64_t  CS_LDK_PaymentPurpose_invoice_payment(int64_t payment_preimage, int8_tArray payment_secret) {
65855         void* payment_preimage_ptr = untag_ptr(payment_preimage);
65856         CHECK_ACCESS(payment_preimage_ptr);
65857         LDKCOption_ThirtyTwoBytesZ payment_preimage_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_preimage_ptr);
65858         payment_preimage_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_preimage));
65859         LDKThirtyTwoBytes payment_secret_ref;
65860         CHECK(payment_secret->arr_len == 32);
65861         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
65862         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65863         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_conv, payment_secret_ref);
65864         int64_t ret_ref = tag_ptr(ret_copy, true);
65865         return ret_ref;
65866 }
65867
65868 int64_t  CS_LDK_PaymentPurpose_spontaneous_payment(int8_tArray a) {
65869         LDKThirtyTwoBytes a_ref;
65870         CHECK(a->arr_len == 32);
65871         memcpy(a_ref.data, a->elems, 32); FREE(a);
65872         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
65873         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
65874         int64_t ret_ref = tag_ptr(ret_copy, true);
65875         return ret_ref;
65876 }
65877
65878 jboolean  CS_LDK_PaymentPurpose_eq(int64_t a, int64_t b) {
65879         LDKPaymentPurpose* a_conv = (LDKPaymentPurpose*)untag_ptr(a);
65880         LDKPaymentPurpose* b_conv = (LDKPaymentPurpose*)untag_ptr(b);
65881         jboolean ret_conv = PaymentPurpose_eq(a_conv, b_conv);
65882         return ret_conv;
65883 }
65884
65885 int8_tArray  CS_LDK_PaymentPurpose_write(int64_t obj) {
65886         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
65887         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
65888         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
65889         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
65890         CVec_u8Z_free(ret_var);
65891         return ret_arr;
65892 }
65893
65894 int64_t  CS_LDK_PaymentPurpose_read(int8_tArray ser) {
65895         LDKu8slice ser_ref;
65896         ser_ref.datalen = ser->arr_len;
65897         ser_ref.data = ser->elems;
65898         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
65899         *ret_conv = PaymentPurpose_read(ser_ref);
65900         FREE(ser);
65901         return tag_ptr(ret_conv, true);
65902 }
65903
65904 void  CS_LDK_ClaimedHTLC_free(int64_t this_obj) {
65905         LDKClaimedHTLC this_obj_conv;
65906         this_obj_conv.inner = untag_ptr(this_obj);
65907         this_obj_conv.is_owned = ptr_is_owned(this_obj);
65908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
65909         ClaimedHTLC_free(this_obj_conv);
65910 }
65911
65912 int8_tArray  CS_LDK_ClaimedHTLC_get_channel_id(int64_t this_ptr) {
65913         LDKClaimedHTLC this_ptr_conv;
65914         this_ptr_conv.inner = untag_ptr(this_ptr);
65915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65917         this_ptr_conv.is_owned = false;
65918         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
65919         memcpy(ret_arr->elems, *ClaimedHTLC_get_channel_id(&this_ptr_conv), 32);
65920         return ret_arr;
65921 }
65922
65923 void  CS_LDK_ClaimedHTLC_set_channel_id(int64_t this_ptr, int8_tArray val) {
65924         LDKClaimedHTLC this_ptr_conv;
65925         this_ptr_conv.inner = untag_ptr(this_ptr);
65926         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65928         this_ptr_conv.is_owned = false;
65929         LDKThirtyTwoBytes val_ref;
65930         CHECK(val->arr_len == 32);
65931         memcpy(val_ref.data, val->elems, 32); FREE(val);
65932         ClaimedHTLC_set_channel_id(&this_ptr_conv, val_ref);
65933 }
65934
65935 int8_tArray  CS_LDK_ClaimedHTLC_get_user_channel_id(int64_t this_ptr) {
65936         LDKClaimedHTLC this_ptr_conv;
65937         this_ptr_conv.inner = untag_ptr(this_ptr);
65938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65940         this_ptr_conv.is_owned = false;
65941         int8_tArray ret_arr = init_int8_tArray(16, __LINE__);
65942         memcpy(ret_arr->elems, ClaimedHTLC_get_user_channel_id(&this_ptr_conv).le_bytes, 16);
65943         return ret_arr;
65944 }
65945
65946 void  CS_LDK_ClaimedHTLC_set_user_channel_id(int64_t this_ptr, int8_tArray val) {
65947         LDKClaimedHTLC this_ptr_conv;
65948         this_ptr_conv.inner = untag_ptr(this_ptr);
65949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65951         this_ptr_conv.is_owned = false;
65952         LDKU128 val_ref;
65953         CHECK(val->arr_len == 16);
65954         memcpy(val_ref.le_bytes, val->elems, 16); FREE(val);
65955         ClaimedHTLC_set_user_channel_id(&this_ptr_conv, val_ref);
65956 }
65957
65958 int32_t  CS_LDK_ClaimedHTLC_get_cltv_expiry(int64_t this_ptr) {
65959         LDKClaimedHTLC this_ptr_conv;
65960         this_ptr_conv.inner = untag_ptr(this_ptr);
65961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65963         this_ptr_conv.is_owned = false;
65964         int32_t ret_conv = ClaimedHTLC_get_cltv_expiry(&this_ptr_conv);
65965         return ret_conv;
65966 }
65967
65968 void  CS_LDK_ClaimedHTLC_set_cltv_expiry(int64_t this_ptr, int32_t val) {
65969         LDKClaimedHTLC this_ptr_conv;
65970         this_ptr_conv.inner = untag_ptr(this_ptr);
65971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65973         this_ptr_conv.is_owned = false;
65974         ClaimedHTLC_set_cltv_expiry(&this_ptr_conv, val);
65975 }
65976
65977 int64_t  CS_LDK_ClaimedHTLC_get_value_msat(int64_t this_ptr) {
65978         LDKClaimedHTLC this_ptr_conv;
65979         this_ptr_conv.inner = untag_ptr(this_ptr);
65980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65982         this_ptr_conv.is_owned = false;
65983         int64_t ret_conv = ClaimedHTLC_get_value_msat(&this_ptr_conv);
65984         return ret_conv;
65985 }
65986
65987 void  CS_LDK_ClaimedHTLC_set_value_msat(int64_t this_ptr, int64_t val) {
65988         LDKClaimedHTLC this_ptr_conv;
65989         this_ptr_conv.inner = untag_ptr(this_ptr);
65990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
65991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
65992         this_ptr_conv.is_owned = false;
65993         ClaimedHTLC_set_value_msat(&this_ptr_conv, val);
65994 }
65995
65996 int64_t  CS_LDK_ClaimedHTLC_new(int8_tArray channel_id_arg, int8_tArray user_channel_id_arg, int32_t cltv_expiry_arg, int64_t value_msat_arg) {
65997         LDKThirtyTwoBytes channel_id_arg_ref;
65998         CHECK(channel_id_arg->arr_len == 32);
65999         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
66000         LDKU128 user_channel_id_arg_ref;
66001         CHECK(user_channel_id_arg->arr_len == 16);
66002         memcpy(user_channel_id_arg_ref.le_bytes, user_channel_id_arg->elems, 16); FREE(user_channel_id_arg);
66003         LDKClaimedHTLC ret_var = ClaimedHTLC_new(channel_id_arg_ref, user_channel_id_arg_ref, cltv_expiry_arg, value_msat_arg);
66004         int64_t ret_ref = 0;
66005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
66006         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
66007         return ret_ref;
66008 }
66009
66010 static inline uint64_t ClaimedHTLC_clone_ptr(LDKClaimedHTLC *NONNULL_PTR arg) {
66011         LDKClaimedHTLC ret_var = ClaimedHTLC_clone(arg);
66012         int64_t ret_ref = 0;
66013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
66014         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
66015         return ret_ref;
66016 }
66017 int64_t  CS_LDK_ClaimedHTLC_clone_ptr(int64_t arg) {
66018         LDKClaimedHTLC arg_conv;
66019         arg_conv.inner = untag_ptr(arg);
66020         arg_conv.is_owned = ptr_is_owned(arg);
66021         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
66022         arg_conv.is_owned = false;
66023         int64_t ret_conv = ClaimedHTLC_clone_ptr(&arg_conv);
66024         return ret_conv;
66025 }
66026
66027 int64_t  CS_LDK_ClaimedHTLC_clone(int64_t orig) {
66028         LDKClaimedHTLC orig_conv;
66029         orig_conv.inner = untag_ptr(orig);
66030         orig_conv.is_owned = ptr_is_owned(orig);
66031         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
66032         orig_conv.is_owned = false;
66033         LDKClaimedHTLC ret_var = ClaimedHTLC_clone(&orig_conv);
66034         int64_t ret_ref = 0;
66035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
66036         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
66037         return ret_ref;
66038 }
66039
66040 jboolean  CS_LDK_ClaimedHTLC_eq(int64_t a, int64_t b) {
66041         LDKClaimedHTLC a_conv;
66042         a_conv.inner = untag_ptr(a);
66043         a_conv.is_owned = ptr_is_owned(a);
66044         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
66045         a_conv.is_owned = false;
66046         LDKClaimedHTLC b_conv;
66047         b_conv.inner = untag_ptr(b);
66048         b_conv.is_owned = ptr_is_owned(b);
66049         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
66050         b_conv.is_owned = false;
66051         jboolean ret_conv = ClaimedHTLC_eq(&a_conv, &b_conv);
66052         return ret_conv;
66053 }
66054
66055 int8_tArray  CS_LDK_ClaimedHTLC_write(int64_t obj) {
66056         LDKClaimedHTLC obj_conv;
66057         obj_conv.inner = untag_ptr(obj);
66058         obj_conv.is_owned = ptr_is_owned(obj);
66059         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
66060         obj_conv.is_owned = false;
66061         LDKCVec_u8Z ret_var = ClaimedHTLC_write(&obj_conv);
66062         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66063         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66064         CVec_u8Z_free(ret_var);
66065         return ret_arr;
66066 }
66067
66068 int64_t  CS_LDK_ClaimedHTLC_read(int8_tArray ser) {
66069         LDKu8slice ser_ref;
66070         ser_ref.datalen = ser->arr_len;
66071         ser_ref.data = ser->elems;
66072         LDKCResult_ClaimedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClaimedHTLCDecodeErrorZ), "LDKCResult_ClaimedHTLCDecodeErrorZ");
66073         *ret_conv = ClaimedHTLC_read(ser_ref);
66074         FREE(ser);
66075         return tag_ptr(ret_conv, true);
66076 }
66077
66078 void  CS_LDK_PathFailure_free(int64_t this_ptr) {
66079         if (!ptr_is_owned(this_ptr)) return;
66080         void* this_ptr_ptr = untag_ptr(this_ptr);
66081         CHECK_ACCESS(this_ptr_ptr);
66082         LDKPathFailure this_ptr_conv = *(LDKPathFailure*)(this_ptr_ptr);
66083         FREE(untag_ptr(this_ptr));
66084         PathFailure_free(this_ptr_conv);
66085 }
66086
66087 static inline uint64_t PathFailure_clone_ptr(LDKPathFailure *NONNULL_PTR arg) {
66088         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66089         *ret_copy = PathFailure_clone(arg);
66090         int64_t ret_ref = tag_ptr(ret_copy, true);
66091         return ret_ref;
66092 }
66093 int64_t  CS_LDK_PathFailure_clone_ptr(int64_t arg) {
66094         LDKPathFailure* arg_conv = (LDKPathFailure*)untag_ptr(arg);
66095         int64_t ret_conv = PathFailure_clone_ptr(arg_conv);
66096         return ret_conv;
66097 }
66098
66099 int64_t  CS_LDK_PathFailure_clone(int64_t orig) {
66100         LDKPathFailure* orig_conv = (LDKPathFailure*)untag_ptr(orig);
66101         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66102         *ret_copy = PathFailure_clone(orig_conv);
66103         int64_t ret_ref = tag_ptr(ret_copy, true);
66104         return ret_ref;
66105 }
66106
66107 int64_t  CS_LDK_PathFailure_initial_send(int64_t err) {
66108         void* err_ptr = untag_ptr(err);
66109         CHECK_ACCESS(err_ptr);
66110         LDKAPIError err_conv = *(LDKAPIError*)(err_ptr);
66111         err_conv = APIError_clone((LDKAPIError*)untag_ptr(err));
66112         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66113         *ret_copy = PathFailure_initial_send(err_conv);
66114         int64_t ret_ref = tag_ptr(ret_copy, true);
66115         return ret_ref;
66116 }
66117
66118 int64_t  CS_LDK_PathFailure_on_path(int64_t network_update) {
66119         void* network_update_ptr = untag_ptr(network_update);
66120         CHECK_ACCESS(network_update_ptr);
66121         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
66122         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
66123         LDKPathFailure *ret_copy = MALLOC(sizeof(LDKPathFailure), "LDKPathFailure");
66124         *ret_copy = PathFailure_on_path(network_update_conv);
66125         int64_t ret_ref = tag_ptr(ret_copy, true);
66126         return ret_ref;
66127 }
66128
66129 jboolean  CS_LDK_PathFailure_eq(int64_t a, int64_t b) {
66130         LDKPathFailure* a_conv = (LDKPathFailure*)untag_ptr(a);
66131         LDKPathFailure* b_conv = (LDKPathFailure*)untag_ptr(b);
66132         jboolean ret_conv = PathFailure_eq(a_conv, b_conv);
66133         return ret_conv;
66134 }
66135
66136 int8_tArray  CS_LDK_PathFailure_write(int64_t obj) {
66137         LDKPathFailure* obj_conv = (LDKPathFailure*)untag_ptr(obj);
66138         LDKCVec_u8Z ret_var = PathFailure_write(obj_conv);
66139         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66140         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66141         CVec_u8Z_free(ret_var);
66142         return ret_arr;
66143 }
66144
66145 int64_t  CS_LDK_PathFailure_read(int8_tArray ser) {
66146         LDKu8slice ser_ref;
66147         ser_ref.datalen = ser->arr_len;
66148         ser_ref.data = ser->elems;
66149         LDKCResult_COption_PathFailureZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_PathFailureZDecodeErrorZ), "LDKCResult_COption_PathFailureZDecodeErrorZ");
66150         *ret_conv = PathFailure_read(ser_ref);
66151         FREE(ser);
66152         return tag_ptr(ret_conv, true);
66153 }
66154
66155 void  CS_LDK_ClosureReason_free(int64_t this_ptr) {
66156         if (!ptr_is_owned(this_ptr)) return;
66157         void* this_ptr_ptr = untag_ptr(this_ptr);
66158         CHECK_ACCESS(this_ptr_ptr);
66159         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
66160         FREE(untag_ptr(this_ptr));
66161         ClosureReason_free(this_ptr_conv);
66162 }
66163
66164 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
66165         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66166         *ret_copy = ClosureReason_clone(arg);
66167         int64_t ret_ref = tag_ptr(ret_copy, true);
66168         return ret_ref;
66169 }
66170 int64_t  CS_LDK_ClosureReason_clone_ptr(int64_t arg) {
66171         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
66172         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
66173         return ret_conv;
66174 }
66175
66176 int64_t  CS_LDK_ClosureReason_clone(int64_t orig) {
66177         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
66178         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66179         *ret_copy = ClosureReason_clone(orig_conv);
66180         int64_t ret_ref = tag_ptr(ret_copy, true);
66181         return ret_ref;
66182 }
66183
66184 int64_t  CS_LDK_ClosureReason_counterparty_force_closed(int64_t peer_msg) {
66185         LDKUntrustedString peer_msg_conv;
66186         peer_msg_conv.inner = untag_ptr(peer_msg);
66187         peer_msg_conv.is_owned = ptr_is_owned(peer_msg);
66188         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_msg_conv);
66189         peer_msg_conv = UntrustedString_clone(&peer_msg_conv);
66190         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66191         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
66192         int64_t ret_ref = tag_ptr(ret_copy, true);
66193         return ret_ref;
66194 }
66195
66196 int64_t  CS_LDK_ClosureReason_holder_force_closed() {
66197         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66198         *ret_copy = ClosureReason_holder_force_closed();
66199         int64_t ret_ref = tag_ptr(ret_copy, true);
66200         return ret_ref;
66201 }
66202
66203 int64_t  CS_LDK_ClosureReason_cooperative_closure() {
66204         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66205         *ret_copy = ClosureReason_cooperative_closure();
66206         int64_t ret_ref = tag_ptr(ret_copy, true);
66207         return ret_ref;
66208 }
66209
66210 int64_t  CS_LDK_ClosureReason_commitment_tx_confirmed() {
66211         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66212         *ret_copy = ClosureReason_commitment_tx_confirmed();
66213         int64_t ret_ref = tag_ptr(ret_copy, true);
66214         return ret_ref;
66215 }
66216
66217 int64_t  CS_LDK_ClosureReason_funding_timed_out() {
66218         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66219         *ret_copy = ClosureReason_funding_timed_out();
66220         int64_t ret_ref = tag_ptr(ret_copy, true);
66221         return ret_ref;
66222 }
66223
66224 int64_t  CS_LDK_ClosureReason_processing_error(jstring err) {
66225         LDKStr err_conv = str_ref_to_owned_c(err);
66226         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66227         *ret_copy = ClosureReason_processing_error(err_conv);
66228         int64_t ret_ref = tag_ptr(ret_copy, true);
66229         return ret_ref;
66230 }
66231
66232 int64_t  CS_LDK_ClosureReason_disconnected_peer() {
66233         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66234         *ret_copy = ClosureReason_disconnected_peer();
66235         int64_t ret_ref = tag_ptr(ret_copy, true);
66236         return ret_ref;
66237 }
66238
66239 int64_t  CS_LDK_ClosureReason_outdated_channel_manager() {
66240         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66241         *ret_copy = ClosureReason_outdated_channel_manager();
66242         int64_t ret_ref = tag_ptr(ret_copy, true);
66243         return ret_ref;
66244 }
66245
66246 int64_t  CS_LDK_ClosureReason_counterparty_coop_closed_unfunded_channel() {
66247         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66248         *ret_copy = ClosureReason_counterparty_coop_closed_unfunded_channel();
66249         int64_t ret_ref = tag_ptr(ret_copy, true);
66250         return ret_ref;
66251 }
66252
66253 int64_t  CS_LDK_ClosureReason_funding_batch_closure() {
66254         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
66255         *ret_copy = ClosureReason_funding_batch_closure();
66256         int64_t ret_ref = tag_ptr(ret_copy, true);
66257         return ret_ref;
66258 }
66259
66260 jboolean  CS_LDK_ClosureReason_eq(int64_t a, int64_t b) {
66261         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
66262         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
66263         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
66264         return ret_conv;
66265 }
66266
66267 int8_tArray  CS_LDK_ClosureReason_write(int64_t obj) {
66268         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
66269         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
66270         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66271         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66272         CVec_u8Z_free(ret_var);
66273         return ret_arr;
66274 }
66275
66276 int64_t  CS_LDK_ClosureReason_read(int8_tArray ser) {
66277         LDKu8slice ser_ref;
66278         ser_ref.datalen = ser->arr_len;
66279         ser_ref.data = ser->elems;
66280         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
66281         *ret_conv = ClosureReason_read(ser_ref);
66282         FREE(ser);
66283         return tag_ptr(ret_conv, true);
66284 }
66285
66286 void  CS_LDK_HTLCDestination_free(int64_t this_ptr) {
66287         if (!ptr_is_owned(this_ptr)) return;
66288         void* this_ptr_ptr = untag_ptr(this_ptr);
66289         CHECK_ACCESS(this_ptr_ptr);
66290         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
66291         FREE(untag_ptr(this_ptr));
66292         HTLCDestination_free(this_ptr_conv);
66293 }
66294
66295 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
66296         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66297         *ret_copy = HTLCDestination_clone(arg);
66298         int64_t ret_ref = tag_ptr(ret_copy, true);
66299         return ret_ref;
66300 }
66301 int64_t  CS_LDK_HTLCDestination_clone_ptr(int64_t arg) {
66302         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
66303         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
66304         return ret_conv;
66305 }
66306
66307 int64_t  CS_LDK_HTLCDestination_clone(int64_t orig) {
66308         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
66309         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66310         *ret_copy = HTLCDestination_clone(orig_conv);
66311         int64_t ret_ref = tag_ptr(ret_copy, true);
66312         return ret_ref;
66313 }
66314
66315 int64_t  CS_LDK_HTLCDestination_next_hop_channel(int8_tArray node_id, int8_tArray channel_id) {
66316         LDKPublicKey node_id_ref;
66317         CHECK(node_id->arr_len == 33);
66318         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66319         LDKThirtyTwoBytes channel_id_ref;
66320         CHECK(channel_id->arr_len == 32);
66321         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66322         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66323         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
66324         int64_t ret_ref = tag_ptr(ret_copy, true);
66325         return ret_ref;
66326 }
66327
66328 int64_t  CS_LDK_HTLCDestination_unknown_next_hop(int64_t requested_forward_scid) {
66329         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66330         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
66331         int64_t ret_ref = tag_ptr(ret_copy, true);
66332         return ret_ref;
66333 }
66334
66335 int64_t  CS_LDK_HTLCDestination_invalid_forward(int64_t requested_forward_scid) {
66336         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66337         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
66338         int64_t ret_ref = tag_ptr(ret_copy, true);
66339         return ret_ref;
66340 }
66341
66342 int64_t  CS_LDK_HTLCDestination_failed_payment(int8_tArray payment_hash) {
66343         LDKThirtyTwoBytes payment_hash_ref;
66344         CHECK(payment_hash->arr_len == 32);
66345         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66346         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
66347         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
66348         int64_t ret_ref = tag_ptr(ret_copy, true);
66349         return ret_ref;
66350 }
66351
66352 jboolean  CS_LDK_HTLCDestination_eq(int64_t a, int64_t b) {
66353         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
66354         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
66355         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
66356         return ret_conv;
66357 }
66358
66359 int8_tArray  CS_LDK_HTLCDestination_write(int64_t obj) {
66360         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
66361         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
66362         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66363         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66364         CVec_u8Z_free(ret_var);
66365         return ret_arr;
66366 }
66367
66368 int64_t  CS_LDK_HTLCDestination_read(int8_tArray ser) {
66369         LDKu8slice ser_ref;
66370         ser_ref.datalen = ser->arr_len;
66371         ser_ref.data = ser->elems;
66372         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
66373         *ret_conv = HTLCDestination_read(ser_ref);
66374         FREE(ser);
66375         return tag_ptr(ret_conv, true);
66376 }
66377
66378 int32_t  CS_LDK_PaymentFailureReason_clone(int64_t orig) {
66379         LDKPaymentFailureReason* orig_conv = (LDKPaymentFailureReason*)untag_ptr(orig);
66380         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_clone(orig_conv));
66381         return ret_conv;
66382 }
66383
66384 int32_t  CS_LDK_PaymentFailureReason_recipient_rejected() {
66385         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_recipient_rejected());
66386         return ret_conv;
66387 }
66388
66389 int32_t  CS_LDK_PaymentFailureReason_user_abandoned() {
66390         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_user_abandoned());
66391         return ret_conv;
66392 }
66393
66394 int32_t  CS_LDK_PaymentFailureReason_retries_exhausted() {
66395         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_retries_exhausted());
66396         return ret_conv;
66397 }
66398
66399 int32_t  CS_LDK_PaymentFailureReason_payment_expired() {
66400         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_payment_expired());
66401         return ret_conv;
66402 }
66403
66404 int32_t  CS_LDK_PaymentFailureReason_route_not_found() {
66405         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_route_not_found());
66406         return ret_conv;
66407 }
66408
66409 int32_t  CS_LDK_PaymentFailureReason_unexpected_error() {
66410         int32_t ret_conv = LDKPaymentFailureReason_to_cs(PaymentFailureReason_unexpected_error());
66411         return ret_conv;
66412 }
66413
66414 jboolean  CS_LDK_PaymentFailureReason_eq(int64_t a, int64_t b) {
66415         LDKPaymentFailureReason* a_conv = (LDKPaymentFailureReason*)untag_ptr(a);
66416         LDKPaymentFailureReason* b_conv = (LDKPaymentFailureReason*)untag_ptr(b);
66417         jboolean ret_conv = PaymentFailureReason_eq(a_conv, b_conv);
66418         return ret_conv;
66419 }
66420
66421 int8_tArray  CS_LDK_PaymentFailureReason_write(int64_t obj) {
66422         LDKPaymentFailureReason* obj_conv = (LDKPaymentFailureReason*)untag_ptr(obj);
66423         LDKCVec_u8Z ret_var = PaymentFailureReason_write(obj_conv);
66424         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66425         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66426         CVec_u8Z_free(ret_var);
66427         return ret_arr;
66428 }
66429
66430 int64_t  CS_LDK_PaymentFailureReason_read(int8_tArray ser) {
66431         LDKu8slice ser_ref;
66432         ser_ref.datalen = ser->arr_len;
66433         ser_ref.data = ser->elems;
66434         LDKCResult_PaymentFailureReasonDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentFailureReasonDecodeErrorZ), "LDKCResult_PaymentFailureReasonDecodeErrorZ");
66435         *ret_conv = PaymentFailureReason_read(ser_ref);
66436         FREE(ser);
66437         return tag_ptr(ret_conv, true);
66438 }
66439
66440 void  CS_LDK_Event_free(int64_t this_ptr) {
66441         if (!ptr_is_owned(this_ptr)) return;
66442         void* this_ptr_ptr = untag_ptr(this_ptr);
66443         CHECK_ACCESS(this_ptr_ptr);
66444         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
66445         FREE(untag_ptr(this_ptr));
66446         Event_free(this_ptr_conv);
66447 }
66448
66449 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
66450         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66451         *ret_copy = Event_clone(arg);
66452         int64_t ret_ref = tag_ptr(ret_copy, true);
66453         return ret_ref;
66454 }
66455 int64_t  CS_LDK_Event_clone_ptr(int64_t arg) {
66456         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
66457         int64_t ret_conv = Event_clone_ptr(arg_conv);
66458         return ret_conv;
66459 }
66460
66461 int64_t  CS_LDK_Event_clone(int64_t orig) {
66462         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
66463         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66464         *ret_copy = Event_clone(orig_conv);
66465         int64_t ret_ref = tag_ptr(ret_copy, true);
66466         return ret_ref;
66467 }
66468
66469 int64_t  CS_LDK_Event_funding_generation_ready(int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int8_tArray user_channel_id) {
66470         LDKThirtyTwoBytes temporary_channel_id_ref;
66471         CHECK(temporary_channel_id->arr_len == 32);
66472         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
66473         LDKPublicKey counterparty_node_id_ref;
66474         CHECK(counterparty_node_id->arr_len == 33);
66475         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66476         LDKCVec_u8Z output_script_ref;
66477         output_script_ref.datalen = output_script->arr_len;
66478         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
66479         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
66480         LDKU128 user_channel_id_ref;
66481         CHECK(user_channel_id->arr_len == 16);
66482         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66483         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66484         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
66485         int64_t ret_ref = tag_ptr(ret_copy, true);
66486         return ret_ref;
66487 }
66488
66489 int64_t  CS_LDK_Event_payment_claimable(int8_tArray receiver_node_id, int8_tArray payment_hash, int64_t onion_fields, int64_t amount_msat, int64_t counterparty_skimmed_fee_msat, int64_t purpose, int64_t via_channel_id, int64_t via_user_channel_id, int64_t claim_deadline) {
66490         LDKPublicKey receiver_node_id_ref;
66491         CHECK(receiver_node_id->arr_len == 33);
66492         memcpy(receiver_node_id_ref.compressed_form, receiver_node_id->elems, 33); FREE(receiver_node_id);
66493         LDKThirtyTwoBytes payment_hash_ref;
66494         CHECK(payment_hash->arr_len == 32);
66495         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66496         LDKRecipientOnionFields onion_fields_conv;
66497         onion_fields_conv.inner = untag_ptr(onion_fields);
66498         onion_fields_conv.is_owned = ptr_is_owned(onion_fields);
66499         CHECK_INNER_FIELD_ACCESS_OR_NULL(onion_fields_conv);
66500         onion_fields_conv = RecipientOnionFields_clone(&onion_fields_conv);
66501         void* purpose_ptr = untag_ptr(purpose);
66502         CHECK_ACCESS(purpose_ptr);
66503         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
66504         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
66505         void* via_channel_id_ptr = untag_ptr(via_channel_id);
66506         CHECK_ACCESS(via_channel_id_ptr);
66507         LDKCOption_ThirtyTwoBytesZ via_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(via_channel_id_ptr);
66508         via_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(via_channel_id));
66509         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
66510         CHECK_ACCESS(via_user_channel_id_ptr);
66511         LDKCOption_U128Z via_user_channel_id_conv = *(LDKCOption_U128Z*)(via_user_channel_id_ptr);
66512         via_user_channel_id_conv = COption_U128Z_clone((LDKCOption_U128Z*)untag_ptr(via_user_channel_id));
66513         void* claim_deadline_ptr = untag_ptr(claim_deadline);
66514         CHECK_ACCESS(claim_deadline_ptr);
66515         LDKCOption_u32Z claim_deadline_conv = *(LDKCOption_u32Z*)(claim_deadline_ptr);
66516         claim_deadline_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(claim_deadline));
66517         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66518         *ret_copy = Event_payment_claimable(receiver_node_id_ref, payment_hash_ref, onion_fields_conv, amount_msat, counterparty_skimmed_fee_msat, purpose_conv, via_channel_id_conv, via_user_channel_id_conv, claim_deadline_conv);
66519         int64_t ret_ref = tag_ptr(ret_copy, true);
66520         return ret_ref;
66521 }
66522
66523 int64_t  CS_LDK_Event_payment_claimed(int8_tArray receiver_node_id, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose, int64_tArray htlcs, int64_t sender_intended_total_msat) {
66524         LDKPublicKey receiver_node_id_ref;
66525         CHECK(receiver_node_id->arr_len == 33);
66526         memcpy(receiver_node_id_ref.compressed_form, receiver_node_id->elems, 33); FREE(receiver_node_id);
66527         LDKThirtyTwoBytes payment_hash_ref;
66528         CHECK(payment_hash->arr_len == 32);
66529         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66530         void* purpose_ptr = untag_ptr(purpose);
66531         CHECK_ACCESS(purpose_ptr);
66532         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
66533         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
66534         LDKCVec_ClaimedHTLCZ htlcs_constr;
66535         htlcs_constr.datalen = htlcs->arr_len;
66536         if (htlcs_constr.datalen > 0)
66537                 htlcs_constr.data = MALLOC(htlcs_constr.datalen * sizeof(LDKClaimedHTLC), "LDKCVec_ClaimedHTLCZ Elements");
66538         else
66539                 htlcs_constr.data = NULL;
66540         int64_t* htlcs_vals = htlcs->elems;
66541         for (size_t n = 0; n < htlcs_constr.datalen; n++) {
66542                 int64_t htlcs_conv_13 = htlcs_vals[n];
66543                 LDKClaimedHTLC htlcs_conv_13_conv;
66544                 htlcs_conv_13_conv.inner = untag_ptr(htlcs_conv_13);
66545                 htlcs_conv_13_conv.is_owned = ptr_is_owned(htlcs_conv_13);
66546                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlcs_conv_13_conv);
66547                 htlcs_conv_13_conv = ClaimedHTLC_clone(&htlcs_conv_13_conv);
66548                 htlcs_constr.data[n] = htlcs_conv_13_conv;
66549         }
66550         FREE(htlcs);
66551         void* sender_intended_total_msat_ptr = untag_ptr(sender_intended_total_msat);
66552         CHECK_ACCESS(sender_intended_total_msat_ptr);
66553         LDKCOption_u64Z sender_intended_total_msat_conv = *(LDKCOption_u64Z*)(sender_intended_total_msat_ptr);
66554         sender_intended_total_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(sender_intended_total_msat));
66555         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66556         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv, htlcs_constr, sender_intended_total_msat_conv);
66557         int64_t ret_ref = tag_ptr(ret_copy, true);
66558         return ret_ref;
66559 }
66560
66561 int64_t  CS_LDK_Event_invoice_request_failed(int8_tArray payment_id) {
66562         LDKThirtyTwoBytes payment_id_ref;
66563         CHECK(payment_id->arr_len == 32);
66564         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66565         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66566         *ret_copy = Event_invoice_request_failed(payment_id_ref);
66567         int64_t ret_ref = tag_ptr(ret_copy, true);
66568         return ret_ref;
66569 }
66570
66571 int64_t  CS_LDK_Event_payment_sent(int64_t payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, int64_t fee_paid_msat) {
66572         void* payment_id_ptr = untag_ptr(payment_id);
66573         CHECK_ACCESS(payment_id_ptr);
66574         LDKCOption_ThirtyTwoBytesZ payment_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_id_ptr);
66575         payment_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_id));
66576         LDKThirtyTwoBytes payment_preimage_ref;
66577         CHECK(payment_preimage->arr_len == 32);
66578         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
66579         LDKThirtyTwoBytes payment_hash_ref;
66580         CHECK(payment_hash->arr_len == 32);
66581         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66582         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
66583         CHECK_ACCESS(fee_paid_msat_ptr);
66584         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
66585         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
66586         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66587         *ret_copy = Event_payment_sent(payment_id_conv, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
66588         int64_t ret_ref = tag_ptr(ret_copy, true);
66589         return ret_ref;
66590 }
66591
66592 int64_t  CS_LDK_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash, int64_t reason) {
66593         LDKThirtyTwoBytes payment_id_ref;
66594         CHECK(payment_id->arr_len == 32);
66595         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66596         LDKThirtyTwoBytes payment_hash_ref;
66597         CHECK(payment_hash->arr_len == 32);
66598         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66599         void* reason_ptr = untag_ptr(reason);
66600         CHECK_ACCESS(reason_ptr);
66601         LDKCOption_PaymentFailureReasonZ reason_conv = *(LDKCOption_PaymentFailureReasonZ*)(reason_ptr);
66602         reason_conv = COption_PaymentFailureReasonZ_clone((LDKCOption_PaymentFailureReasonZ*)untag_ptr(reason));
66603         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66604         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref, reason_conv);
66605         int64_t ret_ref = tag_ptr(ret_copy, true);
66606         return ret_ref;
66607 }
66608
66609 int64_t  CS_LDK_Event_payment_path_successful(int8_tArray payment_id, int64_t payment_hash, int64_t path) {
66610         LDKThirtyTwoBytes payment_id_ref;
66611         CHECK(payment_id->arr_len == 32);
66612         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66613         void* payment_hash_ptr = untag_ptr(payment_hash);
66614         CHECK_ACCESS(payment_hash_ptr);
66615         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
66616         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
66617         LDKPath path_conv;
66618         path_conv.inner = untag_ptr(path);
66619         path_conv.is_owned = ptr_is_owned(path);
66620         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66621         path_conv = Path_clone(&path_conv);
66622         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66623         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_conv, path_conv);
66624         int64_t ret_ref = tag_ptr(ret_copy, true);
66625         return ret_ref;
66626 }
66627
66628 int64_t  CS_LDK_Event_payment_path_failed(int64_t payment_id, int8_tArray payment_hash, jboolean payment_failed_permanently, int64_t failure, int64_t path, int64_t short_channel_id) {
66629         void* payment_id_ptr = untag_ptr(payment_id);
66630         CHECK_ACCESS(payment_id_ptr);
66631         LDKCOption_ThirtyTwoBytesZ payment_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_id_ptr);
66632         payment_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_id));
66633         LDKThirtyTwoBytes payment_hash_ref;
66634         CHECK(payment_hash->arr_len == 32);
66635         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66636         void* failure_ptr = untag_ptr(failure);
66637         CHECK_ACCESS(failure_ptr);
66638         LDKPathFailure failure_conv = *(LDKPathFailure*)(failure_ptr);
66639         failure_conv = PathFailure_clone((LDKPathFailure*)untag_ptr(failure));
66640         LDKPath path_conv;
66641         path_conv.inner = untag_ptr(path);
66642         path_conv.is_owned = ptr_is_owned(path);
66643         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66644         path_conv = Path_clone(&path_conv);
66645         void* short_channel_id_ptr = untag_ptr(short_channel_id);
66646         CHECK_ACCESS(short_channel_id_ptr);
66647         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
66648         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
66649         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66650         *ret_copy = Event_payment_path_failed(payment_id_conv, payment_hash_ref, payment_failed_permanently, failure_conv, path_conv, short_channel_id_conv);
66651         int64_t ret_ref = tag_ptr(ret_copy, true);
66652         return ret_ref;
66653 }
66654
66655 int64_t  CS_LDK_Event_probe_successful(int8_tArray payment_id, int8_tArray payment_hash, int64_t path) {
66656         LDKThirtyTwoBytes payment_id_ref;
66657         CHECK(payment_id->arr_len == 32);
66658         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66659         LDKThirtyTwoBytes payment_hash_ref;
66660         CHECK(payment_hash->arr_len == 32);
66661         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66662         LDKPath path_conv;
66663         path_conv.inner = untag_ptr(path);
66664         path_conv.is_owned = ptr_is_owned(path);
66665         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66666         path_conv = Path_clone(&path_conv);
66667         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66668         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_conv);
66669         int64_t ret_ref = tag_ptr(ret_copy, true);
66670         return ret_ref;
66671 }
66672
66673 int64_t  CS_LDK_Event_probe_failed(int8_tArray payment_id, int8_tArray payment_hash, int64_t path, int64_t short_channel_id) {
66674         LDKThirtyTwoBytes payment_id_ref;
66675         CHECK(payment_id->arr_len == 32);
66676         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
66677         LDKThirtyTwoBytes payment_hash_ref;
66678         CHECK(payment_hash->arr_len == 32);
66679         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66680         LDKPath path_conv;
66681         path_conv.inner = untag_ptr(path);
66682         path_conv.is_owned = ptr_is_owned(path);
66683         CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv);
66684         path_conv = Path_clone(&path_conv);
66685         void* short_channel_id_ptr = untag_ptr(short_channel_id);
66686         CHECK_ACCESS(short_channel_id_ptr);
66687         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
66688         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
66689         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66690         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_conv, short_channel_id_conv);
66691         int64_t ret_ref = tag_ptr(ret_copy, true);
66692         return ret_ref;
66693 }
66694
66695 int64_t  CS_LDK_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
66696         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66697         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
66698         int64_t ret_ref = tag_ptr(ret_copy, true);
66699         return ret_ref;
66700 }
66701
66702 int64_t  CS_LDK_Event_htlcintercepted(int8_tArray intercept_id, int64_t requested_next_hop_scid, int8_tArray payment_hash, int64_t inbound_amount_msat, int64_t expected_outbound_amount_msat) {
66703         LDKThirtyTwoBytes intercept_id_ref;
66704         CHECK(intercept_id->arr_len == 32);
66705         memcpy(intercept_id_ref.data, intercept_id->elems, 32); FREE(intercept_id);
66706         LDKThirtyTwoBytes payment_hash_ref;
66707         CHECK(payment_hash->arr_len == 32);
66708         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
66709         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66710         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
66711         int64_t ret_ref = tag_ptr(ret_copy, true);
66712         return ret_ref;
66713 }
66714
66715 int64_t  CS_LDK_Event_spendable_outputs(int64_tArray outputs, int64_t channel_id) {
66716         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
66717         outputs_constr.datalen = outputs->arr_len;
66718         if (outputs_constr.datalen > 0)
66719                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
66720         else
66721                 outputs_constr.data = NULL;
66722         int64_t* outputs_vals = outputs->elems;
66723         for (size_t b = 0; b < outputs_constr.datalen; b++) {
66724                 int64_t outputs_conv_27 = outputs_vals[b];
66725                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
66726                 CHECK_ACCESS(outputs_conv_27_ptr);
66727                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
66728                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
66729                 outputs_constr.data[b] = outputs_conv_27_conv;
66730         }
66731         FREE(outputs);
66732         void* channel_id_ptr = untag_ptr(channel_id);
66733         CHECK_ACCESS(channel_id_ptr);
66734         LDKCOption_ThirtyTwoBytesZ channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(channel_id_ptr);
66735         channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(channel_id));
66736         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66737         *ret_copy = Event_spendable_outputs(outputs_constr, channel_id_conv);
66738         int64_t ret_ref = tag_ptr(ret_copy, true);
66739         return ret_ref;
66740 }
66741
66742 int64_t  CS_LDK_Event_payment_forwarded(int64_t prev_channel_id, int64_t next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx, int64_t outbound_amount_forwarded_msat) {
66743         void* prev_channel_id_ptr = untag_ptr(prev_channel_id);
66744         CHECK_ACCESS(prev_channel_id_ptr);
66745         LDKCOption_ThirtyTwoBytesZ prev_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(prev_channel_id_ptr);
66746         prev_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(prev_channel_id));
66747         void* next_channel_id_ptr = untag_ptr(next_channel_id);
66748         CHECK_ACCESS(next_channel_id_ptr);
66749         LDKCOption_ThirtyTwoBytesZ next_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(next_channel_id_ptr);
66750         next_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(next_channel_id));
66751         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
66752         CHECK_ACCESS(fee_earned_msat_ptr);
66753         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
66754         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
66755         void* outbound_amount_forwarded_msat_ptr = untag_ptr(outbound_amount_forwarded_msat);
66756         CHECK_ACCESS(outbound_amount_forwarded_msat_ptr);
66757         LDKCOption_u64Z outbound_amount_forwarded_msat_conv = *(LDKCOption_u64Z*)(outbound_amount_forwarded_msat_ptr);
66758         outbound_amount_forwarded_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_amount_forwarded_msat));
66759         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66760         *ret_copy = Event_payment_forwarded(prev_channel_id_conv, next_channel_id_conv, fee_earned_msat_conv, claim_from_onchain_tx, outbound_amount_forwarded_msat_conv);
66761         int64_t ret_ref = tag_ptr(ret_copy, true);
66762         return ret_ref;
66763 }
66764
66765 int64_t  CS_LDK_Event_channel_pending(int8_tArray channel_id, int8_tArray user_channel_id, int64_t former_temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_txo) {
66766         LDKThirtyTwoBytes channel_id_ref;
66767         CHECK(channel_id->arr_len == 32);
66768         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66769         LDKU128 user_channel_id_ref;
66770         CHECK(user_channel_id->arr_len == 16);
66771         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66772         void* former_temporary_channel_id_ptr = untag_ptr(former_temporary_channel_id);
66773         CHECK_ACCESS(former_temporary_channel_id_ptr);
66774         LDKCOption_ThirtyTwoBytesZ former_temporary_channel_id_conv = *(LDKCOption_ThirtyTwoBytesZ*)(former_temporary_channel_id_ptr);
66775         former_temporary_channel_id_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(former_temporary_channel_id));
66776         LDKPublicKey counterparty_node_id_ref;
66777         CHECK(counterparty_node_id->arr_len == 33);
66778         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66779         LDKOutPoint funding_txo_conv;
66780         funding_txo_conv.inner = untag_ptr(funding_txo);
66781         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
66782         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
66783         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
66784         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66785         *ret_copy = Event_channel_pending(channel_id_ref, user_channel_id_ref, former_temporary_channel_id_conv, counterparty_node_id_ref, funding_txo_conv);
66786         int64_t ret_ref = tag_ptr(ret_copy, true);
66787         return ret_ref;
66788 }
66789
66790 int64_t  CS_LDK_Event_channel_ready(int8_tArray channel_id, int8_tArray user_channel_id, int8_tArray counterparty_node_id, int64_t channel_type) {
66791         LDKThirtyTwoBytes channel_id_ref;
66792         CHECK(channel_id->arr_len == 32);
66793         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66794         LDKU128 user_channel_id_ref;
66795         CHECK(user_channel_id->arr_len == 16);
66796         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66797         LDKPublicKey counterparty_node_id_ref;
66798         CHECK(counterparty_node_id->arr_len == 33);
66799         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66800         LDKChannelTypeFeatures channel_type_conv;
66801         channel_type_conv.inner = untag_ptr(channel_type);
66802         channel_type_conv.is_owned = ptr_is_owned(channel_type);
66803         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
66804         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
66805         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66806         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
66807         int64_t ret_ref = tag_ptr(ret_copy, true);
66808         return ret_ref;
66809 }
66810
66811 int64_t  CS_LDK_Event_channel_closed(int8_tArray channel_id, int8_tArray user_channel_id, int64_t reason, int8_tArray counterparty_node_id, int64_t channel_capacity_sats) {
66812         LDKThirtyTwoBytes channel_id_ref;
66813         CHECK(channel_id->arr_len == 32);
66814         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66815         LDKU128 user_channel_id_ref;
66816         CHECK(user_channel_id->arr_len == 16);
66817         memcpy(user_channel_id_ref.le_bytes, user_channel_id->elems, 16); FREE(user_channel_id);
66818         void* reason_ptr = untag_ptr(reason);
66819         CHECK_ACCESS(reason_ptr);
66820         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
66821         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
66822         LDKPublicKey counterparty_node_id_ref;
66823         CHECK(counterparty_node_id->arr_len == 33);
66824         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66825         void* channel_capacity_sats_ptr = untag_ptr(channel_capacity_sats);
66826         CHECK_ACCESS(channel_capacity_sats_ptr);
66827         LDKCOption_u64Z channel_capacity_sats_conv = *(LDKCOption_u64Z*)(channel_capacity_sats_ptr);
66828         channel_capacity_sats_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(channel_capacity_sats));
66829         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66830         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv, counterparty_node_id_ref, channel_capacity_sats_conv);
66831         int64_t ret_ref = tag_ptr(ret_copy, true);
66832         return ret_ref;
66833 }
66834
66835 int64_t  CS_LDK_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
66836         LDKThirtyTwoBytes channel_id_ref;
66837         CHECK(channel_id->arr_len == 32);
66838         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
66839         LDKTransaction transaction_ref;
66840         transaction_ref.datalen = transaction->arr_len;
66841         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
66842         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
66843         transaction_ref.data_is_owned = true;
66844         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66845         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
66846         int64_t ret_ref = tag_ptr(ret_copy, true);
66847         return ret_ref;
66848 }
66849
66850 int64_t  CS_LDK_Event_open_channel_request(int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, int64_t channel_type) {
66851         LDKThirtyTwoBytes temporary_channel_id_ref;
66852         CHECK(temporary_channel_id->arr_len == 32);
66853         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
66854         LDKPublicKey counterparty_node_id_ref;
66855         CHECK(counterparty_node_id->arr_len == 33);
66856         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
66857         LDKChannelTypeFeatures channel_type_conv;
66858         channel_type_conv.inner = untag_ptr(channel_type);
66859         channel_type_conv.is_owned = ptr_is_owned(channel_type);
66860         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
66861         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
66862         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66863         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
66864         int64_t ret_ref = tag_ptr(ret_copy, true);
66865         return ret_ref;
66866 }
66867
66868 int64_t  CS_LDK_Event_htlchandling_failed(int8_tArray prev_channel_id, int64_t failed_next_destination) {
66869         LDKThirtyTwoBytes prev_channel_id_ref;
66870         CHECK(prev_channel_id->arr_len == 32);
66871         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
66872         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
66873         CHECK_ACCESS(failed_next_destination_ptr);
66874         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
66875         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
66876         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66877         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
66878         int64_t ret_ref = tag_ptr(ret_copy, true);
66879         return ret_ref;
66880 }
66881
66882 int64_t  CS_LDK_Event_bump_transaction(int64_t a) {
66883         void* a_ptr = untag_ptr(a);
66884         CHECK_ACCESS(a_ptr);
66885         LDKBumpTransactionEvent a_conv = *(LDKBumpTransactionEvent*)(a_ptr);
66886         a_conv = BumpTransactionEvent_clone((LDKBumpTransactionEvent*)untag_ptr(a));
66887         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
66888         *ret_copy = Event_bump_transaction(a_conv);
66889         int64_t ret_ref = tag_ptr(ret_copy, true);
66890         return ret_ref;
66891 }
66892
66893 jboolean  CS_LDK_Event_eq(int64_t a, int64_t b) {
66894         LDKEvent* a_conv = (LDKEvent*)untag_ptr(a);
66895         LDKEvent* b_conv = (LDKEvent*)untag_ptr(b);
66896         jboolean ret_conv = Event_eq(a_conv, b_conv);
66897         return ret_conv;
66898 }
66899
66900 int8_tArray  CS_LDK_Event_write(int64_t obj) {
66901         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
66902         LDKCVec_u8Z ret_var = Event_write(obj_conv);
66903         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
66904         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
66905         CVec_u8Z_free(ret_var);
66906         return ret_arr;
66907 }
66908
66909 int64_t  CS_LDK_Event_read(int8_tArray ser) {
66910         LDKu8slice ser_ref;
66911         ser_ref.datalen = ser->arr_len;
66912         ser_ref.data = ser->elems;
66913         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
66914         *ret_conv = Event_read(ser_ref);
66915         FREE(ser);
66916         return tag_ptr(ret_conv, true);
66917 }
66918
66919 void  CS_LDK_MessageSendEvent_free(int64_t this_ptr) {
66920         if (!ptr_is_owned(this_ptr)) return;
66921         void* this_ptr_ptr = untag_ptr(this_ptr);
66922         CHECK_ACCESS(this_ptr_ptr);
66923         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
66924         FREE(untag_ptr(this_ptr));
66925         MessageSendEvent_free(this_ptr_conv);
66926 }
66927
66928 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
66929         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66930         *ret_copy = MessageSendEvent_clone(arg);
66931         int64_t ret_ref = tag_ptr(ret_copy, true);
66932         return ret_ref;
66933 }
66934 int64_t  CS_LDK_MessageSendEvent_clone_ptr(int64_t arg) {
66935         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
66936         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
66937         return ret_conv;
66938 }
66939
66940 int64_t  CS_LDK_MessageSendEvent_clone(int64_t orig) {
66941         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
66942         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66943         *ret_copy = MessageSendEvent_clone(orig_conv);
66944         int64_t ret_ref = tag_ptr(ret_copy, true);
66945         return ret_ref;
66946 }
66947
66948 int64_t  CS_LDK_MessageSendEvent_send_accept_channel(int8_tArray node_id, int64_t msg) {
66949         LDKPublicKey node_id_ref;
66950         CHECK(node_id->arr_len == 33);
66951         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66952         LDKAcceptChannel msg_conv;
66953         msg_conv.inner = untag_ptr(msg);
66954         msg_conv.is_owned = ptr_is_owned(msg);
66955         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
66956         msg_conv = AcceptChannel_clone(&msg_conv);
66957         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66958         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
66959         int64_t ret_ref = tag_ptr(ret_copy, true);
66960         return ret_ref;
66961 }
66962
66963 int64_t  CS_LDK_MessageSendEvent_send_accept_channel_v2(int8_tArray node_id, int64_t msg) {
66964         LDKPublicKey node_id_ref;
66965         CHECK(node_id->arr_len == 33);
66966         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66967         LDKAcceptChannelV2 msg_conv;
66968         msg_conv.inner = untag_ptr(msg);
66969         msg_conv.is_owned = ptr_is_owned(msg);
66970         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
66971         msg_conv = AcceptChannelV2_clone(&msg_conv);
66972         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66973         *ret_copy = MessageSendEvent_send_accept_channel_v2(node_id_ref, msg_conv);
66974         int64_t ret_ref = tag_ptr(ret_copy, true);
66975         return ret_ref;
66976 }
66977
66978 int64_t  CS_LDK_MessageSendEvent_send_open_channel(int8_tArray node_id, int64_t msg) {
66979         LDKPublicKey node_id_ref;
66980         CHECK(node_id->arr_len == 33);
66981         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66982         LDKOpenChannel msg_conv;
66983         msg_conv.inner = untag_ptr(msg);
66984         msg_conv.is_owned = ptr_is_owned(msg);
66985         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
66986         msg_conv = OpenChannel_clone(&msg_conv);
66987         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
66988         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
66989         int64_t ret_ref = tag_ptr(ret_copy, true);
66990         return ret_ref;
66991 }
66992
66993 int64_t  CS_LDK_MessageSendEvent_send_open_channel_v2(int8_tArray node_id, int64_t msg) {
66994         LDKPublicKey node_id_ref;
66995         CHECK(node_id->arr_len == 33);
66996         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
66997         LDKOpenChannelV2 msg_conv;
66998         msg_conv.inner = untag_ptr(msg);
66999         msg_conv.is_owned = ptr_is_owned(msg);
67000         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67001         msg_conv = OpenChannelV2_clone(&msg_conv);
67002         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67003         *ret_copy = MessageSendEvent_send_open_channel_v2(node_id_ref, msg_conv);
67004         int64_t ret_ref = tag_ptr(ret_copy, true);
67005         return ret_ref;
67006 }
67007
67008 int64_t  CS_LDK_MessageSendEvent_send_funding_created(int8_tArray node_id, int64_t msg) {
67009         LDKPublicKey node_id_ref;
67010         CHECK(node_id->arr_len == 33);
67011         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67012         LDKFundingCreated msg_conv;
67013         msg_conv.inner = untag_ptr(msg);
67014         msg_conv.is_owned = ptr_is_owned(msg);
67015         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67016         msg_conv = FundingCreated_clone(&msg_conv);
67017         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67018         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
67019         int64_t ret_ref = tag_ptr(ret_copy, true);
67020         return ret_ref;
67021 }
67022
67023 int64_t  CS_LDK_MessageSendEvent_send_funding_signed(int8_tArray node_id, int64_t msg) {
67024         LDKPublicKey node_id_ref;
67025         CHECK(node_id->arr_len == 33);
67026         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67027         LDKFundingSigned msg_conv;
67028         msg_conv.inner = untag_ptr(msg);
67029         msg_conv.is_owned = ptr_is_owned(msg);
67030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67031         msg_conv = FundingSigned_clone(&msg_conv);
67032         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67033         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
67034         int64_t ret_ref = tag_ptr(ret_copy, true);
67035         return ret_ref;
67036 }
67037
67038 int64_t  CS_LDK_MessageSendEvent_send_tx_add_input(int8_tArray node_id, int64_t msg) {
67039         LDKPublicKey node_id_ref;
67040         CHECK(node_id->arr_len == 33);
67041         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67042         LDKTxAddInput msg_conv;
67043         msg_conv.inner = untag_ptr(msg);
67044         msg_conv.is_owned = ptr_is_owned(msg);
67045         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67046         msg_conv = TxAddInput_clone(&msg_conv);
67047         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67048         *ret_copy = MessageSendEvent_send_tx_add_input(node_id_ref, msg_conv);
67049         int64_t ret_ref = tag_ptr(ret_copy, true);
67050         return ret_ref;
67051 }
67052
67053 int64_t  CS_LDK_MessageSendEvent_send_tx_add_output(int8_tArray node_id, int64_t msg) {
67054         LDKPublicKey node_id_ref;
67055         CHECK(node_id->arr_len == 33);
67056         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67057         LDKTxAddOutput msg_conv;
67058         msg_conv.inner = untag_ptr(msg);
67059         msg_conv.is_owned = ptr_is_owned(msg);
67060         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67061         msg_conv = TxAddOutput_clone(&msg_conv);
67062         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67063         *ret_copy = MessageSendEvent_send_tx_add_output(node_id_ref, msg_conv);
67064         int64_t ret_ref = tag_ptr(ret_copy, true);
67065         return ret_ref;
67066 }
67067
67068 int64_t  CS_LDK_MessageSendEvent_send_tx_remove_input(int8_tArray node_id, int64_t msg) {
67069         LDKPublicKey node_id_ref;
67070         CHECK(node_id->arr_len == 33);
67071         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67072         LDKTxRemoveInput msg_conv;
67073         msg_conv.inner = untag_ptr(msg);
67074         msg_conv.is_owned = ptr_is_owned(msg);
67075         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67076         msg_conv = TxRemoveInput_clone(&msg_conv);
67077         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67078         *ret_copy = MessageSendEvent_send_tx_remove_input(node_id_ref, msg_conv);
67079         int64_t ret_ref = tag_ptr(ret_copy, true);
67080         return ret_ref;
67081 }
67082
67083 int64_t  CS_LDK_MessageSendEvent_send_tx_remove_output(int8_tArray node_id, int64_t msg) {
67084         LDKPublicKey node_id_ref;
67085         CHECK(node_id->arr_len == 33);
67086         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67087         LDKTxRemoveOutput msg_conv;
67088         msg_conv.inner = untag_ptr(msg);
67089         msg_conv.is_owned = ptr_is_owned(msg);
67090         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67091         msg_conv = TxRemoveOutput_clone(&msg_conv);
67092         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67093         *ret_copy = MessageSendEvent_send_tx_remove_output(node_id_ref, msg_conv);
67094         int64_t ret_ref = tag_ptr(ret_copy, true);
67095         return ret_ref;
67096 }
67097
67098 int64_t  CS_LDK_MessageSendEvent_send_tx_complete(int8_tArray node_id, int64_t msg) {
67099         LDKPublicKey node_id_ref;
67100         CHECK(node_id->arr_len == 33);
67101         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67102         LDKTxComplete msg_conv;
67103         msg_conv.inner = untag_ptr(msg);
67104         msg_conv.is_owned = ptr_is_owned(msg);
67105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67106         msg_conv = TxComplete_clone(&msg_conv);
67107         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67108         *ret_copy = MessageSendEvent_send_tx_complete(node_id_ref, msg_conv);
67109         int64_t ret_ref = tag_ptr(ret_copy, true);
67110         return ret_ref;
67111 }
67112
67113 int64_t  CS_LDK_MessageSendEvent_send_tx_signatures(int8_tArray node_id, int64_t msg) {
67114         LDKPublicKey node_id_ref;
67115         CHECK(node_id->arr_len == 33);
67116         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67117         LDKTxSignatures msg_conv;
67118         msg_conv.inner = untag_ptr(msg);
67119         msg_conv.is_owned = ptr_is_owned(msg);
67120         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67121         msg_conv = TxSignatures_clone(&msg_conv);
67122         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67123         *ret_copy = MessageSendEvent_send_tx_signatures(node_id_ref, msg_conv);
67124         int64_t ret_ref = tag_ptr(ret_copy, true);
67125         return ret_ref;
67126 }
67127
67128 int64_t  CS_LDK_MessageSendEvent_send_tx_init_rbf(int8_tArray node_id, int64_t msg) {
67129         LDKPublicKey node_id_ref;
67130         CHECK(node_id->arr_len == 33);
67131         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67132         LDKTxInitRbf msg_conv;
67133         msg_conv.inner = untag_ptr(msg);
67134         msg_conv.is_owned = ptr_is_owned(msg);
67135         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67136         msg_conv = TxInitRbf_clone(&msg_conv);
67137         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67138         *ret_copy = MessageSendEvent_send_tx_init_rbf(node_id_ref, msg_conv);
67139         int64_t ret_ref = tag_ptr(ret_copy, true);
67140         return ret_ref;
67141 }
67142
67143 int64_t  CS_LDK_MessageSendEvent_send_tx_ack_rbf(int8_tArray node_id, int64_t msg) {
67144         LDKPublicKey node_id_ref;
67145         CHECK(node_id->arr_len == 33);
67146         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67147         LDKTxAckRbf msg_conv;
67148         msg_conv.inner = untag_ptr(msg);
67149         msg_conv.is_owned = ptr_is_owned(msg);
67150         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67151         msg_conv = TxAckRbf_clone(&msg_conv);
67152         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67153         *ret_copy = MessageSendEvent_send_tx_ack_rbf(node_id_ref, msg_conv);
67154         int64_t ret_ref = tag_ptr(ret_copy, true);
67155         return ret_ref;
67156 }
67157
67158 int64_t  CS_LDK_MessageSendEvent_send_tx_abort(int8_tArray node_id, int64_t msg) {
67159         LDKPublicKey node_id_ref;
67160         CHECK(node_id->arr_len == 33);
67161         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67162         LDKTxAbort msg_conv;
67163         msg_conv.inner = untag_ptr(msg);
67164         msg_conv.is_owned = ptr_is_owned(msg);
67165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67166         msg_conv = TxAbort_clone(&msg_conv);
67167         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67168         *ret_copy = MessageSendEvent_send_tx_abort(node_id_ref, msg_conv);
67169         int64_t ret_ref = tag_ptr(ret_copy, true);
67170         return ret_ref;
67171 }
67172
67173 int64_t  CS_LDK_MessageSendEvent_send_channel_ready(int8_tArray node_id, int64_t msg) {
67174         LDKPublicKey node_id_ref;
67175         CHECK(node_id->arr_len == 33);
67176         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67177         LDKChannelReady msg_conv;
67178         msg_conv.inner = untag_ptr(msg);
67179         msg_conv.is_owned = ptr_is_owned(msg);
67180         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67181         msg_conv = ChannelReady_clone(&msg_conv);
67182         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67183         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
67184         int64_t ret_ref = tag_ptr(ret_copy, true);
67185         return ret_ref;
67186 }
67187
67188 int64_t  CS_LDK_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, int64_t msg) {
67189         LDKPublicKey node_id_ref;
67190         CHECK(node_id->arr_len == 33);
67191         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67192         LDKAnnouncementSignatures msg_conv;
67193         msg_conv.inner = untag_ptr(msg);
67194         msg_conv.is_owned = ptr_is_owned(msg);
67195         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67196         msg_conv = AnnouncementSignatures_clone(&msg_conv);
67197         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67198         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
67199         int64_t ret_ref = tag_ptr(ret_copy, true);
67200         return ret_ref;
67201 }
67202
67203 int64_t  CS_LDK_MessageSendEvent_update_htlcs(int8_tArray node_id, int64_t updates) {
67204         LDKPublicKey node_id_ref;
67205         CHECK(node_id->arr_len == 33);
67206         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67207         LDKCommitmentUpdate updates_conv;
67208         updates_conv.inner = untag_ptr(updates);
67209         updates_conv.is_owned = ptr_is_owned(updates);
67210         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
67211         updates_conv = CommitmentUpdate_clone(&updates_conv);
67212         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67213         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
67214         int64_t ret_ref = tag_ptr(ret_copy, true);
67215         return ret_ref;
67216 }
67217
67218 int64_t  CS_LDK_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, int64_t msg) {
67219         LDKPublicKey node_id_ref;
67220         CHECK(node_id->arr_len == 33);
67221         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67222         LDKRevokeAndACK msg_conv;
67223         msg_conv.inner = untag_ptr(msg);
67224         msg_conv.is_owned = ptr_is_owned(msg);
67225         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67226         msg_conv = RevokeAndACK_clone(&msg_conv);
67227         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67228         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
67229         int64_t ret_ref = tag_ptr(ret_copy, true);
67230         return ret_ref;
67231 }
67232
67233 int64_t  CS_LDK_MessageSendEvent_send_closing_signed(int8_tArray node_id, int64_t msg) {
67234         LDKPublicKey node_id_ref;
67235         CHECK(node_id->arr_len == 33);
67236         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67237         LDKClosingSigned msg_conv;
67238         msg_conv.inner = untag_ptr(msg);
67239         msg_conv.is_owned = ptr_is_owned(msg);
67240         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67241         msg_conv = ClosingSigned_clone(&msg_conv);
67242         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67243         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
67244         int64_t ret_ref = tag_ptr(ret_copy, true);
67245         return ret_ref;
67246 }
67247
67248 int64_t  CS_LDK_MessageSendEvent_send_shutdown(int8_tArray node_id, int64_t msg) {
67249         LDKPublicKey node_id_ref;
67250         CHECK(node_id->arr_len == 33);
67251         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67252         LDKShutdown msg_conv;
67253         msg_conv.inner = untag_ptr(msg);
67254         msg_conv.is_owned = ptr_is_owned(msg);
67255         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67256         msg_conv = Shutdown_clone(&msg_conv);
67257         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67258         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
67259         int64_t ret_ref = tag_ptr(ret_copy, true);
67260         return ret_ref;
67261 }
67262
67263 int64_t  CS_LDK_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, int64_t msg) {
67264         LDKPublicKey node_id_ref;
67265         CHECK(node_id->arr_len == 33);
67266         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67267         LDKChannelReestablish msg_conv;
67268         msg_conv.inner = untag_ptr(msg);
67269         msg_conv.is_owned = ptr_is_owned(msg);
67270         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67271         msg_conv = ChannelReestablish_clone(&msg_conv);
67272         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67273         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
67274         int64_t ret_ref = tag_ptr(ret_copy, true);
67275         return ret_ref;
67276 }
67277
67278 int64_t  CS_LDK_MessageSendEvent_send_channel_announcement(int8_tArray node_id, int64_t msg, int64_t update_msg) {
67279         LDKPublicKey node_id_ref;
67280         CHECK(node_id->arr_len == 33);
67281         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67282         LDKChannelAnnouncement msg_conv;
67283         msg_conv.inner = untag_ptr(msg);
67284         msg_conv.is_owned = ptr_is_owned(msg);
67285         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67286         msg_conv = ChannelAnnouncement_clone(&msg_conv);
67287         LDKChannelUpdate update_msg_conv;
67288         update_msg_conv.inner = untag_ptr(update_msg);
67289         update_msg_conv.is_owned = ptr_is_owned(update_msg);
67290         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
67291         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
67292         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67293         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
67294         int64_t ret_ref = tag_ptr(ret_copy, true);
67295         return ret_ref;
67296 }
67297
67298 int64_t  CS_LDK_MessageSendEvent_broadcast_channel_announcement(int64_t msg, int64_t update_msg) {
67299         LDKChannelAnnouncement msg_conv;
67300         msg_conv.inner = untag_ptr(msg);
67301         msg_conv.is_owned = ptr_is_owned(msg);
67302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67303         msg_conv = ChannelAnnouncement_clone(&msg_conv);
67304         LDKChannelUpdate update_msg_conv;
67305         update_msg_conv.inner = untag_ptr(update_msg);
67306         update_msg_conv.is_owned = ptr_is_owned(update_msg);
67307         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
67308         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
67309         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67310         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
67311         int64_t ret_ref = tag_ptr(ret_copy, true);
67312         return ret_ref;
67313 }
67314
67315 int64_t  CS_LDK_MessageSendEvent_broadcast_channel_update(int64_t msg) {
67316         LDKChannelUpdate msg_conv;
67317         msg_conv.inner = untag_ptr(msg);
67318         msg_conv.is_owned = ptr_is_owned(msg);
67319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67320         msg_conv = ChannelUpdate_clone(&msg_conv);
67321         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67322         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
67323         int64_t ret_ref = tag_ptr(ret_copy, true);
67324         return ret_ref;
67325 }
67326
67327 int64_t  CS_LDK_MessageSendEvent_broadcast_node_announcement(int64_t msg) {
67328         LDKNodeAnnouncement msg_conv;
67329         msg_conv.inner = untag_ptr(msg);
67330         msg_conv.is_owned = ptr_is_owned(msg);
67331         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67332         msg_conv = NodeAnnouncement_clone(&msg_conv);
67333         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67334         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
67335         int64_t ret_ref = tag_ptr(ret_copy, true);
67336         return ret_ref;
67337 }
67338
67339 int64_t  CS_LDK_MessageSendEvent_send_channel_update(int8_tArray node_id, int64_t msg) {
67340         LDKPublicKey node_id_ref;
67341         CHECK(node_id->arr_len == 33);
67342         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67343         LDKChannelUpdate msg_conv;
67344         msg_conv.inner = untag_ptr(msg);
67345         msg_conv.is_owned = ptr_is_owned(msg);
67346         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67347         msg_conv = ChannelUpdate_clone(&msg_conv);
67348         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67349         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
67350         int64_t ret_ref = tag_ptr(ret_copy, true);
67351         return ret_ref;
67352 }
67353
67354 int64_t  CS_LDK_MessageSendEvent_handle_error(int8_tArray node_id, int64_t action) {
67355         LDKPublicKey node_id_ref;
67356         CHECK(node_id->arr_len == 33);
67357         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67358         void* action_ptr = untag_ptr(action);
67359         CHECK_ACCESS(action_ptr);
67360         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
67361         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
67362         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67363         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
67364         int64_t ret_ref = tag_ptr(ret_copy, true);
67365         return ret_ref;
67366 }
67367
67368 int64_t  CS_LDK_MessageSendEvent_send_channel_range_query(int8_tArray node_id, int64_t msg) {
67369         LDKPublicKey node_id_ref;
67370         CHECK(node_id->arr_len == 33);
67371         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67372         LDKQueryChannelRange msg_conv;
67373         msg_conv.inner = untag_ptr(msg);
67374         msg_conv.is_owned = ptr_is_owned(msg);
67375         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67376         msg_conv = QueryChannelRange_clone(&msg_conv);
67377         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67378         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
67379         int64_t ret_ref = tag_ptr(ret_copy, true);
67380         return ret_ref;
67381 }
67382
67383 int64_t  CS_LDK_MessageSendEvent_send_short_ids_query(int8_tArray node_id, int64_t msg) {
67384         LDKPublicKey node_id_ref;
67385         CHECK(node_id->arr_len == 33);
67386         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67387         LDKQueryShortChannelIds msg_conv;
67388         msg_conv.inner = untag_ptr(msg);
67389         msg_conv.is_owned = ptr_is_owned(msg);
67390         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67391         msg_conv = QueryShortChannelIds_clone(&msg_conv);
67392         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67393         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
67394         int64_t ret_ref = tag_ptr(ret_copy, true);
67395         return ret_ref;
67396 }
67397
67398 int64_t  CS_LDK_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, int64_t msg) {
67399         LDKPublicKey node_id_ref;
67400         CHECK(node_id->arr_len == 33);
67401         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67402         LDKReplyChannelRange msg_conv;
67403         msg_conv.inner = untag_ptr(msg);
67404         msg_conv.is_owned = ptr_is_owned(msg);
67405         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67406         msg_conv = ReplyChannelRange_clone(&msg_conv);
67407         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67408         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
67409         int64_t ret_ref = tag_ptr(ret_copy, true);
67410         return ret_ref;
67411 }
67412
67413 int64_t  CS_LDK_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, int64_t msg) {
67414         LDKPublicKey node_id_ref;
67415         CHECK(node_id->arr_len == 33);
67416         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
67417         LDKGossipTimestampFilter msg_conv;
67418         msg_conv.inner = untag_ptr(msg);
67419         msg_conv.is_owned = ptr_is_owned(msg);
67420         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
67421         msg_conv = GossipTimestampFilter_clone(&msg_conv);
67422         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
67423         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
67424         int64_t ret_ref = tag_ptr(ret_copy, true);
67425         return ret_ref;
67426 }
67427
67428 void  CS_LDK_MessageSendEventsProvider_free(int64_t this_ptr) {
67429         if (!ptr_is_owned(this_ptr)) return;
67430         void* this_ptr_ptr = untag_ptr(this_ptr);
67431         CHECK_ACCESS(this_ptr_ptr);
67432         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
67433         FREE(untag_ptr(this_ptr));
67434         MessageSendEventsProvider_free(this_ptr_conv);
67435 }
67436
67437 void  CS_LDK_EventsProvider_free(int64_t this_ptr) {
67438         if (!ptr_is_owned(this_ptr)) return;
67439         void* this_ptr_ptr = untag_ptr(this_ptr);
67440         CHECK_ACCESS(this_ptr_ptr);
67441         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
67442         FREE(untag_ptr(this_ptr));
67443         EventsProvider_free(this_ptr_conv);
67444 }
67445
67446 void  CS_LDK_EventHandler_free(int64_t this_ptr) {
67447         if (!ptr_is_owned(this_ptr)) return;
67448         void* this_ptr_ptr = untag_ptr(this_ptr);
67449         CHECK_ACCESS(this_ptr_ptr);
67450         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
67451         FREE(untag_ptr(this_ptr));
67452         EventHandler_free(this_ptr_conv);
67453 }
67454
67455 void  CS_LDK_AnchorDescriptor_free(int64_t this_obj) {
67456         LDKAnchorDescriptor this_obj_conv;
67457         this_obj_conv.inner = untag_ptr(this_obj);
67458         this_obj_conv.is_owned = ptr_is_owned(this_obj);
67459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
67460         AnchorDescriptor_free(this_obj_conv);
67461 }
67462
67463 int64_t  CS_LDK_AnchorDescriptor_get_channel_derivation_parameters(int64_t this_ptr) {
67464         LDKAnchorDescriptor this_ptr_conv;
67465         this_ptr_conv.inner = untag_ptr(this_ptr);
67466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67468         this_ptr_conv.is_owned = false;
67469         LDKChannelDerivationParameters ret_var = AnchorDescriptor_get_channel_derivation_parameters(&this_ptr_conv);
67470         int64_t ret_ref = 0;
67471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67473         return ret_ref;
67474 }
67475
67476 void  CS_LDK_AnchorDescriptor_set_channel_derivation_parameters(int64_t this_ptr, int64_t val) {
67477         LDKAnchorDescriptor this_ptr_conv;
67478         this_ptr_conv.inner = untag_ptr(this_ptr);
67479         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67481         this_ptr_conv.is_owned = false;
67482         LDKChannelDerivationParameters val_conv;
67483         val_conv.inner = untag_ptr(val);
67484         val_conv.is_owned = ptr_is_owned(val);
67485         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67486         val_conv = ChannelDerivationParameters_clone(&val_conv);
67487         AnchorDescriptor_set_channel_derivation_parameters(&this_ptr_conv, val_conv);
67488 }
67489
67490 int64_t  CS_LDK_AnchorDescriptor_get_outpoint(int64_t this_ptr) {
67491         LDKAnchorDescriptor this_ptr_conv;
67492         this_ptr_conv.inner = untag_ptr(this_ptr);
67493         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67495         this_ptr_conv.is_owned = false;
67496         LDKOutPoint ret_var = AnchorDescriptor_get_outpoint(&this_ptr_conv);
67497         int64_t ret_ref = 0;
67498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67500         return ret_ref;
67501 }
67502
67503 void  CS_LDK_AnchorDescriptor_set_outpoint(int64_t this_ptr, int64_t val) {
67504         LDKAnchorDescriptor this_ptr_conv;
67505         this_ptr_conv.inner = untag_ptr(this_ptr);
67506         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67508         this_ptr_conv.is_owned = false;
67509         LDKOutPoint val_conv;
67510         val_conv.inner = untag_ptr(val);
67511         val_conv.is_owned = ptr_is_owned(val);
67512         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67513         val_conv = OutPoint_clone(&val_conv);
67514         AnchorDescriptor_set_outpoint(&this_ptr_conv, val_conv);
67515 }
67516
67517 int64_t  CS_LDK_AnchorDescriptor_new(int64_t channel_derivation_parameters_arg, int64_t outpoint_arg) {
67518         LDKChannelDerivationParameters channel_derivation_parameters_arg_conv;
67519         channel_derivation_parameters_arg_conv.inner = untag_ptr(channel_derivation_parameters_arg);
67520         channel_derivation_parameters_arg_conv.is_owned = ptr_is_owned(channel_derivation_parameters_arg);
67521         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_derivation_parameters_arg_conv);
67522         channel_derivation_parameters_arg_conv = ChannelDerivationParameters_clone(&channel_derivation_parameters_arg_conv);
67523         LDKOutPoint outpoint_arg_conv;
67524         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
67525         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
67526         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
67527         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
67528         LDKAnchorDescriptor ret_var = AnchorDescriptor_new(channel_derivation_parameters_arg_conv, outpoint_arg_conv);
67529         int64_t ret_ref = 0;
67530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67532         return ret_ref;
67533 }
67534
67535 static inline uint64_t AnchorDescriptor_clone_ptr(LDKAnchorDescriptor *NONNULL_PTR arg) {
67536         LDKAnchorDescriptor ret_var = AnchorDescriptor_clone(arg);
67537         int64_t ret_ref = 0;
67538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67539         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67540         return ret_ref;
67541 }
67542 int64_t  CS_LDK_AnchorDescriptor_clone_ptr(int64_t arg) {
67543         LDKAnchorDescriptor arg_conv;
67544         arg_conv.inner = untag_ptr(arg);
67545         arg_conv.is_owned = ptr_is_owned(arg);
67546         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
67547         arg_conv.is_owned = false;
67548         int64_t ret_conv = AnchorDescriptor_clone_ptr(&arg_conv);
67549         return ret_conv;
67550 }
67551
67552 int64_t  CS_LDK_AnchorDescriptor_clone(int64_t orig) {
67553         LDKAnchorDescriptor orig_conv;
67554         orig_conv.inner = untag_ptr(orig);
67555         orig_conv.is_owned = ptr_is_owned(orig);
67556         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
67557         orig_conv.is_owned = false;
67558         LDKAnchorDescriptor ret_var = AnchorDescriptor_clone(&orig_conv);
67559         int64_t ret_ref = 0;
67560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67562         return ret_ref;
67563 }
67564
67565 jboolean  CS_LDK_AnchorDescriptor_eq(int64_t a, int64_t b) {
67566         LDKAnchorDescriptor a_conv;
67567         a_conv.inner = untag_ptr(a);
67568         a_conv.is_owned = ptr_is_owned(a);
67569         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
67570         a_conv.is_owned = false;
67571         LDKAnchorDescriptor b_conv;
67572         b_conv.inner = untag_ptr(b);
67573         b_conv.is_owned = ptr_is_owned(b);
67574         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
67575         b_conv.is_owned = false;
67576         jboolean ret_conv = AnchorDescriptor_eq(&a_conv, &b_conv);
67577         return ret_conv;
67578 }
67579
67580 int64_t  CS_LDK_AnchorDescriptor_previous_utxo(int64_t this_arg) {
67581         LDKAnchorDescriptor this_arg_conv;
67582         this_arg_conv.inner = untag_ptr(this_arg);
67583         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67585         this_arg_conv.is_owned = false;
67586         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
67587         *ret_ref = AnchorDescriptor_previous_utxo(&this_arg_conv);
67588         return tag_ptr(ret_ref, true);
67589 }
67590
67591 int64_t  CS_LDK_AnchorDescriptor_unsigned_tx_input(int64_t this_arg) {
67592         LDKAnchorDescriptor this_arg_conv;
67593         this_arg_conv.inner = untag_ptr(this_arg);
67594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67596         this_arg_conv.is_owned = false;
67597         LDKTxIn* ret_ref = MALLOC(sizeof(LDKTxIn), "LDKTxIn");
67598         *ret_ref = AnchorDescriptor_unsigned_tx_input(&this_arg_conv);
67599         return tag_ptr(ret_ref, true);
67600 }
67601
67602 int8_tArray  CS_LDK_AnchorDescriptor_witness_script(int64_t this_arg) {
67603         LDKAnchorDescriptor this_arg_conv;
67604         this_arg_conv.inner = untag_ptr(this_arg);
67605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67607         this_arg_conv.is_owned = false;
67608         LDKCVec_u8Z ret_var = AnchorDescriptor_witness_script(&this_arg_conv);
67609         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
67610         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
67611         CVec_u8Z_free(ret_var);
67612         return ret_arr;
67613 }
67614
67615 int8_tArray  CS_LDK_AnchorDescriptor_tx_input_witness(int64_t this_arg, int8_tArray signature) {
67616         LDKAnchorDescriptor this_arg_conv;
67617         this_arg_conv.inner = untag_ptr(this_arg);
67618         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67620         this_arg_conv.is_owned = false;
67621         LDKECDSASignature signature_ref;
67622         CHECK(signature->arr_len == 64);
67623         memcpy(signature_ref.compact_form, signature->elems, 64); FREE(signature);
67624         LDKWitness ret_var = AnchorDescriptor_tx_input_witness(&this_arg_conv, signature_ref);
67625         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
67626         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
67627         Witness_free(ret_var);
67628         return ret_arr;
67629 }
67630
67631 int64_t  CS_LDK_AnchorDescriptor_derive_channel_signer(int64_t this_arg, int64_t signer_provider) {
67632         LDKAnchorDescriptor this_arg_conv;
67633         this_arg_conv.inner = untag_ptr(this_arg);
67634         this_arg_conv.is_owned = ptr_is_owned(this_arg);
67635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
67636         this_arg_conv.is_owned = false;
67637         void* signer_provider_ptr = untag_ptr(signer_provider);
67638         if (ptr_is_owned(signer_provider)) { CHECK_ACCESS(signer_provider_ptr); }
67639         LDKSignerProvider* signer_provider_conv = (LDKSignerProvider*)signer_provider_ptr;
67640         LDKWriteableEcdsaChannelSigner* ret_ret = MALLOC(sizeof(LDKWriteableEcdsaChannelSigner), "LDKWriteableEcdsaChannelSigner");
67641         *ret_ret = AnchorDescriptor_derive_channel_signer(&this_arg_conv, signer_provider_conv);
67642         return tag_ptr(ret_ret, true);
67643 }
67644
67645 void  CS_LDK_BumpTransactionEvent_free(int64_t this_ptr) {
67646         if (!ptr_is_owned(this_ptr)) return;
67647         void* this_ptr_ptr = untag_ptr(this_ptr);
67648         CHECK_ACCESS(this_ptr_ptr);
67649         LDKBumpTransactionEvent this_ptr_conv = *(LDKBumpTransactionEvent*)(this_ptr_ptr);
67650         FREE(untag_ptr(this_ptr));
67651         BumpTransactionEvent_free(this_ptr_conv);
67652 }
67653
67654 static inline uint64_t BumpTransactionEvent_clone_ptr(LDKBumpTransactionEvent *NONNULL_PTR arg) {
67655         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67656         *ret_copy = BumpTransactionEvent_clone(arg);
67657         int64_t ret_ref = tag_ptr(ret_copy, true);
67658         return ret_ref;
67659 }
67660 int64_t  CS_LDK_BumpTransactionEvent_clone_ptr(int64_t arg) {
67661         LDKBumpTransactionEvent* arg_conv = (LDKBumpTransactionEvent*)untag_ptr(arg);
67662         int64_t ret_conv = BumpTransactionEvent_clone_ptr(arg_conv);
67663         return ret_conv;
67664 }
67665
67666 int64_t  CS_LDK_BumpTransactionEvent_clone(int64_t orig) {
67667         LDKBumpTransactionEvent* orig_conv = (LDKBumpTransactionEvent*)untag_ptr(orig);
67668         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67669         *ret_copy = BumpTransactionEvent_clone(orig_conv);
67670         int64_t ret_ref = tag_ptr(ret_copy, true);
67671         return ret_ref;
67672 }
67673
67674 int64_t  CS_LDK_BumpTransactionEvent_channel_close(int8_tArray claim_id, int32_t package_target_feerate_sat_per_1000_weight, int8_tArray commitment_tx, int64_t commitment_tx_fee_satoshis, int64_t anchor_descriptor, int64_tArray pending_htlcs) {
67675         LDKThirtyTwoBytes claim_id_ref;
67676         CHECK(claim_id->arr_len == 32);
67677         memcpy(claim_id_ref.data, claim_id->elems, 32); FREE(claim_id);
67678         LDKTransaction commitment_tx_ref;
67679         commitment_tx_ref.datalen = commitment_tx->arr_len;
67680         commitment_tx_ref.data = MALLOC(commitment_tx_ref.datalen, "LDKTransaction Bytes");
67681         memcpy(commitment_tx_ref.data, commitment_tx->elems, commitment_tx_ref.datalen); FREE(commitment_tx);
67682         commitment_tx_ref.data_is_owned = true;
67683         LDKAnchorDescriptor anchor_descriptor_conv;
67684         anchor_descriptor_conv.inner = untag_ptr(anchor_descriptor);
67685         anchor_descriptor_conv.is_owned = ptr_is_owned(anchor_descriptor);
67686         CHECK_INNER_FIELD_ACCESS_OR_NULL(anchor_descriptor_conv);
67687         anchor_descriptor_conv = AnchorDescriptor_clone(&anchor_descriptor_conv);
67688         LDKCVec_HTLCOutputInCommitmentZ pending_htlcs_constr;
67689         pending_htlcs_constr.datalen = pending_htlcs->arr_len;
67690         if (pending_htlcs_constr.datalen > 0)
67691                 pending_htlcs_constr.data = MALLOC(pending_htlcs_constr.datalen * sizeof(LDKHTLCOutputInCommitment), "LDKCVec_HTLCOutputInCommitmentZ Elements");
67692         else
67693                 pending_htlcs_constr.data = NULL;
67694         int64_t* pending_htlcs_vals = pending_htlcs->elems;
67695         for (size_t y = 0; y < pending_htlcs_constr.datalen; y++) {
67696                 int64_t pending_htlcs_conv_24 = pending_htlcs_vals[y];
67697                 LDKHTLCOutputInCommitment pending_htlcs_conv_24_conv;
67698                 pending_htlcs_conv_24_conv.inner = untag_ptr(pending_htlcs_conv_24);
67699                 pending_htlcs_conv_24_conv.is_owned = ptr_is_owned(pending_htlcs_conv_24);
67700                 CHECK_INNER_FIELD_ACCESS_OR_NULL(pending_htlcs_conv_24_conv);
67701                 pending_htlcs_conv_24_conv = HTLCOutputInCommitment_clone(&pending_htlcs_conv_24_conv);
67702                 pending_htlcs_constr.data[y] = pending_htlcs_conv_24_conv;
67703         }
67704         FREE(pending_htlcs);
67705         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67706         *ret_copy = BumpTransactionEvent_channel_close(claim_id_ref, package_target_feerate_sat_per_1000_weight, commitment_tx_ref, commitment_tx_fee_satoshis, anchor_descriptor_conv, pending_htlcs_constr);
67707         int64_t ret_ref = tag_ptr(ret_copy, true);
67708         return ret_ref;
67709 }
67710
67711 int64_t  CS_LDK_BumpTransactionEvent_htlcresolution(int8_tArray claim_id, int32_t target_feerate_sat_per_1000_weight, int64_tArray htlc_descriptors, int32_t tx_lock_time) {
67712         LDKThirtyTwoBytes claim_id_ref;
67713         CHECK(claim_id->arr_len == 32);
67714         memcpy(claim_id_ref.data, claim_id->elems, 32); FREE(claim_id);
67715         LDKCVec_HTLCDescriptorZ htlc_descriptors_constr;
67716         htlc_descriptors_constr.datalen = htlc_descriptors->arr_len;
67717         if (htlc_descriptors_constr.datalen > 0)
67718                 htlc_descriptors_constr.data = MALLOC(htlc_descriptors_constr.datalen * sizeof(LDKHTLCDescriptor), "LDKCVec_HTLCDescriptorZ Elements");
67719         else
67720                 htlc_descriptors_constr.data = NULL;
67721         int64_t* htlc_descriptors_vals = htlc_descriptors->elems;
67722         for (size_t q = 0; q < htlc_descriptors_constr.datalen; q++) {
67723                 int64_t htlc_descriptors_conv_16 = htlc_descriptors_vals[q];
67724                 LDKHTLCDescriptor htlc_descriptors_conv_16_conv;
67725                 htlc_descriptors_conv_16_conv.inner = untag_ptr(htlc_descriptors_conv_16);
67726                 htlc_descriptors_conv_16_conv.is_owned = ptr_is_owned(htlc_descriptors_conv_16);
67727                 CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_descriptors_conv_16_conv);
67728                 htlc_descriptors_conv_16_conv = HTLCDescriptor_clone(&htlc_descriptors_conv_16_conv);
67729                 htlc_descriptors_constr.data[q] = htlc_descriptors_conv_16_conv;
67730         }
67731         FREE(htlc_descriptors);
67732         LDKBumpTransactionEvent *ret_copy = MALLOC(sizeof(LDKBumpTransactionEvent), "LDKBumpTransactionEvent");
67733         *ret_copy = BumpTransactionEvent_htlcresolution(claim_id_ref, target_feerate_sat_per_1000_weight, htlc_descriptors_constr, tx_lock_time);
67734         int64_t ret_ref = tag_ptr(ret_copy, true);
67735         return ret_ref;
67736 }
67737
67738 jboolean  CS_LDK_BumpTransactionEvent_eq(int64_t a, int64_t b) {
67739         LDKBumpTransactionEvent* a_conv = (LDKBumpTransactionEvent*)untag_ptr(a);
67740         LDKBumpTransactionEvent* b_conv = (LDKBumpTransactionEvent*)untag_ptr(b);
67741         jboolean ret_conv = BumpTransactionEvent_eq(a_conv, b_conv);
67742         return ret_conv;
67743 }
67744
67745 void  CS_LDK_Input_free(int64_t this_obj) {
67746         LDKInput this_obj_conv;
67747         this_obj_conv.inner = untag_ptr(this_obj);
67748         this_obj_conv.is_owned = ptr_is_owned(this_obj);
67749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
67750         Input_free(this_obj_conv);
67751 }
67752
67753 int64_t  CS_LDK_Input_get_outpoint(int64_t this_ptr) {
67754         LDKInput this_ptr_conv;
67755         this_ptr_conv.inner = untag_ptr(this_ptr);
67756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67758         this_ptr_conv.is_owned = false;
67759         LDKOutPoint ret_var = Input_get_outpoint(&this_ptr_conv);
67760         int64_t ret_ref = 0;
67761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67762         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67763         return ret_ref;
67764 }
67765
67766 void  CS_LDK_Input_set_outpoint(int64_t this_ptr, int64_t val) {
67767         LDKInput this_ptr_conv;
67768         this_ptr_conv.inner = untag_ptr(this_ptr);
67769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67771         this_ptr_conv.is_owned = false;
67772         LDKOutPoint val_conv;
67773         val_conv.inner = untag_ptr(val);
67774         val_conv.is_owned = ptr_is_owned(val);
67775         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67776         val_conv = OutPoint_clone(&val_conv);
67777         Input_set_outpoint(&this_ptr_conv, val_conv);
67778 }
67779
67780 int64_t  CS_LDK_Input_get_previous_utxo(int64_t this_ptr) {
67781         LDKInput this_ptr_conv;
67782         this_ptr_conv.inner = untag_ptr(this_ptr);
67783         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67785         this_ptr_conv.is_owned = false;
67786         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
67787         *ret_ref = Input_get_previous_utxo(&this_ptr_conv);
67788         return tag_ptr(ret_ref, true);
67789 }
67790
67791 void  CS_LDK_Input_set_previous_utxo(int64_t this_ptr, int64_t val) {
67792         LDKInput this_ptr_conv;
67793         this_ptr_conv.inner = untag_ptr(this_ptr);
67794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67796         this_ptr_conv.is_owned = false;
67797         void* val_ptr = untag_ptr(val);
67798         CHECK_ACCESS(val_ptr);
67799         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
67800         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
67801         Input_set_previous_utxo(&this_ptr_conv, val_conv);
67802 }
67803
67804 int64_t  CS_LDK_Input_get_satisfaction_weight(int64_t this_ptr) {
67805         LDKInput this_ptr_conv;
67806         this_ptr_conv.inner = untag_ptr(this_ptr);
67807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67809         this_ptr_conv.is_owned = false;
67810         int64_t ret_conv = Input_get_satisfaction_weight(&this_ptr_conv);
67811         return ret_conv;
67812 }
67813
67814 void  CS_LDK_Input_set_satisfaction_weight(int64_t this_ptr, int64_t val) {
67815         LDKInput this_ptr_conv;
67816         this_ptr_conv.inner = untag_ptr(this_ptr);
67817         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67819         this_ptr_conv.is_owned = false;
67820         Input_set_satisfaction_weight(&this_ptr_conv, val);
67821 }
67822
67823 int64_t  CS_LDK_Input_new(int64_t outpoint_arg, int64_t previous_utxo_arg, int64_t satisfaction_weight_arg) {
67824         LDKOutPoint outpoint_arg_conv;
67825         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
67826         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
67827         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
67828         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
67829         void* previous_utxo_arg_ptr = untag_ptr(previous_utxo_arg);
67830         CHECK_ACCESS(previous_utxo_arg_ptr);
67831         LDKTxOut previous_utxo_arg_conv = *(LDKTxOut*)(previous_utxo_arg_ptr);
67832         previous_utxo_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(previous_utxo_arg));
67833         LDKInput ret_var = Input_new(outpoint_arg_conv, previous_utxo_arg_conv, satisfaction_weight_arg);
67834         int64_t ret_ref = 0;
67835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67837         return ret_ref;
67838 }
67839
67840 static inline uint64_t Input_clone_ptr(LDKInput *NONNULL_PTR arg) {
67841         LDKInput ret_var = Input_clone(arg);
67842         int64_t ret_ref = 0;
67843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67844         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67845         return ret_ref;
67846 }
67847 int64_t  CS_LDK_Input_clone_ptr(int64_t arg) {
67848         LDKInput arg_conv;
67849         arg_conv.inner = untag_ptr(arg);
67850         arg_conv.is_owned = ptr_is_owned(arg);
67851         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
67852         arg_conv.is_owned = false;
67853         int64_t ret_conv = Input_clone_ptr(&arg_conv);
67854         return ret_conv;
67855 }
67856
67857 int64_t  CS_LDK_Input_clone(int64_t orig) {
67858         LDKInput orig_conv;
67859         orig_conv.inner = untag_ptr(orig);
67860         orig_conv.is_owned = ptr_is_owned(orig);
67861         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
67862         orig_conv.is_owned = false;
67863         LDKInput ret_var = Input_clone(&orig_conv);
67864         int64_t ret_ref = 0;
67865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67866         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67867         return ret_ref;
67868 }
67869
67870 int64_t  CS_LDK_Input_hash(int64_t o) {
67871         LDKInput o_conv;
67872         o_conv.inner = untag_ptr(o);
67873         o_conv.is_owned = ptr_is_owned(o);
67874         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
67875         o_conv.is_owned = false;
67876         int64_t ret_conv = Input_hash(&o_conv);
67877         return ret_conv;
67878 }
67879
67880 jboolean  CS_LDK_Input_eq(int64_t a, int64_t b) {
67881         LDKInput a_conv;
67882         a_conv.inner = untag_ptr(a);
67883         a_conv.is_owned = ptr_is_owned(a);
67884         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
67885         a_conv.is_owned = false;
67886         LDKInput b_conv;
67887         b_conv.inner = untag_ptr(b);
67888         b_conv.is_owned = ptr_is_owned(b);
67889         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
67890         b_conv.is_owned = false;
67891         jboolean ret_conv = Input_eq(&a_conv, &b_conv);
67892         return ret_conv;
67893 }
67894
67895 void  CS_LDK_Utxo_free(int64_t this_obj) {
67896         LDKUtxo this_obj_conv;
67897         this_obj_conv.inner = untag_ptr(this_obj);
67898         this_obj_conv.is_owned = ptr_is_owned(this_obj);
67899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
67900         Utxo_free(this_obj_conv);
67901 }
67902
67903 int64_t  CS_LDK_Utxo_get_outpoint(int64_t this_ptr) {
67904         LDKUtxo this_ptr_conv;
67905         this_ptr_conv.inner = untag_ptr(this_ptr);
67906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67908         this_ptr_conv.is_owned = false;
67909         LDKOutPoint ret_var = Utxo_get_outpoint(&this_ptr_conv);
67910         int64_t ret_ref = 0;
67911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67913         return ret_ref;
67914 }
67915
67916 void  CS_LDK_Utxo_set_outpoint(int64_t this_ptr, int64_t val) {
67917         LDKUtxo this_ptr_conv;
67918         this_ptr_conv.inner = untag_ptr(this_ptr);
67919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67921         this_ptr_conv.is_owned = false;
67922         LDKOutPoint val_conv;
67923         val_conv.inner = untag_ptr(val);
67924         val_conv.is_owned = ptr_is_owned(val);
67925         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
67926         val_conv = OutPoint_clone(&val_conv);
67927         Utxo_set_outpoint(&this_ptr_conv, val_conv);
67928 }
67929
67930 int64_t  CS_LDK_Utxo_get_output(int64_t this_ptr) {
67931         LDKUtxo this_ptr_conv;
67932         this_ptr_conv.inner = untag_ptr(this_ptr);
67933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67935         this_ptr_conv.is_owned = false;
67936         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
67937         *ret_ref = Utxo_get_output(&this_ptr_conv);
67938         return tag_ptr(ret_ref, true);
67939 }
67940
67941 void  CS_LDK_Utxo_set_output(int64_t this_ptr, int64_t val) {
67942         LDKUtxo this_ptr_conv;
67943         this_ptr_conv.inner = untag_ptr(this_ptr);
67944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67946         this_ptr_conv.is_owned = false;
67947         void* val_ptr = untag_ptr(val);
67948         CHECK_ACCESS(val_ptr);
67949         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
67950         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
67951         Utxo_set_output(&this_ptr_conv, val_conv);
67952 }
67953
67954 int64_t  CS_LDK_Utxo_get_satisfaction_weight(int64_t this_ptr) {
67955         LDKUtxo this_ptr_conv;
67956         this_ptr_conv.inner = untag_ptr(this_ptr);
67957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67959         this_ptr_conv.is_owned = false;
67960         int64_t ret_conv = Utxo_get_satisfaction_weight(&this_ptr_conv);
67961         return ret_conv;
67962 }
67963
67964 void  CS_LDK_Utxo_set_satisfaction_weight(int64_t this_ptr, int64_t val) {
67965         LDKUtxo this_ptr_conv;
67966         this_ptr_conv.inner = untag_ptr(this_ptr);
67967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
67968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
67969         this_ptr_conv.is_owned = false;
67970         Utxo_set_satisfaction_weight(&this_ptr_conv, val);
67971 }
67972
67973 int64_t  CS_LDK_Utxo_new(int64_t outpoint_arg, int64_t output_arg, int64_t satisfaction_weight_arg) {
67974         LDKOutPoint outpoint_arg_conv;
67975         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
67976         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
67977         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
67978         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
67979         void* output_arg_ptr = untag_ptr(output_arg);
67980         CHECK_ACCESS(output_arg_ptr);
67981         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
67982         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
67983         LDKUtxo ret_var = Utxo_new(outpoint_arg_conv, output_arg_conv, satisfaction_weight_arg);
67984         int64_t ret_ref = 0;
67985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67986         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67987         return ret_ref;
67988 }
67989
67990 static inline uint64_t Utxo_clone_ptr(LDKUtxo *NONNULL_PTR arg) {
67991         LDKUtxo ret_var = Utxo_clone(arg);
67992         int64_t ret_ref = 0;
67993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
67994         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
67995         return ret_ref;
67996 }
67997 int64_t  CS_LDK_Utxo_clone_ptr(int64_t arg) {
67998         LDKUtxo arg_conv;
67999         arg_conv.inner = untag_ptr(arg);
68000         arg_conv.is_owned = ptr_is_owned(arg);
68001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68002         arg_conv.is_owned = false;
68003         int64_t ret_conv = Utxo_clone_ptr(&arg_conv);
68004         return ret_conv;
68005 }
68006
68007 int64_t  CS_LDK_Utxo_clone(int64_t orig) {
68008         LDKUtxo orig_conv;
68009         orig_conv.inner = untag_ptr(orig);
68010         orig_conv.is_owned = ptr_is_owned(orig);
68011         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68012         orig_conv.is_owned = false;
68013         LDKUtxo ret_var = Utxo_clone(&orig_conv);
68014         int64_t ret_ref = 0;
68015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68017         return ret_ref;
68018 }
68019
68020 int64_t  CS_LDK_Utxo_hash(int64_t o) {
68021         LDKUtxo o_conv;
68022         o_conv.inner = untag_ptr(o);
68023         o_conv.is_owned = ptr_is_owned(o);
68024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68025         o_conv.is_owned = false;
68026         int64_t ret_conv = Utxo_hash(&o_conv);
68027         return ret_conv;
68028 }
68029
68030 jboolean  CS_LDK_Utxo_eq(int64_t a, int64_t b) {
68031         LDKUtxo a_conv;
68032         a_conv.inner = untag_ptr(a);
68033         a_conv.is_owned = ptr_is_owned(a);
68034         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68035         a_conv.is_owned = false;
68036         LDKUtxo b_conv;
68037         b_conv.inner = untag_ptr(b);
68038         b_conv.is_owned = ptr_is_owned(b);
68039         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68040         b_conv.is_owned = false;
68041         jboolean ret_conv = Utxo_eq(&a_conv, &b_conv);
68042         return ret_conv;
68043 }
68044
68045 int64_t  CS_LDK_Utxo_new_p2pkh(int64_t outpoint, int64_t value, int8_tArray pubkey_hash) {
68046         LDKOutPoint outpoint_conv;
68047         outpoint_conv.inner = untag_ptr(outpoint);
68048         outpoint_conv.is_owned = ptr_is_owned(outpoint);
68049         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
68050         outpoint_conv = OutPoint_clone(&outpoint_conv);
68051         uint8_t pubkey_hash_arr[20];
68052         CHECK(pubkey_hash->arr_len == 20);
68053         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
68054         uint8_t (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
68055         LDKUtxo ret_var = Utxo_new_p2pkh(outpoint_conv, value, pubkey_hash_ref);
68056         int64_t ret_ref = 0;
68057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68058         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68059         return ret_ref;
68060 }
68061
68062 void  CS_LDK_CoinSelection_free(int64_t this_obj) {
68063         LDKCoinSelection this_obj_conv;
68064         this_obj_conv.inner = untag_ptr(this_obj);
68065         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68067         CoinSelection_free(this_obj_conv);
68068 }
68069
68070 int64_tArray  CS_LDK_CoinSelection_get_confirmed_utxos(int64_t this_ptr) {
68071         LDKCoinSelection this_ptr_conv;
68072         this_ptr_conv.inner = untag_ptr(this_ptr);
68073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68075         this_ptr_conv.is_owned = false;
68076         LDKCVec_UtxoZ ret_var = CoinSelection_get_confirmed_utxos(&this_ptr_conv);
68077         int64_tArray ret_arr = NULL;
68078         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
68079         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
68080         for (size_t g = 0; g < ret_var.datalen; g++) {
68081                 LDKUtxo ret_conv_6_var = ret_var.data[g];
68082                 int64_t ret_conv_6_ref = 0;
68083                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_6_var);
68084                 ret_conv_6_ref = tag_ptr(ret_conv_6_var.inner, ret_conv_6_var.is_owned);
68085                 ret_arr_ptr[g] = ret_conv_6_ref;
68086         }
68087         
68088         FREE(ret_var.data);
68089         return ret_arr;
68090 }
68091
68092 void  CS_LDK_CoinSelection_set_confirmed_utxos(int64_t this_ptr, int64_tArray val) {
68093         LDKCoinSelection this_ptr_conv;
68094         this_ptr_conv.inner = untag_ptr(this_ptr);
68095         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68097         this_ptr_conv.is_owned = false;
68098         LDKCVec_UtxoZ val_constr;
68099         val_constr.datalen = val->arr_len;
68100         if (val_constr.datalen > 0)
68101                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
68102         else
68103                 val_constr.data = NULL;
68104         int64_t* val_vals = val->elems;
68105         for (size_t g = 0; g < val_constr.datalen; g++) {
68106                 int64_t val_conv_6 = val_vals[g];
68107                 LDKUtxo val_conv_6_conv;
68108                 val_conv_6_conv.inner = untag_ptr(val_conv_6);
68109                 val_conv_6_conv.is_owned = ptr_is_owned(val_conv_6);
68110                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_6_conv);
68111                 val_conv_6_conv = Utxo_clone(&val_conv_6_conv);
68112                 val_constr.data[g] = val_conv_6_conv;
68113         }
68114         FREE(val);
68115         CoinSelection_set_confirmed_utxos(&this_ptr_conv, val_constr);
68116 }
68117
68118 int64_t  CS_LDK_CoinSelection_get_change_output(int64_t this_ptr) {
68119         LDKCoinSelection this_ptr_conv;
68120         this_ptr_conv.inner = untag_ptr(this_ptr);
68121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68123         this_ptr_conv.is_owned = false;
68124         LDKCOption_TxOutZ *ret_copy = MALLOC(sizeof(LDKCOption_TxOutZ), "LDKCOption_TxOutZ");
68125         *ret_copy = CoinSelection_get_change_output(&this_ptr_conv);
68126         int64_t ret_ref = tag_ptr(ret_copy, true);
68127         return ret_ref;
68128 }
68129
68130 void  CS_LDK_CoinSelection_set_change_output(int64_t this_ptr, int64_t val) {
68131         LDKCoinSelection this_ptr_conv;
68132         this_ptr_conv.inner = untag_ptr(this_ptr);
68133         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68135         this_ptr_conv.is_owned = false;
68136         void* val_ptr = untag_ptr(val);
68137         CHECK_ACCESS(val_ptr);
68138         LDKCOption_TxOutZ val_conv = *(LDKCOption_TxOutZ*)(val_ptr);
68139         val_conv = COption_TxOutZ_clone((LDKCOption_TxOutZ*)untag_ptr(val));
68140         CoinSelection_set_change_output(&this_ptr_conv, val_conv);
68141 }
68142
68143 int64_t  CS_LDK_CoinSelection_new(int64_tArray confirmed_utxos_arg, int64_t change_output_arg) {
68144         LDKCVec_UtxoZ confirmed_utxos_arg_constr;
68145         confirmed_utxos_arg_constr.datalen = confirmed_utxos_arg->arr_len;
68146         if (confirmed_utxos_arg_constr.datalen > 0)
68147                 confirmed_utxos_arg_constr.data = MALLOC(confirmed_utxos_arg_constr.datalen * sizeof(LDKUtxo), "LDKCVec_UtxoZ Elements");
68148         else
68149                 confirmed_utxos_arg_constr.data = NULL;
68150         int64_t* confirmed_utxos_arg_vals = confirmed_utxos_arg->elems;
68151         for (size_t g = 0; g < confirmed_utxos_arg_constr.datalen; g++) {
68152                 int64_t confirmed_utxos_arg_conv_6 = confirmed_utxos_arg_vals[g];
68153                 LDKUtxo confirmed_utxos_arg_conv_6_conv;
68154                 confirmed_utxos_arg_conv_6_conv.inner = untag_ptr(confirmed_utxos_arg_conv_6);
68155                 confirmed_utxos_arg_conv_6_conv.is_owned = ptr_is_owned(confirmed_utxos_arg_conv_6);
68156                 CHECK_INNER_FIELD_ACCESS_OR_NULL(confirmed_utxos_arg_conv_6_conv);
68157                 confirmed_utxos_arg_conv_6_conv = Utxo_clone(&confirmed_utxos_arg_conv_6_conv);
68158                 confirmed_utxos_arg_constr.data[g] = confirmed_utxos_arg_conv_6_conv;
68159         }
68160         FREE(confirmed_utxos_arg);
68161         void* change_output_arg_ptr = untag_ptr(change_output_arg);
68162         CHECK_ACCESS(change_output_arg_ptr);
68163         LDKCOption_TxOutZ change_output_arg_conv = *(LDKCOption_TxOutZ*)(change_output_arg_ptr);
68164         change_output_arg_conv = COption_TxOutZ_clone((LDKCOption_TxOutZ*)untag_ptr(change_output_arg));
68165         LDKCoinSelection ret_var = CoinSelection_new(confirmed_utxos_arg_constr, change_output_arg_conv);
68166         int64_t ret_ref = 0;
68167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68169         return ret_ref;
68170 }
68171
68172 static inline uint64_t CoinSelection_clone_ptr(LDKCoinSelection *NONNULL_PTR arg) {
68173         LDKCoinSelection ret_var = CoinSelection_clone(arg);
68174         int64_t ret_ref = 0;
68175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68177         return ret_ref;
68178 }
68179 int64_t  CS_LDK_CoinSelection_clone_ptr(int64_t arg) {
68180         LDKCoinSelection arg_conv;
68181         arg_conv.inner = untag_ptr(arg);
68182         arg_conv.is_owned = ptr_is_owned(arg);
68183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68184         arg_conv.is_owned = false;
68185         int64_t ret_conv = CoinSelection_clone_ptr(&arg_conv);
68186         return ret_conv;
68187 }
68188
68189 int64_t  CS_LDK_CoinSelection_clone(int64_t orig) {
68190         LDKCoinSelection orig_conv;
68191         orig_conv.inner = untag_ptr(orig);
68192         orig_conv.is_owned = ptr_is_owned(orig);
68193         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68194         orig_conv.is_owned = false;
68195         LDKCoinSelection ret_var = CoinSelection_clone(&orig_conv);
68196         int64_t ret_ref = 0;
68197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68199         return ret_ref;
68200 }
68201
68202 void  CS_LDK_CoinSelectionSource_free(int64_t this_ptr) {
68203         if (!ptr_is_owned(this_ptr)) return;
68204         void* this_ptr_ptr = untag_ptr(this_ptr);
68205         CHECK_ACCESS(this_ptr_ptr);
68206         LDKCoinSelectionSource this_ptr_conv = *(LDKCoinSelectionSource*)(this_ptr_ptr);
68207         FREE(untag_ptr(this_ptr));
68208         CoinSelectionSource_free(this_ptr_conv);
68209 }
68210
68211 void  CS_LDK_WalletSource_free(int64_t this_ptr) {
68212         if (!ptr_is_owned(this_ptr)) return;
68213         void* this_ptr_ptr = untag_ptr(this_ptr);
68214         CHECK_ACCESS(this_ptr_ptr);
68215         LDKWalletSource this_ptr_conv = *(LDKWalletSource*)(this_ptr_ptr);
68216         FREE(untag_ptr(this_ptr));
68217         WalletSource_free(this_ptr_conv);
68218 }
68219
68220 void  CS_LDK_Wallet_free(int64_t this_obj) {
68221         LDKWallet this_obj_conv;
68222         this_obj_conv.inner = untag_ptr(this_obj);
68223         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68225         Wallet_free(this_obj_conv);
68226 }
68227
68228 int64_t  CS_LDK_Wallet_new(int64_t source, int64_t logger) {
68229         void* source_ptr = untag_ptr(source);
68230         CHECK_ACCESS(source_ptr);
68231         LDKWalletSource source_conv = *(LDKWalletSource*)(source_ptr);
68232         if (source_conv.free == LDKWalletSource_JCalls_free) {
68233                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68234                 LDKWalletSource_JCalls_cloned(&source_conv);
68235         }
68236         void* logger_ptr = untag_ptr(logger);
68237         CHECK_ACCESS(logger_ptr);
68238         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
68239         if (logger_conv.free == LDKLogger_JCalls_free) {
68240                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68241                 LDKLogger_JCalls_cloned(&logger_conv);
68242         }
68243         LDKWallet ret_var = Wallet_new(source_conv, logger_conv);
68244         int64_t ret_ref = 0;
68245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68247         return ret_ref;
68248 }
68249
68250 int64_t  CS_LDK_Wallet_as_CoinSelectionSource(int64_t this_arg) {
68251         LDKWallet this_arg_conv;
68252         this_arg_conv.inner = untag_ptr(this_arg);
68253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68255         this_arg_conv.is_owned = false;
68256         LDKCoinSelectionSource* ret_ret = MALLOC(sizeof(LDKCoinSelectionSource), "LDKCoinSelectionSource");
68257         *ret_ret = Wallet_as_CoinSelectionSource(&this_arg_conv);
68258         return tag_ptr(ret_ret, true);
68259 }
68260
68261 void  CS_LDK_BumpTransactionEventHandler_free(int64_t this_obj) {
68262         LDKBumpTransactionEventHandler this_obj_conv;
68263         this_obj_conv.inner = untag_ptr(this_obj);
68264         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68266         BumpTransactionEventHandler_free(this_obj_conv);
68267 }
68268
68269 int64_t  CS_LDK_BumpTransactionEventHandler_new(int64_t broadcaster, int64_t utxo_source, int64_t signer_provider, int64_t logger) {
68270         void* broadcaster_ptr = untag_ptr(broadcaster);
68271         CHECK_ACCESS(broadcaster_ptr);
68272         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
68273         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
68274                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68275                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
68276         }
68277         void* utxo_source_ptr = untag_ptr(utxo_source);
68278         CHECK_ACCESS(utxo_source_ptr);
68279         LDKCoinSelectionSource utxo_source_conv = *(LDKCoinSelectionSource*)(utxo_source_ptr);
68280         if (utxo_source_conv.free == LDKCoinSelectionSource_JCalls_free) {
68281                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68282                 LDKCoinSelectionSource_JCalls_cloned(&utxo_source_conv);
68283         }
68284         void* signer_provider_ptr = untag_ptr(signer_provider);
68285         CHECK_ACCESS(signer_provider_ptr);
68286         LDKSignerProvider signer_provider_conv = *(LDKSignerProvider*)(signer_provider_ptr);
68287         if (signer_provider_conv.free == LDKSignerProvider_JCalls_free) {
68288                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68289                 LDKSignerProvider_JCalls_cloned(&signer_provider_conv);
68290         }
68291         void* logger_ptr = untag_ptr(logger);
68292         CHECK_ACCESS(logger_ptr);
68293         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
68294         if (logger_conv.free == LDKLogger_JCalls_free) {
68295                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68296                 LDKLogger_JCalls_cloned(&logger_conv);
68297         }
68298         LDKBumpTransactionEventHandler ret_var = BumpTransactionEventHandler_new(broadcaster_conv, utxo_source_conv, signer_provider_conv, logger_conv);
68299         int64_t ret_ref = 0;
68300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68301         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68302         return ret_ref;
68303 }
68304
68305 void  CS_LDK_BumpTransactionEventHandler_handle_event(int64_t this_arg, int64_t event) {
68306         LDKBumpTransactionEventHandler this_arg_conv;
68307         this_arg_conv.inner = untag_ptr(this_arg);
68308         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68310         this_arg_conv.is_owned = false;
68311         LDKBumpTransactionEvent* event_conv = (LDKBumpTransactionEvent*)untag_ptr(event);
68312         BumpTransactionEventHandler_handle_event(&this_arg_conv, event_conv);
68313 }
68314
68315 void  CS_LDK_FilesystemStore_free(int64_t this_obj) {
68316         LDKFilesystemStore this_obj_conv;
68317         this_obj_conv.inner = untag_ptr(this_obj);
68318         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68320         FilesystemStore_free(this_obj_conv);
68321 }
68322
68323 int64_t  CS_LDK_FilesystemStore_new(jstring data_dir) {
68324         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
68325         LDKFilesystemStore ret_var = FilesystemStore_new(data_dir_conv);
68326         int64_t ret_ref = 0;
68327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68329         return ret_ref;
68330 }
68331
68332 jstring  CS_LDK_FilesystemStore_get_data_dir(int64_t this_arg) {
68333         LDKFilesystemStore this_arg_conv;
68334         this_arg_conv.inner = untag_ptr(this_arg);
68335         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68337         this_arg_conv.is_owned = false;
68338         LDKStr ret_str = FilesystemStore_get_data_dir(&this_arg_conv);
68339         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
68340         Str_free(ret_str);
68341         return ret_conv;
68342 }
68343
68344 int64_t  CS_LDK_FilesystemStore_as_KVStore(int64_t this_arg) {
68345         LDKFilesystemStore this_arg_conv;
68346         this_arg_conv.inner = untag_ptr(this_arg);
68347         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68349         this_arg_conv.is_owned = false;
68350         LDKKVStore* ret_ret = MALLOC(sizeof(LDKKVStore), "LDKKVStore");
68351         *ret_ret = FilesystemStore_as_KVStore(&this_arg_conv);
68352         return tag_ptr(ret_ret, true);
68353 }
68354
68355 void  CS_LDK_BackgroundProcessor_free(int64_t this_obj) {
68356         LDKBackgroundProcessor this_obj_conv;
68357         this_obj_conv.inner = untag_ptr(this_obj);
68358         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68360         BackgroundProcessor_free(this_obj_conv);
68361 }
68362
68363 void  CS_LDK_GossipSync_free(int64_t this_ptr) {
68364         if (!ptr_is_owned(this_ptr)) return;
68365         void* this_ptr_ptr = untag_ptr(this_ptr);
68366         CHECK_ACCESS(this_ptr_ptr);
68367         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
68368         FREE(untag_ptr(this_ptr));
68369         GossipSync_free(this_ptr_conv);
68370 }
68371
68372 int64_t  CS_LDK_GossipSync_p2_p(int64_t a) {
68373         LDKP2PGossipSync a_conv;
68374         a_conv.inner = untag_ptr(a);
68375         a_conv.is_owned = ptr_is_owned(a);
68376         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68377         a_conv.is_owned = false;
68378         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
68379         *ret_copy = GossipSync_p2_p(&a_conv);
68380         int64_t ret_ref = tag_ptr(ret_copy, true);
68381         return ret_ref;
68382 }
68383
68384 int64_t  CS_LDK_GossipSync_rapid(int64_t a) {
68385         LDKRapidGossipSync a_conv;
68386         a_conv.inner = untag_ptr(a);
68387         a_conv.is_owned = ptr_is_owned(a);
68388         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68389         a_conv.is_owned = false;
68390         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
68391         *ret_copy = GossipSync_rapid(&a_conv);
68392         int64_t ret_ref = tag_ptr(ret_copy, true);
68393         return ret_ref;
68394 }
68395
68396 int64_t  CS_LDK_GossipSync_none() {
68397         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
68398         *ret_copy = GossipSync_none();
68399         int64_t ret_ref = tag_ptr(ret_copy, true);
68400         return ret_ref;
68401 }
68402
68403 int64_t  CS_LDK_BackgroundProcessor_start(int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t gossip_sync, int64_t peer_manager, int64_t logger, int64_t scorer) {
68404         void* persister_ptr = untag_ptr(persister);
68405         CHECK_ACCESS(persister_ptr);
68406         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
68407         if (persister_conv.free == LDKPersister_JCalls_free) {
68408                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68409                 LDKPersister_JCalls_cloned(&persister_conv);
68410         }
68411         void* event_handler_ptr = untag_ptr(event_handler);
68412         CHECK_ACCESS(event_handler_ptr);
68413         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
68414         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
68415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68416                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
68417         }
68418         LDKChainMonitor chain_monitor_conv;
68419         chain_monitor_conv.inner = untag_ptr(chain_monitor);
68420         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
68421         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
68422         chain_monitor_conv.is_owned = false;
68423         LDKChannelManager channel_manager_conv;
68424         channel_manager_conv.inner = untag_ptr(channel_manager);
68425         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
68426         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
68427         channel_manager_conv.is_owned = false;
68428         void* gossip_sync_ptr = untag_ptr(gossip_sync);
68429         CHECK_ACCESS(gossip_sync_ptr);
68430         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
68431         // WARNING: we may need a move here but no clone is available for LDKGossipSync
68432         LDKPeerManager peer_manager_conv;
68433         peer_manager_conv.inner = untag_ptr(peer_manager);
68434         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
68435         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
68436         peer_manager_conv.is_owned = false;
68437         void* logger_ptr = untag_ptr(logger);
68438         CHECK_ACCESS(logger_ptr);
68439         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
68440         if (logger_conv.free == LDKLogger_JCalls_free) {
68441                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68442                 LDKLogger_JCalls_cloned(&logger_conv);
68443         }
68444         void* scorer_ptr = untag_ptr(scorer);
68445         CHECK_ACCESS(scorer_ptr);
68446         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
68447         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
68448         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
68449                 // Manually implement clone for Java trait instances
68450                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
68451                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
68452                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
68453                 }
68454         }
68455         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, gossip_sync_conv, &peer_manager_conv, logger_conv, scorer_conv);
68456         int64_t ret_ref = 0;
68457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68458         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68459         return ret_ref;
68460 }
68461
68462 int64_t  CS_LDK_BackgroundProcessor_join(int64_t this_arg) {
68463         LDKBackgroundProcessor this_arg_conv;
68464         this_arg_conv.inner = untag_ptr(this_arg);
68465         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68467         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
68468         
68469         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
68470         *ret_conv = BackgroundProcessor_join(this_arg_conv);
68471         return tag_ptr(ret_conv, true);
68472 }
68473
68474 int64_t  CS_LDK_BackgroundProcessor_stop(int64_t this_arg) {
68475         LDKBackgroundProcessor this_arg_conv;
68476         this_arg_conv.inner = untag_ptr(this_arg);
68477         this_arg_conv.is_owned = ptr_is_owned(this_arg);
68478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
68479         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
68480         
68481         LDKCResult_NoneIOErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneIOErrorZ), "LDKCResult_NoneIOErrorZ");
68482         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
68483         return tag_ptr(ret_conv, true);
68484 }
68485
68486 void  CS_LDK_Bolt11ParseError_free(int64_t this_ptr) {
68487         if (!ptr_is_owned(this_ptr)) return;
68488         void* this_ptr_ptr = untag_ptr(this_ptr);
68489         CHECK_ACCESS(this_ptr_ptr);
68490         LDKBolt11ParseError this_ptr_conv = *(LDKBolt11ParseError*)(this_ptr_ptr);
68491         FREE(untag_ptr(this_ptr));
68492         Bolt11ParseError_free(this_ptr_conv);
68493 }
68494
68495 static inline uint64_t Bolt11ParseError_clone_ptr(LDKBolt11ParseError *NONNULL_PTR arg) {
68496         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68497         *ret_copy = Bolt11ParseError_clone(arg);
68498         int64_t ret_ref = tag_ptr(ret_copy, true);
68499         return ret_ref;
68500 }
68501 int64_t  CS_LDK_Bolt11ParseError_clone_ptr(int64_t arg) {
68502         LDKBolt11ParseError* arg_conv = (LDKBolt11ParseError*)untag_ptr(arg);
68503         int64_t ret_conv = Bolt11ParseError_clone_ptr(arg_conv);
68504         return ret_conv;
68505 }
68506
68507 int64_t  CS_LDK_Bolt11ParseError_clone(int64_t orig) {
68508         LDKBolt11ParseError* orig_conv = (LDKBolt11ParseError*)untag_ptr(orig);
68509         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68510         *ret_copy = Bolt11ParseError_clone(orig_conv);
68511         int64_t ret_ref = tag_ptr(ret_copy, true);
68512         return ret_ref;
68513 }
68514
68515 int64_t  CS_LDK_Bolt11ParseError_bech32_error(int64_t a) {
68516         void* a_ptr = untag_ptr(a);
68517         CHECK_ACCESS(a_ptr);
68518         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
68519         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
68520         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68521         *ret_copy = Bolt11ParseError_bech32_error(a_conv);
68522         int64_t ret_ref = tag_ptr(ret_copy, true);
68523         return ret_ref;
68524 }
68525
68526 int64_t  CS_LDK_Bolt11ParseError_parse_amount_error(int32_t a) {
68527         
68528         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68529         *ret_copy = Bolt11ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
68530         int64_t ret_ref = tag_ptr(ret_copy, true);
68531         return ret_ref;
68532 }
68533
68534 int64_t  CS_LDK_Bolt11ParseError_malformed_signature(int32_t a) {
68535         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_cs(a);
68536         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68537         *ret_copy = Bolt11ParseError_malformed_signature(a_conv);
68538         int64_t ret_ref = tag_ptr(ret_copy, true);
68539         return ret_ref;
68540 }
68541
68542 int64_t  CS_LDK_Bolt11ParseError_bad_prefix() {
68543         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68544         *ret_copy = Bolt11ParseError_bad_prefix();
68545         int64_t ret_ref = tag_ptr(ret_copy, true);
68546         return ret_ref;
68547 }
68548
68549 int64_t  CS_LDK_Bolt11ParseError_unknown_currency() {
68550         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68551         *ret_copy = Bolt11ParseError_unknown_currency();
68552         int64_t ret_ref = tag_ptr(ret_copy, true);
68553         return ret_ref;
68554 }
68555
68556 int64_t  CS_LDK_Bolt11ParseError_unknown_si_prefix() {
68557         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68558         *ret_copy = Bolt11ParseError_unknown_si_prefix();
68559         int64_t ret_ref = tag_ptr(ret_copy, true);
68560         return ret_ref;
68561 }
68562
68563 int64_t  CS_LDK_Bolt11ParseError_malformed_hrp() {
68564         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68565         *ret_copy = Bolt11ParseError_malformed_hrp();
68566         int64_t ret_ref = tag_ptr(ret_copy, true);
68567         return ret_ref;
68568 }
68569
68570 int64_t  CS_LDK_Bolt11ParseError_too_short_data_part() {
68571         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68572         *ret_copy = Bolt11ParseError_too_short_data_part();
68573         int64_t ret_ref = tag_ptr(ret_copy, true);
68574         return ret_ref;
68575 }
68576
68577 int64_t  CS_LDK_Bolt11ParseError_unexpected_end_of_tagged_fields() {
68578         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68579         *ret_copy = Bolt11ParseError_unexpected_end_of_tagged_fields();
68580         int64_t ret_ref = tag_ptr(ret_copy, true);
68581         return ret_ref;
68582 }
68583
68584 int64_t  CS_LDK_Bolt11ParseError_description_decode_error(int32_t a) {
68585         
68586         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68587         *ret_copy = Bolt11ParseError_description_decode_error((LDKError){ ._dummy = 0 });
68588         int64_t ret_ref = tag_ptr(ret_copy, true);
68589         return ret_ref;
68590 }
68591
68592 int64_t  CS_LDK_Bolt11ParseError_padding_error() {
68593         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68594         *ret_copy = Bolt11ParseError_padding_error();
68595         int64_t ret_ref = tag_ptr(ret_copy, true);
68596         return ret_ref;
68597 }
68598
68599 int64_t  CS_LDK_Bolt11ParseError_integer_overflow_error() {
68600         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68601         *ret_copy = Bolt11ParseError_integer_overflow_error();
68602         int64_t ret_ref = tag_ptr(ret_copy, true);
68603         return ret_ref;
68604 }
68605
68606 int64_t  CS_LDK_Bolt11ParseError_invalid_seg_wit_program_length() {
68607         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68608         *ret_copy = Bolt11ParseError_invalid_seg_wit_program_length();
68609         int64_t ret_ref = tag_ptr(ret_copy, true);
68610         return ret_ref;
68611 }
68612
68613 int64_t  CS_LDK_Bolt11ParseError_invalid_pub_key_hash_length() {
68614         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68615         *ret_copy = Bolt11ParseError_invalid_pub_key_hash_length();
68616         int64_t ret_ref = tag_ptr(ret_copy, true);
68617         return ret_ref;
68618 }
68619
68620 int64_t  CS_LDK_Bolt11ParseError_invalid_script_hash_length() {
68621         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68622         *ret_copy = Bolt11ParseError_invalid_script_hash_length();
68623         int64_t ret_ref = tag_ptr(ret_copy, true);
68624         return ret_ref;
68625 }
68626
68627 int64_t  CS_LDK_Bolt11ParseError_invalid_recovery_id() {
68628         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68629         *ret_copy = Bolt11ParseError_invalid_recovery_id();
68630         int64_t ret_ref = tag_ptr(ret_copy, true);
68631         return ret_ref;
68632 }
68633
68634 int64_t  CS_LDK_Bolt11ParseError_invalid_slice_length(jstring a) {
68635         LDKStr a_conv = str_ref_to_owned_c(a);
68636         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68637         *ret_copy = Bolt11ParseError_invalid_slice_length(a_conv);
68638         int64_t ret_ref = tag_ptr(ret_copy, true);
68639         return ret_ref;
68640 }
68641
68642 int64_t  CS_LDK_Bolt11ParseError_skip() {
68643         LDKBolt11ParseError *ret_copy = MALLOC(sizeof(LDKBolt11ParseError), "LDKBolt11ParseError");
68644         *ret_copy = Bolt11ParseError_skip();
68645         int64_t ret_ref = tag_ptr(ret_copy, true);
68646         return ret_ref;
68647 }
68648
68649 jboolean  CS_LDK_Bolt11ParseError_eq(int64_t a, int64_t b) {
68650         LDKBolt11ParseError* a_conv = (LDKBolt11ParseError*)untag_ptr(a);
68651         LDKBolt11ParseError* b_conv = (LDKBolt11ParseError*)untag_ptr(b);
68652         jboolean ret_conv = Bolt11ParseError_eq(a_conv, b_conv);
68653         return ret_conv;
68654 }
68655
68656 void  CS_LDK_ParseOrSemanticError_free(int64_t this_ptr) {
68657         if (!ptr_is_owned(this_ptr)) return;
68658         void* this_ptr_ptr = untag_ptr(this_ptr);
68659         CHECK_ACCESS(this_ptr_ptr);
68660         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
68661         FREE(untag_ptr(this_ptr));
68662         ParseOrSemanticError_free(this_ptr_conv);
68663 }
68664
68665 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
68666         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68667         *ret_copy = ParseOrSemanticError_clone(arg);
68668         int64_t ret_ref = tag_ptr(ret_copy, true);
68669         return ret_ref;
68670 }
68671 int64_t  CS_LDK_ParseOrSemanticError_clone_ptr(int64_t arg) {
68672         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
68673         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
68674         return ret_conv;
68675 }
68676
68677 int64_t  CS_LDK_ParseOrSemanticError_clone(int64_t orig) {
68678         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
68679         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68680         *ret_copy = ParseOrSemanticError_clone(orig_conv);
68681         int64_t ret_ref = tag_ptr(ret_copy, true);
68682         return ret_ref;
68683 }
68684
68685 int64_t  CS_LDK_ParseOrSemanticError_parse_error(int64_t a) {
68686         void* a_ptr = untag_ptr(a);
68687         CHECK_ACCESS(a_ptr);
68688         LDKBolt11ParseError a_conv = *(LDKBolt11ParseError*)(a_ptr);
68689         a_conv = Bolt11ParseError_clone((LDKBolt11ParseError*)untag_ptr(a));
68690         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68691         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
68692         int64_t ret_ref = tag_ptr(ret_copy, true);
68693         return ret_ref;
68694 }
68695
68696 int64_t  CS_LDK_ParseOrSemanticError_semantic_error(int32_t a) {
68697         LDKBolt11SemanticError a_conv = LDKBolt11SemanticError_from_cs(a);
68698         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
68699         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
68700         int64_t ret_ref = tag_ptr(ret_copy, true);
68701         return ret_ref;
68702 }
68703
68704 jboolean  CS_LDK_ParseOrSemanticError_eq(int64_t a, int64_t b) {
68705         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
68706         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
68707         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
68708         return ret_conv;
68709 }
68710
68711 void  CS_LDK_Bolt11Invoice_free(int64_t this_obj) {
68712         LDKBolt11Invoice this_obj_conv;
68713         this_obj_conv.inner = untag_ptr(this_obj);
68714         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68716         Bolt11Invoice_free(this_obj_conv);
68717 }
68718
68719 jboolean  CS_LDK_Bolt11Invoice_eq(int64_t a, int64_t b) {
68720         LDKBolt11Invoice a_conv;
68721         a_conv.inner = untag_ptr(a);
68722         a_conv.is_owned = ptr_is_owned(a);
68723         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68724         a_conv.is_owned = false;
68725         LDKBolt11Invoice b_conv;
68726         b_conv.inner = untag_ptr(b);
68727         b_conv.is_owned = ptr_is_owned(b);
68728         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68729         b_conv.is_owned = false;
68730         jboolean ret_conv = Bolt11Invoice_eq(&a_conv, &b_conv);
68731         return ret_conv;
68732 }
68733
68734 static inline uint64_t Bolt11Invoice_clone_ptr(LDKBolt11Invoice *NONNULL_PTR arg) {
68735         LDKBolt11Invoice ret_var = Bolt11Invoice_clone(arg);
68736         int64_t ret_ref = 0;
68737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68738         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68739         return ret_ref;
68740 }
68741 int64_t  CS_LDK_Bolt11Invoice_clone_ptr(int64_t arg) {
68742         LDKBolt11Invoice arg_conv;
68743         arg_conv.inner = untag_ptr(arg);
68744         arg_conv.is_owned = ptr_is_owned(arg);
68745         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68746         arg_conv.is_owned = false;
68747         int64_t ret_conv = Bolt11Invoice_clone_ptr(&arg_conv);
68748         return ret_conv;
68749 }
68750
68751 int64_t  CS_LDK_Bolt11Invoice_clone(int64_t orig) {
68752         LDKBolt11Invoice orig_conv;
68753         orig_conv.inner = untag_ptr(orig);
68754         orig_conv.is_owned = ptr_is_owned(orig);
68755         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68756         orig_conv.is_owned = false;
68757         LDKBolt11Invoice ret_var = Bolt11Invoice_clone(&orig_conv);
68758         int64_t ret_ref = 0;
68759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68760         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68761         return ret_ref;
68762 }
68763
68764 int64_t  CS_LDK_Bolt11Invoice_hash(int64_t o) {
68765         LDKBolt11Invoice o_conv;
68766         o_conv.inner = untag_ptr(o);
68767         o_conv.is_owned = ptr_is_owned(o);
68768         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68769         o_conv.is_owned = false;
68770         int64_t ret_conv = Bolt11Invoice_hash(&o_conv);
68771         return ret_conv;
68772 }
68773
68774 void  CS_LDK_SignedRawBolt11Invoice_free(int64_t this_obj) {
68775         LDKSignedRawBolt11Invoice this_obj_conv;
68776         this_obj_conv.inner = untag_ptr(this_obj);
68777         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68779         SignedRawBolt11Invoice_free(this_obj_conv);
68780 }
68781
68782 jboolean  CS_LDK_SignedRawBolt11Invoice_eq(int64_t a, int64_t b) {
68783         LDKSignedRawBolt11Invoice a_conv;
68784         a_conv.inner = untag_ptr(a);
68785         a_conv.is_owned = ptr_is_owned(a);
68786         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68787         a_conv.is_owned = false;
68788         LDKSignedRawBolt11Invoice b_conv;
68789         b_conv.inner = untag_ptr(b);
68790         b_conv.is_owned = ptr_is_owned(b);
68791         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68792         b_conv.is_owned = false;
68793         jboolean ret_conv = SignedRawBolt11Invoice_eq(&a_conv, &b_conv);
68794         return ret_conv;
68795 }
68796
68797 static inline uint64_t SignedRawBolt11Invoice_clone_ptr(LDKSignedRawBolt11Invoice *NONNULL_PTR arg) {
68798         LDKSignedRawBolt11Invoice ret_var = SignedRawBolt11Invoice_clone(arg);
68799         int64_t ret_ref = 0;
68800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68802         return ret_ref;
68803 }
68804 int64_t  CS_LDK_SignedRawBolt11Invoice_clone_ptr(int64_t arg) {
68805         LDKSignedRawBolt11Invoice arg_conv;
68806         arg_conv.inner = untag_ptr(arg);
68807         arg_conv.is_owned = ptr_is_owned(arg);
68808         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68809         arg_conv.is_owned = false;
68810         int64_t ret_conv = SignedRawBolt11Invoice_clone_ptr(&arg_conv);
68811         return ret_conv;
68812 }
68813
68814 int64_t  CS_LDK_SignedRawBolt11Invoice_clone(int64_t orig) {
68815         LDKSignedRawBolt11Invoice orig_conv;
68816         orig_conv.inner = untag_ptr(orig);
68817         orig_conv.is_owned = ptr_is_owned(orig);
68818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68819         orig_conv.is_owned = false;
68820         LDKSignedRawBolt11Invoice ret_var = SignedRawBolt11Invoice_clone(&orig_conv);
68821         int64_t ret_ref = 0;
68822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68823         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68824         return ret_ref;
68825 }
68826
68827 int64_t  CS_LDK_SignedRawBolt11Invoice_hash(int64_t o) {
68828         LDKSignedRawBolt11Invoice o_conv;
68829         o_conv.inner = untag_ptr(o);
68830         o_conv.is_owned = ptr_is_owned(o);
68831         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68832         o_conv.is_owned = false;
68833         int64_t ret_conv = SignedRawBolt11Invoice_hash(&o_conv);
68834         return ret_conv;
68835 }
68836
68837 void  CS_LDK_RawBolt11Invoice_free(int64_t this_obj) {
68838         LDKRawBolt11Invoice this_obj_conv;
68839         this_obj_conv.inner = untag_ptr(this_obj);
68840         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68842         RawBolt11Invoice_free(this_obj_conv);
68843 }
68844
68845 int64_t  CS_LDK_RawBolt11Invoice_get_data(int64_t this_ptr) {
68846         LDKRawBolt11Invoice this_ptr_conv;
68847         this_ptr_conv.inner = untag_ptr(this_ptr);
68848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68850         this_ptr_conv.is_owned = false;
68851         LDKRawDataPart ret_var = RawBolt11Invoice_get_data(&this_ptr_conv);
68852         int64_t ret_ref = 0;
68853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68854         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68855         return ret_ref;
68856 }
68857
68858 void  CS_LDK_RawBolt11Invoice_set_data(int64_t this_ptr, int64_t val) {
68859         LDKRawBolt11Invoice this_ptr_conv;
68860         this_ptr_conv.inner = untag_ptr(this_ptr);
68861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68863         this_ptr_conv.is_owned = false;
68864         LDKRawDataPart val_conv;
68865         val_conv.inner = untag_ptr(val);
68866         val_conv.is_owned = ptr_is_owned(val);
68867         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
68868         val_conv = RawDataPart_clone(&val_conv);
68869         RawBolt11Invoice_set_data(&this_ptr_conv, val_conv);
68870 }
68871
68872 jboolean  CS_LDK_RawBolt11Invoice_eq(int64_t a, int64_t b) {
68873         LDKRawBolt11Invoice a_conv;
68874         a_conv.inner = untag_ptr(a);
68875         a_conv.is_owned = ptr_is_owned(a);
68876         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68877         a_conv.is_owned = false;
68878         LDKRawBolt11Invoice b_conv;
68879         b_conv.inner = untag_ptr(b);
68880         b_conv.is_owned = ptr_is_owned(b);
68881         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68882         b_conv.is_owned = false;
68883         jboolean ret_conv = RawBolt11Invoice_eq(&a_conv, &b_conv);
68884         return ret_conv;
68885 }
68886
68887 static inline uint64_t RawBolt11Invoice_clone_ptr(LDKRawBolt11Invoice *NONNULL_PTR arg) {
68888         LDKRawBolt11Invoice ret_var = RawBolt11Invoice_clone(arg);
68889         int64_t ret_ref = 0;
68890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68891         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68892         return ret_ref;
68893 }
68894 int64_t  CS_LDK_RawBolt11Invoice_clone_ptr(int64_t arg) {
68895         LDKRawBolt11Invoice arg_conv;
68896         arg_conv.inner = untag_ptr(arg);
68897         arg_conv.is_owned = ptr_is_owned(arg);
68898         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68899         arg_conv.is_owned = false;
68900         int64_t ret_conv = RawBolt11Invoice_clone_ptr(&arg_conv);
68901         return ret_conv;
68902 }
68903
68904 int64_t  CS_LDK_RawBolt11Invoice_clone(int64_t orig) {
68905         LDKRawBolt11Invoice orig_conv;
68906         orig_conv.inner = untag_ptr(orig);
68907         orig_conv.is_owned = ptr_is_owned(orig);
68908         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68909         orig_conv.is_owned = false;
68910         LDKRawBolt11Invoice ret_var = RawBolt11Invoice_clone(&orig_conv);
68911         int64_t ret_ref = 0;
68912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68914         return ret_ref;
68915 }
68916
68917 int64_t  CS_LDK_RawBolt11Invoice_hash(int64_t o) {
68918         LDKRawBolt11Invoice o_conv;
68919         o_conv.inner = untag_ptr(o);
68920         o_conv.is_owned = ptr_is_owned(o);
68921         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
68922         o_conv.is_owned = false;
68923         int64_t ret_conv = RawBolt11Invoice_hash(&o_conv);
68924         return ret_conv;
68925 }
68926
68927 void  CS_LDK_RawDataPart_free(int64_t this_obj) {
68928         LDKRawDataPart this_obj_conv;
68929         this_obj_conv.inner = untag_ptr(this_obj);
68930         this_obj_conv.is_owned = ptr_is_owned(this_obj);
68931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
68932         RawDataPart_free(this_obj_conv);
68933 }
68934
68935 int64_t  CS_LDK_RawDataPart_get_timestamp(int64_t this_ptr) {
68936         LDKRawDataPart this_ptr_conv;
68937         this_ptr_conv.inner = untag_ptr(this_ptr);
68938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68940         this_ptr_conv.is_owned = false;
68941         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
68942         int64_t ret_ref = 0;
68943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68944         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68945         return ret_ref;
68946 }
68947
68948 void  CS_LDK_RawDataPart_set_timestamp(int64_t this_ptr, int64_t val) {
68949         LDKRawDataPart this_ptr_conv;
68950         this_ptr_conv.inner = untag_ptr(this_ptr);
68951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
68952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
68953         this_ptr_conv.is_owned = false;
68954         LDKPositiveTimestamp val_conv;
68955         val_conv.inner = untag_ptr(val);
68956         val_conv.is_owned = ptr_is_owned(val);
68957         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
68958         val_conv = PositiveTimestamp_clone(&val_conv);
68959         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
68960 }
68961
68962 jboolean  CS_LDK_RawDataPart_eq(int64_t a, int64_t b) {
68963         LDKRawDataPart a_conv;
68964         a_conv.inner = untag_ptr(a);
68965         a_conv.is_owned = ptr_is_owned(a);
68966         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
68967         a_conv.is_owned = false;
68968         LDKRawDataPart b_conv;
68969         b_conv.inner = untag_ptr(b);
68970         b_conv.is_owned = ptr_is_owned(b);
68971         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
68972         b_conv.is_owned = false;
68973         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
68974         return ret_conv;
68975 }
68976
68977 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
68978         LDKRawDataPart ret_var = RawDataPart_clone(arg);
68979         int64_t ret_ref = 0;
68980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
68981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
68982         return ret_ref;
68983 }
68984 int64_t  CS_LDK_RawDataPart_clone_ptr(int64_t arg) {
68985         LDKRawDataPart arg_conv;
68986         arg_conv.inner = untag_ptr(arg);
68987         arg_conv.is_owned = ptr_is_owned(arg);
68988         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
68989         arg_conv.is_owned = false;
68990         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
68991         return ret_conv;
68992 }
68993
68994 int64_t  CS_LDK_RawDataPart_clone(int64_t orig) {
68995         LDKRawDataPart orig_conv;
68996         orig_conv.inner = untag_ptr(orig);
68997         orig_conv.is_owned = ptr_is_owned(orig);
68998         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
68999         orig_conv.is_owned = false;
69000         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
69001         int64_t ret_ref = 0;
69002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69004         return ret_ref;
69005 }
69006
69007 int64_t  CS_LDK_RawDataPart_hash(int64_t o) {
69008         LDKRawDataPart o_conv;
69009         o_conv.inner = untag_ptr(o);
69010         o_conv.is_owned = ptr_is_owned(o);
69011         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69012         o_conv.is_owned = false;
69013         int64_t ret_conv = RawDataPart_hash(&o_conv);
69014         return ret_conv;
69015 }
69016
69017 void  CS_LDK_PositiveTimestamp_free(int64_t this_obj) {
69018         LDKPositiveTimestamp this_obj_conv;
69019         this_obj_conv.inner = untag_ptr(this_obj);
69020         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69022         PositiveTimestamp_free(this_obj_conv);
69023 }
69024
69025 jboolean  CS_LDK_PositiveTimestamp_eq(int64_t a, int64_t b) {
69026         LDKPositiveTimestamp a_conv;
69027         a_conv.inner = untag_ptr(a);
69028         a_conv.is_owned = ptr_is_owned(a);
69029         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69030         a_conv.is_owned = false;
69031         LDKPositiveTimestamp b_conv;
69032         b_conv.inner = untag_ptr(b);
69033         b_conv.is_owned = ptr_is_owned(b);
69034         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69035         b_conv.is_owned = false;
69036         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
69037         return ret_conv;
69038 }
69039
69040 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
69041         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
69042         int64_t ret_ref = 0;
69043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69045         return ret_ref;
69046 }
69047 int64_t  CS_LDK_PositiveTimestamp_clone_ptr(int64_t arg) {
69048         LDKPositiveTimestamp arg_conv;
69049         arg_conv.inner = untag_ptr(arg);
69050         arg_conv.is_owned = ptr_is_owned(arg);
69051         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69052         arg_conv.is_owned = false;
69053         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
69054         return ret_conv;
69055 }
69056
69057 int64_t  CS_LDK_PositiveTimestamp_clone(int64_t orig) {
69058         LDKPositiveTimestamp orig_conv;
69059         orig_conv.inner = untag_ptr(orig);
69060         orig_conv.is_owned = ptr_is_owned(orig);
69061         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69062         orig_conv.is_owned = false;
69063         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
69064         int64_t ret_ref = 0;
69065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69067         return ret_ref;
69068 }
69069
69070 int64_t  CS_LDK_PositiveTimestamp_hash(int64_t o) {
69071         LDKPositiveTimestamp o_conv;
69072         o_conv.inner = untag_ptr(o);
69073         o_conv.is_owned = ptr_is_owned(o);
69074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69075         o_conv.is_owned = false;
69076         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
69077         return ret_conv;
69078 }
69079
69080 int32_t  CS_LDK_SiPrefix_clone(int64_t orig) {
69081         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
69082         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_clone(orig_conv));
69083         return ret_conv;
69084 }
69085
69086 int32_t  CS_LDK_SiPrefix_milli() {
69087         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_milli());
69088         return ret_conv;
69089 }
69090
69091 int32_t  CS_LDK_SiPrefix_micro() {
69092         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_micro());
69093         return ret_conv;
69094 }
69095
69096 int32_t  CS_LDK_SiPrefix_nano() {
69097         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_nano());
69098         return ret_conv;
69099 }
69100
69101 int32_t  CS_LDK_SiPrefix_pico() {
69102         int32_t ret_conv = LDKSiPrefix_to_cs(SiPrefix_pico());
69103         return ret_conv;
69104 }
69105
69106 jboolean  CS_LDK_SiPrefix_eq(int64_t a, int64_t b) {
69107         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
69108         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
69109         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
69110         return ret_conv;
69111 }
69112
69113 int64_t  CS_LDK_SiPrefix_hash(int64_t o) {
69114         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
69115         int64_t ret_conv = SiPrefix_hash(o_conv);
69116         return ret_conv;
69117 }
69118
69119 int64_t  CS_LDK_SiPrefix_multiplier(int64_t this_arg) {
69120         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
69121         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
69122         return ret_conv;
69123 }
69124
69125 int32_t  CS_LDK_Currency_clone(int64_t orig) {
69126         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
69127         int32_t ret_conv = LDKCurrency_to_cs(Currency_clone(orig_conv));
69128         return ret_conv;
69129 }
69130
69131 int32_t  CS_LDK_Currency_bitcoin() {
69132         int32_t ret_conv = LDKCurrency_to_cs(Currency_bitcoin());
69133         return ret_conv;
69134 }
69135
69136 int32_t  CS_LDK_Currency_bitcoin_testnet() {
69137         int32_t ret_conv = LDKCurrency_to_cs(Currency_bitcoin_testnet());
69138         return ret_conv;
69139 }
69140
69141 int32_t  CS_LDK_Currency_regtest() {
69142         int32_t ret_conv = LDKCurrency_to_cs(Currency_regtest());
69143         return ret_conv;
69144 }
69145
69146 int32_t  CS_LDK_Currency_simnet() {
69147         int32_t ret_conv = LDKCurrency_to_cs(Currency_simnet());
69148         return ret_conv;
69149 }
69150
69151 int32_t  CS_LDK_Currency_signet() {
69152         int32_t ret_conv = LDKCurrency_to_cs(Currency_signet());
69153         return ret_conv;
69154 }
69155
69156 int64_t  CS_LDK_Currency_hash(int64_t o) {
69157         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
69158         int64_t ret_conv = Currency_hash(o_conv);
69159         return ret_conv;
69160 }
69161
69162 jboolean  CS_LDK_Currency_eq(int64_t a, int64_t b) {
69163         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
69164         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
69165         jboolean ret_conv = Currency_eq(a_conv, b_conv);
69166         return ret_conv;
69167 }
69168
69169 void  CS_LDK_Sha256_free(int64_t this_obj) {
69170         LDKSha256 this_obj_conv;
69171         this_obj_conv.inner = untag_ptr(this_obj);
69172         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69174         Sha256_free(this_obj_conv);
69175 }
69176
69177 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
69178         LDKSha256 ret_var = Sha256_clone(arg);
69179         int64_t ret_ref = 0;
69180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69181         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69182         return ret_ref;
69183 }
69184 int64_t  CS_LDK_Sha256_clone_ptr(int64_t arg) {
69185         LDKSha256 arg_conv;
69186         arg_conv.inner = untag_ptr(arg);
69187         arg_conv.is_owned = ptr_is_owned(arg);
69188         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69189         arg_conv.is_owned = false;
69190         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
69191         return ret_conv;
69192 }
69193
69194 int64_t  CS_LDK_Sha256_clone(int64_t orig) {
69195         LDKSha256 orig_conv;
69196         orig_conv.inner = untag_ptr(orig);
69197         orig_conv.is_owned = ptr_is_owned(orig);
69198         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69199         orig_conv.is_owned = false;
69200         LDKSha256 ret_var = Sha256_clone(&orig_conv);
69201         int64_t ret_ref = 0;
69202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69203         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69204         return ret_ref;
69205 }
69206
69207 int64_t  CS_LDK_Sha256_hash(int64_t o) {
69208         LDKSha256 o_conv;
69209         o_conv.inner = untag_ptr(o);
69210         o_conv.is_owned = ptr_is_owned(o);
69211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69212         o_conv.is_owned = false;
69213         int64_t ret_conv = Sha256_hash(&o_conv);
69214         return ret_conv;
69215 }
69216
69217 jboolean  CS_LDK_Sha256_eq(int64_t a, int64_t b) {
69218         LDKSha256 a_conv;
69219         a_conv.inner = untag_ptr(a);
69220         a_conv.is_owned = ptr_is_owned(a);
69221         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69222         a_conv.is_owned = false;
69223         LDKSha256 b_conv;
69224         b_conv.inner = untag_ptr(b);
69225         b_conv.is_owned = ptr_is_owned(b);
69226         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69227         b_conv.is_owned = false;
69228         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
69229         return ret_conv;
69230 }
69231
69232 int64_t  CS_LDK_Sha256_from_bytes(int8_tArray bytes) {
69233         uint8_t bytes_arr[32];
69234         CHECK(bytes->arr_len == 32);
69235         memcpy(bytes_arr, bytes->elems, 32); FREE(bytes);
69236         uint8_t (*bytes_ref)[32] = &bytes_arr;
69237         LDKSha256 ret_var = Sha256_from_bytes(bytes_ref);
69238         int64_t ret_ref = 0;
69239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69241         return ret_ref;
69242 }
69243
69244 void  CS_LDK_Description_free(int64_t this_obj) {
69245         LDKDescription this_obj_conv;
69246         this_obj_conv.inner = untag_ptr(this_obj);
69247         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69249         Description_free(this_obj_conv);
69250 }
69251
69252 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
69253         LDKDescription ret_var = Description_clone(arg);
69254         int64_t ret_ref = 0;
69255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69257         return ret_ref;
69258 }
69259 int64_t  CS_LDK_Description_clone_ptr(int64_t arg) {
69260         LDKDescription arg_conv;
69261         arg_conv.inner = untag_ptr(arg);
69262         arg_conv.is_owned = ptr_is_owned(arg);
69263         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69264         arg_conv.is_owned = false;
69265         int64_t ret_conv = Description_clone_ptr(&arg_conv);
69266         return ret_conv;
69267 }
69268
69269 int64_t  CS_LDK_Description_clone(int64_t orig) {
69270         LDKDescription orig_conv;
69271         orig_conv.inner = untag_ptr(orig);
69272         orig_conv.is_owned = ptr_is_owned(orig);
69273         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69274         orig_conv.is_owned = false;
69275         LDKDescription ret_var = Description_clone(&orig_conv);
69276         int64_t ret_ref = 0;
69277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69278         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69279         return ret_ref;
69280 }
69281
69282 int64_t  CS_LDK_Description_hash(int64_t o) {
69283         LDKDescription o_conv;
69284         o_conv.inner = untag_ptr(o);
69285         o_conv.is_owned = ptr_is_owned(o);
69286         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69287         o_conv.is_owned = false;
69288         int64_t ret_conv = Description_hash(&o_conv);
69289         return ret_conv;
69290 }
69291
69292 jboolean  CS_LDK_Description_eq(int64_t a, int64_t b) {
69293         LDKDescription a_conv;
69294         a_conv.inner = untag_ptr(a);
69295         a_conv.is_owned = ptr_is_owned(a);
69296         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69297         a_conv.is_owned = false;
69298         LDKDescription b_conv;
69299         b_conv.inner = untag_ptr(b);
69300         b_conv.is_owned = ptr_is_owned(b);
69301         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69302         b_conv.is_owned = false;
69303         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
69304         return ret_conv;
69305 }
69306
69307 void  CS_LDK_PayeePubKey_free(int64_t this_obj) {
69308         LDKPayeePubKey this_obj_conv;
69309         this_obj_conv.inner = untag_ptr(this_obj);
69310         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69312         PayeePubKey_free(this_obj_conv);
69313 }
69314
69315 int8_tArray  CS_LDK_PayeePubKey_get_a(int64_t this_ptr) {
69316         LDKPayeePubKey this_ptr_conv;
69317         this_ptr_conv.inner = untag_ptr(this_ptr);
69318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69320         this_ptr_conv.is_owned = false;
69321         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
69322         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
69323         return ret_arr;
69324 }
69325
69326 void  CS_LDK_PayeePubKey_set_a(int64_t this_ptr, int8_tArray val) {
69327         LDKPayeePubKey this_ptr_conv;
69328         this_ptr_conv.inner = untag_ptr(this_ptr);
69329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69331         this_ptr_conv.is_owned = false;
69332         LDKPublicKey val_ref;
69333         CHECK(val->arr_len == 33);
69334         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
69335         PayeePubKey_set_a(&this_ptr_conv, val_ref);
69336 }
69337
69338 int64_t  CS_LDK_PayeePubKey_new(int8_tArray a_arg) {
69339         LDKPublicKey a_arg_ref;
69340         CHECK(a_arg->arr_len == 33);
69341         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
69342         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
69343         int64_t ret_ref = 0;
69344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69346         return ret_ref;
69347 }
69348
69349 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
69350         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
69351         int64_t ret_ref = 0;
69352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69353         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69354         return ret_ref;
69355 }
69356 int64_t  CS_LDK_PayeePubKey_clone_ptr(int64_t arg) {
69357         LDKPayeePubKey arg_conv;
69358         arg_conv.inner = untag_ptr(arg);
69359         arg_conv.is_owned = ptr_is_owned(arg);
69360         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69361         arg_conv.is_owned = false;
69362         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
69363         return ret_conv;
69364 }
69365
69366 int64_t  CS_LDK_PayeePubKey_clone(int64_t orig) {
69367         LDKPayeePubKey orig_conv;
69368         orig_conv.inner = untag_ptr(orig);
69369         orig_conv.is_owned = ptr_is_owned(orig);
69370         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69371         orig_conv.is_owned = false;
69372         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
69373         int64_t ret_ref = 0;
69374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69375         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69376         return ret_ref;
69377 }
69378
69379 int64_t  CS_LDK_PayeePubKey_hash(int64_t o) {
69380         LDKPayeePubKey o_conv;
69381         o_conv.inner = untag_ptr(o);
69382         o_conv.is_owned = ptr_is_owned(o);
69383         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69384         o_conv.is_owned = false;
69385         int64_t ret_conv = PayeePubKey_hash(&o_conv);
69386         return ret_conv;
69387 }
69388
69389 jboolean  CS_LDK_PayeePubKey_eq(int64_t a, int64_t b) {
69390         LDKPayeePubKey a_conv;
69391         a_conv.inner = untag_ptr(a);
69392         a_conv.is_owned = ptr_is_owned(a);
69393         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69394         a_conv.is_owned = false;
69395         LDKPayeePubKey b_conv;
69396         b_conv.inner = untag_ptr(b);
69397         b_conv.is_owned = ptr_is_owned(b);
69398         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69399         b_conv.is_owned = false;
69400         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
69401         return ret_conv;
69402 }
69403
69404 void  CS_LDK_ExpiryTime_free(int64_t this_obj) {
69405         LDKExpiryTime this_obj_conv;
69406         this_obj_conv.inner = untag_ptr(this_obj);
69407         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69409         ExpiryTime_free(this_obj_conv);
69410 }
69411
69412 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
69413         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
69414         int64_t ret_ref = 0;
69415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69417         return ret_ref;
69418 }
69419 int64_t  CS_LDK_ExpiryTime_clone_ptr(int64_t arg) {
69420         LDKExpiryTime arg_conv;
69421         arg_conv.inner = untag_ptr(arg);
69422         arg_conv.is_owned = ptr_is_owned(arg);
69423         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69424         arg_conv.is_owned = false;
69425         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
69426         return ret_conv;
69427 }
69428
69429 int64_t  CS_LDK_ExpiryTime_clone(int64_t orig) {
69430         LDKExpiryTime orig_conv;
69431         orig_conv.inner = untag_ptr(orig);
69432         orig_conv.is_owned = ptr_is_owned(orig);
69433         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69434         orig_conv.is_owned = false;
69435         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
69436         int64_t ret_ref = 0;
69437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69439         return ret_ref;
69440 }
69441
69442 int64_t  CS_LDK_ExpiryTime_hash(int64_t o) {
69443         LDKExpiryTime o_conv;
69444         o_conv.inner = untag_ptr(o);
69445         o_conv.is_owned = ptr_is_owned(o);
69446         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69447         o_conv.is_owned = false;
69448         int64_t ret_conv = ExpiryTime_hash(&o_conv);
69449         return ret_conv;
69450 }
69451
69452 jboolean  CS_LDK_ExpiryTime_eq(int64_t a, int64_t b) {
69453         LDKExpiryTime a_conv;
69454         a_conv.inner = untag_ptr(a);
69455         a_conv.is_owned = ptr_is_owned(a);
69456         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69457         a_conv.is_owned = false;
69458         LDKExpiryTime b_conv;
69459         b_conv.inner = untag_ptr(b);
69460         b_conv.is_owned = ptr_is_owned(b);
69461         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69462         b_conv.is_owned = false;
69463         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
69464         return ret_conv;
69465 }
69466
69467 void  CS_LDK_MinFinalCltvExpiryDelta_free(int64_t this_obj) {
69468         LDKMinFinalCltvExpiryDelta this_obj_conv;
69469         this_obj_conv.inner = untag_ptr(this_obj);
69470         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69472         MinFinalCltvExpiryDelta_free(this_obj_conv);
69473 }
69474
69475 int64_t  CS_LDK_MinFinalCltvExpiryDelta_get_a(int64_t this_ptr) {
69476         LDKMinFinalCltvExpiryDelta this_ptr_conv;
69477         this_ptr_conv.inner = untag_ptr(this_ptr);
69478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69480         this_ptr_conv.is_owned = false;
69481         int64_t ret_conv = MinFinalCltvExpiryDelta_get_a(&this_ptr_conv);
69482         return ret_conv;
69483 }
69484
69485 void  CS_LDK_MinFinalCltvExpiryDelta_set_a(int64_t this_ptr, int64_t val) {
69486         LDKMinFinalCltvExpiryDelta this_ptr_conv;
69487         this_ptr_conv.inner = untag_ptr(this_ptr);
69488         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
69489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
69490         this_ptr_conv.is_owned = false;
69491         MinFinalCltvExpiryDelta_set_a(&this_ptr_conv, val);
69492 }
69493
69494 int64_t  CS_LDK_MinFinalCltvExpiryDelta_new(int64_t a_arg) {
69495         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_new(a_arg);
69496         int64_t ret_ref = 0;
69497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69499         return ret_ref;
69500 }
69501
69502 static inline uint64_t MinFinalCltvExpiryDelta_clone_ptr(LDKMinFinalCltvExpiryDelta *NONNULL_PTR arg) {
69503         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(arg);
69504         int64_t ret_ref = 0;
69505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69507         return ret_ref;
69508 }
69509 int64_t  CS_LDK_MinFinalCltvExpiryDelta_clone_ptr(int64_t arg) {
69510         LDKMinFinalCltvExpiryDelta arg_conv;
69511         arg_conv.inner = untag_ptr(arg);
69512         arg_conv.is_owned = ptr_is_owned(arg);
69513         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69514         arg_conv.is_owned = false;
69515         int64_t ret_conv = MinFinalCltvExpiryDelta_clone_ptr(&arg_conv);
69516         return ret_conv;
69517 }
69518
69519 int64_t  CS_LDK_MinFinalCltvExpiryDelta_clone(int64_t orig) {
69520         LDKMinFinalCltvExpiryDelta orig_conv;
69521         orig_conv.inner = untag_ptr(orig);
69522         orig_conv.is_owned = ptr_is_owned(orig);
69523         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69524         orig_conv.is_owned = false;
69525         LDKMinFinalCltvExpiryDelta ret_var = MinFinalCltvExpiryDelta_clone(&orig_conv);
69526         int64_t ret_ref = 0;
69527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69529         return ret_ref;
69530 }
69531
69532 int64_t  CS_LDK_MinFinalCltvExpiryDelta_hash(int64_t o) {
69533         LDKMinFinalCltvExpiryDelta o_conv;
69534         o_conv.inner = untag_ptr(o);
69535         o_conv.is_owned = ptr_is_owned(o);
69536         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69537         o_conv.is_owned = false;
69538         int64_t ret_conv = MinFinalCltvExpiryDelta_hash(&o_conv);
69539         return ret_conv;
69540 }
69541
69542 jboolean  CS_LDK_MinFinalCltvExpiryDelta_eq(int64_t a, int64_t b) {
69543         LDKMinFinalCltvExpiryDelta a_conv;
69544         a_conv.inner = untag_ptr(a);
69545         a_conv.is_owned = ptr_is_owned(a);
69546         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69547         a_conv.is_owned = false;
69548         LDKMinFinalCltvExpiryDelta b_conv;
69549         b_conv.inner = untag_ptr(b);
69550         b_conv.is_owned = ptr_is_owned(b);
69551         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69552         b_conv.is_owned = false;
69553         jboolean ret_conv = MinFinalCltvExpiryDelta_eq(&a_conv, &b_conv);
69554         return ret_conv;
69555 }
69556
69557 void  CS_LDK_Fallback_free(int64_t this_ptr) {
69558         if (!ptr_is_owned(this_ptr)) return;
69559         void* this_ptr_ptr = untag_ptr(this_ptr);
69560         CHECK_ACCESS(this_ptr_ptr);
69561         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
69562         FREE(untag_ptr(this_ptr));
69563         Fallback_free(this_ptr_conv);
69564 }
69565
69566 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
69567         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69568         *ret_copy = Fallback_clone(arg);
69569         int64_t ret_ref = tag_ptr(ret_copy, true);
69570         return ret_ref;
69571 }
69572 int64_t  CS_LDK_Fallback_clone_ptr(int64_t arg) {
69573         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
69574         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
69575         return ret_conv;
69576 }
69577
69578 int64_t  CS_LDK_Fallback_clone(int64_t orig) {
69579         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
69580         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69581         *ret_copy = Fallback_clone(orig_conv);
69582         int64_t ret_ref = tag_ptr(ret_copy, true);
69583         return ret_ref;
69584 }
69585
69586 int64_t  CS_LDK_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
69587         
69588         LDKCVec_u8Z program_ref;
69589         program_ref.datalen = program->arr_len;
69590         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
69591         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
69592         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69593         *ret_copy = Fallback_seg_wit_program((LDKWitnessVersion){ ._0 = version }, program_ref);
69594         int64_t ret_ref = tag_ptr(ret_copy, true);
69595         return ret_ref;
69596 }
69597
69598 int64_t  CS_LDK_Fallback_pub_key_hash(int8_tArray a) {
69599         LDKTwentyBytes a_ref;
69600         CHECK(a->arr_len == 20);
69601         memcpy(a_ref.data, a->elems, 20); FREE(a);
69602         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69603         *ret_copy = Fallback_pub_key_hash(a_ref);
69604         int64_t ret_ref = tag_ptr(ret_copy, true);
69605         return ret_ref;
69606 }
69607
69608 int64_t  CS_LDK_Fallback_script_hash(int8_tArray a) {
69609         LDKTwentyBytes a_ref;
69610         CHECK(a->arr_len == 20);
69611         memcpy(a_ref.data, a->elems, 20); FREE(a);
69612         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
69613         *ret_copy = Fallback_script_hash(a_ref);
69614         int64_t ret_ref = tag_ptr(ret_copy, true);
69615         return ret_ref;
69616 }
69617
69618 int64_t  CS_LDK_Fallback_hash(int64_t o) {
69619         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
69620         int64_t ret_conv = Fallback_hash(o_conv);
69621         return ret_conv;
69622 }
69623
69624 jboolean  CS_LDK_Fallback_eq(int64_t a, int64_t b) {
69625         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
69626         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
69627         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
69628         return ret_conv;
69629 }
69630
69631 void  CS_LDK_Bolt11InvoiceSignature_free(int64_t this_obj) {
69632         LDKBolt11InvoiceSignature this_obj_conv;
69633         this_obj_conv.inner = untag_ptr(this_obj);
69634         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69636         Bolt11InvoiceSignature_free(this_obj_conv);
69637 }
69638
69639 static inline uint64_t Bolt11InvoiceSignature_clone_ptr(LDKBolt11InvoiceSignature *NONNULL_PTR arg) {
69640         LDKBolt11InvoiceSignature ret_var = Bolt11InvoiceSignature_clone(arg);
69641         int64_t ret_ref = 0;
69642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69643         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69644         return ret_ref;
69645 }
69646 int64_t  CS_LDK_Bolt11InvoiceSignature_clone_ptr(int64_t arg) {
69647         LDKBolt11InvoiceSignature arg_conv;
69648         arg_conv.inner = untag_ptr(arg);
69649         arg_conv.is_owned = ptr_is_owned(arg);
69650         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69651         arg_conv.is_owned = false;
69652         int64_t ret_conv = Bolt11InvoiceSignature_clone_ptr(&arg_conv);
69653         return ret_conv;
69654 }
69655
69656 int64_t  CS_LDK_Bolt11InvoiceSignature_clone(int64_t orig) {
69657         LDKBolt11InvoiceSignature orig_conv;
69658         orig_conv.inner = untag_ptr(orig);
69659         orig_conv.is_owned = ptr_is_owned(orig);
69660         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69661         orig_conv.is_owned = false;
69662         LDKBolt11InvoiceSignature ret_var = Bolt11InvoiceSignature_clone(&orig_conv);
69663         int64_t ret_ref = 0;
69664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69666         return ret_ref;
69667 }
69668
69669 int64_t  CS_LDK_Bolt11InvoiceSignature_hash(int64_t o) {
69670         LDKBolt11InvoiceSignature o_conv;
69671         o_conv.inner = untag_ptr(o);
69672         o_conv.is_owned = ptr_is_owned(o);
69673         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69674         o_conv.is_owned = false;
69675         int64_t ret_conv = Bolt11InvoiceSignature_hash(&o_conv);
69676         return ret_conv;
69677 }
69678
69679 jboolean  CS_LDK_Bolt11InvoiceSignature_eq(int64_t a, int64_t b) {
69680         LDKBolt11InvoiceSignature a_conv;
69681         a_conv.inner = untag_ptr(a);
69682         a_conv.is_owned = ptr_is_owned(a);
69683         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69684         a_conv.is_owned = false;
69685         LDKBolt11InvoiceSignature b_conv;
69686         b_conv.inner = untag_ptr(b);
69687         b_conv.is_owned = ptr_is_owned(b);
69688         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69689         b_conv.is_owned = false;
69690         jboolean ret_conv = Bolt11InvoiceSignature_eq(&a_conv, &b_conv);
69691         return ret_conv;
69692 }
69693
69694 void  CS_LDK_PrivateRoute_free(int64_t this_obj) {
69695         LDKPrivateRoute this_obj_conv;
69696         this_obj_conv.inner = untag_ptr(this_obj);
69697         this_obj_conv.is_owned = ptr_is_owned(this_obj);
69698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
69699         PrivateRoute_free(this_obj_conv);
69700 }
69701
69702 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
69703         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
69704         int64_t ret_ref = 0;
69705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69707         return ret_ref;
69708 }
69709 int64_t  CS_LDK_PrivateRoute_clone_ptr(int64_t arg) {
69710         LDKPrivateRoute arg_conv;
69711         arg_conv.inner = untag_ptr(arg);
69712         arg_conv.is_owned = ptr_is_owned(arg);
69713         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
69714         arg_conv.is_owned = false;
69715         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
69716         return ret_conv;
69717 }
69718
69719 int64_t  CS_LDK_PrivateRoute_clone(int64_t orig) {
69720         LDKPrivateRoute orig_conv;
69721         orig_conv.inner = untag_ptr(orig);
69722         orig_conv.is_owned = ptr_is_owned(orig);
69723         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
69724         orig_conv.is_owned = false;
69725         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
69726         int64_t ret_ref = 0;
69727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69729         return ret_ref;
69730 }
69731
69732 int64_t  CS_LDK_PrivateRoute_hash(int64_t o) {
69733         LDKPrivateRoute o_conv;
69734         o_conv.inner = untag_ptr(o);
69735         o_conv.is_owned = ptr_is_owned(o);
69736         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
69737         o_conv.is_owned = false;
69738         int64_t ret_conv = PrivateRoute_hash(&o_conv);
69739         return ret_conv;
69740 }
69741
69742 jboolean  CS_LDK_PrivateRoute_eq(int64_t a, int64_t b) {
69743         LDKPrivateRoute a_conv;
69744         a_conv.inner = untag_ptr(a);
69745         a_conv.is_owned = ptr_is_owned(a);
69746         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
69747         a_conv.is_owned = false;
69748         LDKPrivateRoute b_conv;
69749         b_conv.inner = untag_ptr(b);
69750         b_conv.is_owned = ptr_is_owned(b);
69751         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
69752         b_conv.is_owned = false;
69753         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
69754         return ret_conv;
69755 }
69756
69757 int64_t  CS_LDK_SignedRawBolt11Invoice_into_parts(int64_t this_arg) {
69758         LDKSignedRawBolt11Invoice this_arg_conv;
69759         this_arg_conv.inner = untag_ptr(this_arg);
69760         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69762         this_arg_conv = SignedRawBolt11Invoice_clone(&this_arg_conv);
69763         LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ), "LDKC3Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ");
69764         *ret_conv = SignedRawBolt11Invoice_into_parts(this_arg_conv);
69765         return tag_ptr(ret_conv, true);
69766 }
69767
69768 int64_t  CS_LDK_SignedRawBolt11Invoice_raw_invoice(int64_t this_arg) {
69769         LDKSignedRawBolt11Invoice this_arg_conv;
69770         this_arg_conv.inner = untag_ptr(this_arg);
69771         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69773         this_arg_conv.is_owned = false;
69774         LDKRawBolt11Invoice ret_var = SignedRawBolt11Invoice_raw_invoice(&this_arg_conv);
69775         int64_t ret_ref = 0;
69776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69778         return ret_ref;
69779 }
69780
69781 int8_tArray  CS_LDK_SignedRawBolt11Invoice_signable_hash(int64_t this_arg) {
69782         LDKSignedRawBolt11Invoice this_arg_conv;
69783         this_arg_conv.inner = untag_ptr(this_arg);
69784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69786         this_arg_conv.is_owned = false;
69787         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
69788         memcpy(ret_arr->elems, *SignedRawBolt11Invoice_signable_hash(&this_arg_conv), 32);
69789         return ret_arr;
69790 }
69791
69792 int64_t  CS_LDK_SignedRawBolt11Invoice_signature(int64_t this_arg) {
69793         LDKSignedRawBolt11Invoice this_arg_conv;
69794         this_arg_conv.inner = untag_ptr(this_arg);
69795         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69797         this_arg_conv.is_owned = false;
69798         LDKBolt11InvoiceSignature ret_var = SignedRawBolt11Invoice_signature(&this_arg_conv);
69799         int64_t ret_ref = 0;
69800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69802         return ret_ref;
69803 }
69804
69805 int64_t  CS_LDK_SignedRawBolt11Invoice_recover_payee_pub_key(int64_t this_arg) {
69806         LDKSignedRawBolt11Invoice this_arg_conv;
69807         this_arg_conv.inner = untag_ptr(this_arg);
69808         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69810         this_arg_conv.is_owned = false;
69811         LDKCResult_PayeePubKeySecp256k1ErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeySecp256k1ErrorZ), "LDKCResult_PayeePubKeySecp256k1ErrorZ");
69812         *ret_conv = SignedRawBolt11Invoice_recover_payee_pub_key(&this_arg_conv);
69813         return tag_ptr(ret_conv, true);
69814 }
69815
69816 jboolean  CS_LDK_SignedRawBolt11Invoice_check_signature(int64_t this_arg) {
69817         LDKSignedRawBolt11Invoice this_arg_conv;
69818         this_arg_conv.inner = untag_ptr(this_arg);
69819         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69821         this_arg_conv.is_owned = false;
69822         jboolean ret_conv = SignedRawBolt11Invoice_check_signature(&this_arg_conv);
69823         return ret_conv;
69824 }
69825
69826 int8_tArray  CS_LDK_RawBolt11Invoice_signable_hash(int64_t this_arg) {
69827         LDKRawBolt11Invoice this_arg_conv;
69828         this_arg_conv.inner = untag_ptr(this_arg);
69829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69831         this_arg_conv.is_owned = false;
69832         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
69833         memcpy(ret_arr->elems, RawBolt11Invoice_signable_hash(&this_arg_conv).data, 32);
69834         return ret_arr;
69835 }
69836
69837 int64_t  CS_LDK_RawBolt11Invoice_payment_hash(int64_t this_arg) {
69838         LDKRawBolt11Invoice this_arg_conv;
69839         this_arg_conv.inner = untag_ptr(this_arg);
69840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69842         this_arg_conv.is_owned = false;
69843         LDKSha256 ret_var = RawBolt11Invoice_payment_hash(&this_arg_conv);
69844         int64_t ret_ref = 0;
69845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69847         return ret_ref;
69848 }
69849
69850 int64_t  CS_LDK_RawBolt11Invoice_description(int64_t this_arg) {
69851         LDKRawBolt11Invoice this_arg_conv;
69852         this_arg_conv.inner = untag_ptr(this_arg);
69853         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69855         this_arg_conv.is_owned = false;
69856         LDKDescription ret_var = RawBolt11Invoice_description(&this_arg_conv);
69857         int64_t ret_ref = 0;
69858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69860         return ret_ref;
69861 }
69862
69863 int64_t  CS_LDK_RawBolt11Invoice_payee_pub_key(int64_t this_arg) {
69864         LDKRawBolt11Invoice this_arg_conv;
69865         this_arg_conv.inner = untag_ptr(this_arg);
69866         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69868         this_arg_conv.is_owned = false;
69869         LDKPayeePubKey ret_var = RawBolt11Invoice_payee_pub_key(&this_arg_conv);
69870         int64_t ret_ref = 0;
69871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69872         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69873         return ret_ref;
69874 }
69875
69876 int64_t  CS_LDK_RawBolt11Invoice_description_hash(int64_t this_arg) {
69877         LDKRawBolt11Invoice this_arg_conv;
69878         this_arg_conv.inner = untag_ptr(this_arg);
69879         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69881         this_arg_conv.is_owned = false;
69882         LDKSha256 ret_var = RawBolt11Invoice_description_hash(&this_arg_conv);
69883         int64_t ret_ref = 0;
69884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69885         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69886         return ret_ref;
69887 }
69888
69889 int64_t  CS_LDK_RawBolt11Invoice_expiry_time(int64_t this_arg) {
69890         LDKRawBolt11Invoice this_arg_conv;
69891         this_arg_conv.inner = untag_ptr(this_arg);
69892         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69894         this_arg_conv.is_owned = false;
69895         LDKExpiryTime ret_var = RawBolt11Invoice_expiry_time(&this_arg_conv);
69896         int64_t ret_ref = 0;
69897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69899         return ret_ref;
69900 }
69901
69902 int64_t  CS_LDK_RawBolt11Invoice_min_final_cltv_expiry_delta(int64_t this_arg) {
69903         LDKRawBolt11Invoice this_arg_conv;
69904         this_arg_conv.inner = untag_ptr(this_arg);
69905         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69907         this_arg_conv.is_owned = false;
69908         LDKMinFinalCltvExpiryDelta ret_var = RawBolt11Invoice_min_final_cltv_expiry_delta(&this_arg_conv);
69909         int64_t ret_ref = 0;
69910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69911         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69912         return ret_ref;
69913 }
69914
69915 int64_t  CS_LDK_RawBolt11Invoice_payment_secret(int64_t this_arg) {
69916         LDKRawBolt11Invoice this_arg_conv;
69917         this_arg_conv.inner = untag_ptr(this_arg);
69918         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69920         this_arg_conv.is_owned = false;
69921         LDKCOption_ThirtyTwoBytesZ *ret_copy = MALLOC(sizeof(LDKCOption_ThirtyTwoBytesZ), "LDKCOption_ThirtyTwoBytesZ");
69922         *ret_copy = RawBolt11Invoice_payment_secret(&this_arg_conv);
69923         int64_t ret_ref = tag_ptr(ret_copy, true);
69924         return ret_ref;
69925 }
69926
69927 int64_t  CS_LDK_RawBolt11Invoice_payment_metadata(int64_t this_arg) {
69928         LDKRawBolt11Invoice this_arg_conv;
69929         this_arg_conv.inner = untag_ptr(this_arg);
69930         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69932         this_arg_conv.is_owned = false;
69933         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
69934         *ret_copy = RawBolt11Invoice_payment_metadata(&this_arg_conv);
69935         int64_t ret_ref = tag_ptr(ret_copy, true);
69936         return ret_ref;
69937 }
69938
69939 int64_t  CS_LDK_RawBolt11Invoice_features(int64_t this_arg) {
69940         LDKRawBolt11Invoice this_arg_conv;
69941         this_arg_conv.inner = untag_ptr(this_arg);
69942         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69944         this_arg_conv.is_owned = false;
69945         LDKBolt11InvoiceFeatures ret_var = RawBolt11Invoice_features(&this_arg_conv);
69946         int64_t ret_ref = 0;
69947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
69948         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
69949         return ret_ref;
69950 }
69951
69952 int64_tArray  CS_LDK_RawBolt11Invoice_private_routes(int64_t this_arg) {
69953         LDKRawBolt11Invoice this_arg_conv;
69954         this_arg_conv.inner = untag_ptr(this_arg);
69955         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69957         this_arg_conv.is_owned = false;
69958         LDKCVec_PrivateRouteZ ret_var = RawBolt11Invoice_private_routes(&this_arg_conv);
69959         int64_tArray ret_arr = NULL;
69960         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
69961         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
69962         for (size_t o = 0; o < ret_var.datalen; o++) {
69963                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
69964                 int64_t ret_conv_14_ref = 0;
69965                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
69966                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
69967                 ret_arr_ptr[o] = ret_conv_14_ref;
69968         }
69969         
69970         FREE(ret_var.data);
69971         return ret_arr;
69972 }
69973
69974 int64_t  CS_LDK_RawBolt11Invoice_amount_pico_btc(int64_t this_arg) {
69975         LDKRawBolt11Invoice this_arg_conv;
69976         this_arg_conv.inner = untag_ptr(this_arg);
69977         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69979         this_arg_conv.is_owned = false;
69980         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
69981         *ret_copy = RawBolt11Invoice_amount_pico_btc(&this_arg_conv);
69982         int64_t ret_ref = tag_ptr(ret_copy, true);
69983         return ret_ref;
69984 }
69985
69986 int32_t  CS_LDK_RawBolt11Invoice_currency(int64_t this_arg) {
69987         LDKRawBolt11Invoice this_arg_conv;
69988         this_arg_conv.inner = untag_ptr(this_arg);
69989         this_arg_conv.is_owned = ptr_is_owned(this_arg);
69990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
69991         this_arg_conv.is_owned = false;
69992         int32_t ret_conv = LDKCurrency_to_cs(RawBolt11Invoice_currency(&this_arg_conv));
69993         return ret_conv;
69994 }
69995
69996 int64_t  CS_LDK_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
69997         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
69998         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
69999         return tag_ptr(ret_conv, true);
70000 }
70001
70002 int64_t  CS_LDK_PositiveTimestamp_from_system_time(int64_t time) {
70003         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
70004         *ret_conv = PositiveTimestamp_from_system_time(time);
70005         return tag_ptr(ret_conv, true);
70006 }
70007
70008 int64_t  CS_LDK_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
70009         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
70010         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
70011         return tag_ptr(ret_conv, true);
70012 }
70013
70014 int64_t  CS_LDK_PositiveTimestamp_as_unix_timestamp(int64_t this_arg) {
70015         LDKPositiveTimestamp this_arg_conv;
70016         this_arg_conv.inner = untag_ptr(this_arg);
70017         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70019         this_arg_conv.is_owned = false;
70020         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
70021         return ret_conv;
70022 }
70023
70024 int64_t  CS_LDK_PositiveTimestamp_as_duration_since_epoch(int64_t this_arg) {
70025         LDKPositiveTimestamp this_arg_conv;
70026         this_arg_conv.inner = untag_ptr(this_arg);
70027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70029         this_arg_conv.is_owned = false;
70030         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
70031         return ret_conv;
70032 }
70033
70034 int64_t  CS_LDK_PositiveTimestamp_as_time(int64_t this_arg) {
70035         LDKPositiveTimestamp this_arg_conv;
70036         this_arg_conv.inner = untag_ptr(this_arg);
70037         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70039         this_arg_conv.is_owned = false;
70040         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
70041         return ret_conv;
70042 }
70043
70044 int8_tArray  CS_LDK_Bolt11Invoice_signable_hash(int64_t this_arg) {
70045         LDKBolt11Invoice this_arg_conv;
70046         this_arg_conv.inner = untag_ptr(this_arg);
70047         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70049         this_arg_conv.is_owned = false;
70050         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
70051         memcpy(ret_arr->elems, Bolt11Invoice_signable_hash(&this_arg_conv).data, 32);
70052         return ret_arr;
70053 }
70054
70055 int64_t  CS_LDK_Bolt11Invoice_into_signed_raw(int64_t this_arg) {
70056         LDKBolt11Invoice this_arg_conv;
70057         this_arg_conv.inner = untag_ptr(this_arg);
70058         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70060         this_arg_conv = Bolt11Invoice_clone(&this_arg_conv);
70061         LDKSignedRawBolt11Invoice ret_var = Bolt11Invoice_into_signed_raw(this_arg_conv);
70062         int64_t ret_ref = 0;
70063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70065         return ret_ref;
70066 }
70067
70068 int64_t  CS_LDK_Bolt11Invoice_check_signature(int64_t this_arg) {
70069         LDKBolt11Invoice this_arg_conv;
70070         this_arg_conv.inner = untag_ptr(this_arg);
70071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70073         this_arg_conv.is_owned = false;
70074         LDKCResult_NoneBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneBolt11SemanticErrorZ), "LDKCResult_NoneBolt11SemanticErrorZ");
70075         *ret_conv = Bolt11Invoice_check_signature(&this_arg_conv);
70076         return tag_ptr(ret_conv, true);
70077 }
70078
70079 int64_t  CS_LDK_Bolt11Invoice_from_signed(int64_t signed_invoice) {
70080         LDKSignedRawBolt11Invoice signed_invoice_conv;
70081         signed_invoice_conv.inner = untag_ptr(signed_invoice);
70082         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
70083         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
70084         signed_invoice_conv = SignedRawBolt11Invoice_clone(&signed_invoice_conv);
70085         LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ), "LDKCResult_Bolt11InvoiceBolt11SemanticErrorZ");
70086         *ret_conv = Bolt11Invoice_from_signed(signed_invoice_conv);
70087         return tag_ptr(ret_conv, true);
70088 }
70089
70090 int64_t  CS_LDK_Bolt11Invoice_timestamp(int64_t this_arg) {
70091         LDKBolt11Invoice this_arg_conv;
70092         this_arg_conv.inner = untag_ptr(this_arg);
70093         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70095         this_arg_conv.is_owned = false;
70096         int64_t ret_conv = Bolt11Invoice_timestamp(&this_arg_conv);
70097         return ret_conv;
70098 }
70099
70100 int64_t  CS_LDK_Bolt11Invoice_duration_since_epoch(int64_t this_arg) {
70101         LDKBolt11Invoice this_arg_conv;
70102         this_arg_conv.inner = untag_ptr(this_arg);
70103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70105         this_arg_conv.is_owned = false;
70106         int64_t ret_conv = Bolt11Invoice_duration_since_epoch(&this_arg_conv);
70107         return ret_conv;
70108 }
70109
70110 int8_tArray  CS_LDK_Bolt11Invoice_payment_hash(int64_t this_arg) {
70111         LDKBolt11Invoice this_arg_conv;
70112         this_arg_conv.inner = untag_ptr(this_arg);
70113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70115         this_arg_conv.is_owned = false;
70116         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
70117         memcpy(ret_arr->elems, *Bolt11Invoice_payment_hash(&this_arg_conv), 32);
70118         return ret_arr;
70119 }
70120
70121 int8_tArray  CS_LDK_Bolt11Invoice_payee_pub_key(int64_t this_arg) {
70122         LDKBolt11Invoice this_arg_conv;
70123         this_arg_conv.inner = untag_ptr(this_arg);
70124         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70126         this_arg_conv.is_owned = false;
70127         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
70128         memcpy(ret_arr->elems, Bolt11Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
70129         return ret_arr;
70130 }
70131
70132 int8_tArray  CS_LDK_Bolt11Invoice_payment_secret(int64_t this_arg) {
70133         LDKBolt11Invoice this_arg_conv;
70134         this_arg_conv.inner = untag_ptr(this_arg);
70135         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70137         this_arg_conv.is_owned = false;
70138         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
70139         memcpy(ret_arr->elems, *Bolt11Invoice_payment_secret(&this_arg_conv), 32);
70140         return ret_arr;
70141 }
70142
70143 int64_t  CS_LDK_Bolt11Invoice_payment_metadata(int64_t this_arg) {
70144         LDKBolt11Invoice this_arg_conv;
70145         this_arg_conv.inner = untag_ptr(this_arg);
70146         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70148         this_arg_conv.is_owned = false;
70149         LDKCOption_CVec_u8ZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_u8ZZ), "LDKCOption_CVec_u8ZZ");
70150         *ret_copy = Bolt11Invoice_payment_metadata(&this_arg_conv);
70151         int64_t ret_ref = tag_ptr(ret_copy, true);
70152         return ret_ref;
70153 }
70154
70155 int64_t  CS_LDK_Bolt11Invoice_features(int64_t this_arg) {
70156         LDKBolt11Invoice this_arg_conv;
70157         this_arg_conv.inner = untag_ptr(this_arg);
70158         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70160         this_arg_conv.is_owned = false;
70161         LDKBolt11InvoiceFeatures ret_var = Bolt11Invoice_features(&this_arg_conv);
70162         int64_t ret_ref = 0;
70163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70165         return ret_ref;
70166 }
70167
70168 int8_tArray  CS_LDK_Bolt11Invoice_recover_payee_pub_key(int64_t this_arg) {
70169         LDKBolt11Invoice this_arg_conv;
70170         this_arg_conv.inner = untag_ptr(this_arg);
70171         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70173         this_arg_conv.is_owned = false;
70174         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
70175         memcpy(ret_arr->elems, Bolt11Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
70176         return ret_arr;
70177 }
70178
70179 int64_t  CS_LDK_Bolt11Invoice_expires_at(int64_t this_arg) {
70180         LDKBolt11Invoice this_arg_conv;
70181         this_arg_conv.inner = untag_ptr(this_arg);
70182         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70184         this_arg_conv.is_owned = false;
70185         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
70186         *ret_copy = Bolt11Invoice_expires_at(&this_arg_conv);
70187         int64_t ret_ref = tag_ptr(ret_copy, true);
70188         return ret_ref;
70189 }
70190
70191 int64_t  CS_LDK_Bolt11Invoice_expiry_time(int64_t this_arg) {
70192         LDKBolt11Invoice this_arg_conv;
70193         this_arg_conv.inner = untag_ptr(this_arg);
70194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70196         this_arg_conv.is_owned = false;
70197         int64_t ret_conv = Bolt11Invoice_expiry_time(&this_arg_conv);
70198         return ret_conv;
70199 }
70200
70201 jboolean  CS_LDK_Bolt11Invoice_is_expired(int64_t this_arg) {
70202         LDKBolt11Invoice this_arg_conv;
70203         this_arg_conv.inner = untag_ptr(this_arg);
70204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70206         this_arg_conv.is_owned = false;
70207         jboolean ret_conv = Bolt11Invoice_is_expired(&this_arg_conv);
70208         return ret_conv;
70209 }
70210
70211 int64_t  CS_LDK_Bolt11Invoice_duration_until_expiry(int64_t this_arg) {
70212         LDKBolt11Invoice this_arg_conv;
70213         this_arg_conv.inner = untag_ptr(this_arg);
70214         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70216         this_arg_conv.is_owned = false;
70217         int64_t ret_conv = Bolt11Invoice_duration_until_expiry(&this_arg_conv);
70218         return ret_conv;
70219 }
70220
70221 int64_t  CS_LDK_Bolt11Invoice_expiration_remaining_from_epoch(int64_t this_arg, int64_t time) {
70222         LDKBolt11Invoice this_arg_conv;
70223         this_arg_conv.inner = untag_ptr(this_arg);
70224         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70226         this_arg_conv.is_owned = false;
70227         int64_t ret_conv = Bolt11Invoice_expiration_remaining_from_epoch(&this_arg_conv, time);
70228         return ret_conv;
70229 }
70230
70231 jboolean  CS_LDK_Bolt11Invoice_would_expire(int64_t this_arg, int64_t at_time) {
70232         LDKBolt11Invoice this_arg_conv;
70233         this_arg_conv.inner = untag_ptr(this_arg);
70234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70236         this_arg_conv.is_owned = false;
70237         jboolean ret_conv = Bolt11Invoice_would_expire(&this_arg_conv, at_time);
70238         return ret_conv;
70239 }
70240
70241 int64_t  CS_LDK_Bolt11Invoice_min_final_cltv_expiry_delta(int64_t this_arg) {
70242         LDKBolt11Invoice this_arg_conv;
70243         this_arg_conv.inner = untag_ptr(this_arg);
70244         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70246         this_arg_conv.is_owned = false;
70247         int64_t ret_conv = Bolt11Invoice_min_final_cltv_expiry_delta(&this_arg_conv);
70248         return ret_conv;
70249 }
70250
70251 ptrArray  CS_LDK_Bolt11Invoice_fallback_addresses(int64_t this_arg) {
70252         LDKBolt11Invoice this_arg_conv;
70253         this_arg_conv.inner = untag_ptr(this_arg);
70254         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70256         this_arg_conv.is_owned = false;
70257         LDKCVec_StrZ ret_var = Bolt11Invoice_fallback_addresses(&this_arg_conv);
70258         ptrArray ret_arr = NULL;
70259         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
70260         jstring *ret_arr_ptr = (jstring*)(((uint8_t*)ret_arr) + 8);
70261         for (size_t i = 0; i < ret_var.datalen; i++) {
70262                 LDKStr ret_conv_8_str = ret_var.data[i];
70263                 jstring ret_conv_8_conv = str_ref_to_cs(ret_conv_8_str.chars, ret_conv_8_str.len);
70264                 Str_free(ret_conv_8_str);
70265                 ret_arr_ptr[i] = ret_conv_8_conv;
70266         }
70267         
70268         FREE(ret_var.data);
70269         return ret_arr;
70270 }
70271
70272 int64_tArray  CS_LDK_Bolt11Invoice_private_routes(int64_t this_arg) {
70273         LDKBolt11Invoice this_arg_conv;
70274         this_arg_conv.inner = untag_ptr(this_arg);
70275         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70277         this_arg_conv.is_owned = false;
70278         LDKCVec_PrivateRouteZ ret_var = Bolt11Invoice_private_routes(&this_arg_conv);
70279         int64_tArray ret_arr = NULL;
70280         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
70281         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
70282         for (size_t o = 0; o < ret_var.datalen; o++) {
70283                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
70284                 int64_t ret_conv_14_ref = 0;
70285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
70286                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
70287                 ret_arr_ptr[o] = ret_conv_14_ref;
70288         }
70289         
70290         FREE(ret_var.data);
70291         return ret_arr;
70292 }
70293
70294 int64_tArray  CS_LDK_Bolt11Invoice_route_hints(int64_t this_arg) {
70295         LDKBolt11Invoice this_arg_conv;
70296         this_arg_conv.inner = untag_ptr(this_arg);
70297         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70299         this_arg_conv.is_owned = false;
70300         LDKCVec_RouteHintZ ret_var = Bolt11Invoice_route_hints(&this_arg_conv);
70301         int64_tArray ret_arr = NULL;
70302         ret_arr = init_int64_tArray(ret_var.datalen, __LINE__);
70303         int64_t *ret_arr_ptr = (int64_t*)(((uint8_t*)ret_arr) + 8);
70304         for (size_t l = 0; l < ret_var.datalen; l++) {
70305                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
70306                 int64_t ret_conv_11_ref = 0;
70307                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
70308                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
70309                 ret_arr_ptr[l] = ret_conv_11_ref;
70310         }
70311         
70312         FREE(ret_var.data);
70313         return ret_arr;
70314 }
70315
70316 int32_t  CS_LDK_Bolt11Invoice_currency(int64_t this_arg) {
70317         LDKBolt11Invoice this_arg_conv;
70318         this_arg_conv.inner = untag_ptr(this_arg);
70319         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70321         this_arg_conv.is_owned = false;
70322         int32_t ret_conv = LDKCurrency_to_cs(Bolt11Invoice_currency(&this_arg_conv));
70323         return ret_conv;
70324 }
70325
70326 int64_t  CS_LDK_Bolt11Invoice_amount_milli_satoshis(int64_t this_arg) {
70327         LDKBolt11Invoice this_arg_conv;
70328         this_arg_conv.inner = untag_ptr(this_arg);
70329         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70331         this_arg_conv.is_owned = false;
70332         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
70333         *ret_copy = Bolt11Invoice_amount_milli_satoshis(&this_arg_conv);
70334         int64_t ret_ref = tag_ptr(ret_copy, true);
70335         return ret_ref;
70336 }
70337
70338 int64_t  CS_LDK_Description_new(jstring description) {
70339         LDKStr description_conv = str_ref_to_owned_c(description);
70340         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
70341         *ret_conv = Description_new(description_conv);
70342         return tag_ptr(ret_conv, true);
70343 }
70344
70345 jstring  CS_LDK_Description_into_inner(int64_t this_arg) {
70346         LDKDescription this_arg_conv;
70347         this_arg_conv.inner = untag_ptr(this_arg);
70348         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70350         this_arg_conv = Description_clone(&this_arg_conv);
70351         LDKStr ret_str = Description_into_inner(this_arg_conv);
70352         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70353         Str_free(ret_str);
70354         return ret_conv;
70355 }
70356
70357 int64_t  CS_LDK_ExpiryTime_from_seconds(int64_t seconds) {
70358         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
70359         int64_t ret_ref = 0;
70360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70362         return ret_ref;
70363 }
70364
70365 int64_t  CS_LDK_ExpiryTime_from_duration(int64_t duration) {
70366         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
70367         int64_t ret_ref = 0;
70368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70370         return ret_ref;
70371 }
70372
70373 int64_t  CS_LDK_ExpiryTime_as_seconds(int64_t this_arg) {
70374         LDKExpiryTime this_arg_conv;
70375         this_arg_conv.inner = untag_ptr(this_arg);
70376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70378         this_arg_conv.is_owned = false;
70379         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
70380         return ret_conv;
70381 }
70382
70383 int64_t  CS_LDK_ExpiryTime_as_duration(int64_t this_arg) {
70384         LDKExpiryTime this_arg_conv;
70385         this_arg_conv.inner = untag_ptr(this_arg);
70386         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70388         this_arg_conv.is_owned = false;
70389         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
70390         return ret_conv;
70391 }
70392
70393 int64_t  CS_LDK_PrivateRoute_new(int64_t hops) {
70394         LDKRouteHint hops_conv;
70395         hops_conv.inner = untag_ptr(hops);
70396         hops_conv.is_owned = ptr_is_owned(hops);
70397         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
70398         hops_conv = RouteHint_clone(&hops_conv);
70399         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
70400         *ret_conv = PrivateRoute_new(hops_conv);
70401         return tag_ptr(ret_conv, true);
70402 }
70403
70404 int64_t  CS_LDK_PrivateRoute_into_inner(int64_t this_arg) {
70405         LDKPrivateRoute this_arg_conv;
70406         this_arg_conv.inner = untag_ptr(this_arg);
70407         this_arg_conv.is_owned = ptr_is_owned(this_arg);
70408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
70409         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
70410         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
70411         int64_t ret_ref = 0;
70412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
70413         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
70414         return ret_ref;
70415 }
70416
70417 int32_t  CS_LDK_CreationError_clone(int64_t orig) {
70418         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
70419         int32_t ret_conv = LDKCreationError_to_cs(CreationError_clone(orig_conv));
70420         return ret_conv;
70421 }
70422
70423 int32_t  CS_LDK_CreationError_description_too_long() {
70424         int32_t ret_conv = LDKCreationError_to_cs(CreationError_description_too_long());
70425         return ret_conv;
70426 }
70427
70428 int32_t  CS_LDK_CreationError_route_too_long() {
70429         int32_t ret_conv = LDKCreationError_to_cs(CreationError_route_too_long());
70430         return ret_conv;
70431 }
70432
70433 int32_t  CS_LDK_CreationError_timestamp_out_of_bounds() {
70434         int32_t ret_conv = LDKCreationError_to_cs(CreationError_timestamp_out_of_bounds());
70435         return ret_conv;
70436 }
70437
70438 int32_t  CS_LDK_CreationError_invalid_amount() {
70439         int32_t ret_conv = LDKCreationError_to_cs(CreationError_invalid_amount());
70440         return ret_conv;
70441 }
70442
70443 int32_t  CS_LDK_CreationError_missing_route_hints() {
70444         int32_t ret_conv = LDKCreationError_to_cs(CreationError_missing_route_hints());
70445         return ret_conv;
70446 }
70447
70448 int32_t  CS_LDK_CreationError_min_final_cltv_expiry_delta_too_short() {
70449         int32_t ret_conv = LDKCreationError_to_cs(CreationError_min_final_cltv_expiry_delta_too_short());
70450         return ret_conv;
70451 }
70452
70453 jboolean  CS_LDK_CreationError_eq(int64_t a, int64_t b) {
70454         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
70455         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
70456         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
70457         return ret_conv;
70458 }
70459
70460 jstring  CS_LDK_CreationError_to_str(int64_t o) {
70461         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
70462         LDKStr ret_str = CreationError_to_str(o_conv);
70463         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70464         Str_free(ret_str);
70465         return ret_conv;
70466 }
70467
70468 int32_t  CS_LDK_Bolt11SemanticError_clone(int64_t orig) {
70469         LDKBolt11SemanticError* orig_conv = (LDKBolt11SemanticError*)untag_ptr(orig);
70470         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_clone(orig_conv));
70471         return ret_conv;
70472 }
70473
70474 int32_t  CS_LDK_Bolt11SemanticError_no_payment_hash() {
70475         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_no_payment_hash());
70476         return ret_conv;
70477 }
70478
70479 int32_t  CS_LDK_Bolt11SemanticError_multiple_payment_hashes() {
70480         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_multiple_payment_hashes());
70481         return ret_conv;
70482 }
70483
70484 int32_t  CS_LDK_Bolt11SemanticError_no_description() {
70485         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_no_description());
70486         return ret_conv;
70487 }
70488
70489 int32_t  CS_LDK_Bolt11SemanticError_multiple_descriptions() {
70490         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_multiple_descriptions());
70491         return ret_conv;
70492 }
70493
70494 int32_t  CS_LDK_Bolt11SemanticError_no_payment_secret() {
70495         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_no_payment_secret());
70496         return ret_conv;
70497 }
70498
70499 int32_t  CS_LDK_Bolt11SemanticError_multiple_payment_secrets() {
70500         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_multiple_payment_secrets());
70501         return ret_conv;
70502 }
70503
70504 int32_t  CS_LDK_Bolt11SemanticError_invalid_features() {
70505         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_invalid_features());
70506         return ret_conv;
70507 }
70508
70509 int32_t  CS_LDK_Bolt11SemanticError_invalid_recovery_id() {
70510         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_invalid_recovery_id());
70511         return ret_conv;
70512 }
70513
70514 int32_t  CS_LDK_Bolt11SemanticError_invalid_signature() {
70515         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_invalid_signature());
70516         return ret_conv;
70517 }
70518
70519 int32_t  CS_LDK_Bolt11SemanticError_imprecise_amount() {
70520         int32_t ret_conv = LDKBolt11SemanticError_to_cs(Bolt11SemanticError_imprecise_amount());
70521         return ret_conv;
70522 }
70523
70524 jboolean  CS_LDK_Bolt11SemanticError_eq(int64_t a, int64_t b) {
70525         LDKBolt11SemanticError* a_conv = (LDKBolt11SemanticError*)untag_ptr(a);
70526         LDKBolt11SemanticError* b_conv = (LDKBolt11SemanticError*)untag_ptr(b);
70527         jboolean ret_conv = Bolt11SemanticError_eq(a_conv, b_conv);
70528         return ret_conv;
70529 }
70530
70531 jstring  CS_LDK_Bolt11SemanticError_to_str(int64_t o) {
70532         LDKBolt11SemanticError* o_conv = (LDKBolt11SemanticError*)untag_ptr(o);
70533         LDKStr ret_str = Bolt11SemanticError_to_str(o_conv);
70534         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70535         Str_free(ret_str);
70536         return ret_conv;
70537 }
70538
70539 void  CS_LDK_SignOrCreationError_free(int64_t this_ptr) {
70540         if (!ptr_is_owned(this_ptr)) return;
70541         void* this_ptr_ptr = untag_ptr(this_ptr);
70542         CHECK_ACCESS(this_ptr_ptr);
70543         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
70544         FREE(untag_ptr(this_ptr));
70545         SignOrCreationError_free(this_ptr_conv);
70546 }
70547
70548 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
70549         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70550         *ret_copy = SignOrCreationError_clone(arg);
70551         int64_t ret_ref = tag_ptr(ret_copy, true);
70552         return ret_ref;
70553 }
70554 int64_t  CS_LDK_SignOrCreationError_clone_ptr(int64_t arg) {
70555         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
70556         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
70557         return ret_conv;
70558 }
70559
70560 int64_t  CS_LDK_SignOrCreationError_clone(int64_t orig) {
70561         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
70562         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70563         *ret_copy = SignOrCreationError_clone(orig_conv);
70564         int64_t ret_ref = tag_ptr(ret_copy, true);
70565         return ret_ref;
70566 }
70567
70568 int64_t  CS_LDK_SignOrCreationError_sign_error() {
70569         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70570         *ret_copy = SignOrCreationError_sign_error();
70571         int64_t ret_ref = tag_ptr(ret_copy, true);
70572         return ret_ref;
70573 }
70574
70575 int64_t  CS_LDK_SignOrCreationError_creation_error(int32_t a) {
70576         LDKCreationError a_conv = LDKCreationError_from_cs(a);
70577         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
70578         *ret_copy = SignOrCreationError_creation_error(a_conv);
70579         int64_t ret_ref = tag_ptr(ret_copy, true);
70580         return ret_ref;
70581 }
70582
70583 jboolean  CS_LDK_SignOrCreationError_eq(int64_t a, int64_t b) {
70584         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
70585         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
70586         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
70587         return ret_conv;
70588 }
70589
70590 jstring  CS_LDK_SignOrCreationError_to_str(int64_t o) {
70591         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
70592         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
70593         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
70594         Str_free(ret_str);
70595         return ret_conv;
70596 }
70597
70598 int64_t  CS_LDK_pay_invoice(int64_t invoice, int64_t retry_strategy, int64_t channelmanager) {
70599         LDKBolt11Invoice invoice_conv;
70600         invoice_conv.inner = untag_ptr(invoice);
70601         invoice_conv.is_owned = ptr_is_owned(invoice);
70602         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70603         invoice_conv.is_owned = false;
70604         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70605         CHECK_ACCESS(retry_strategy_ptr);
70606         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70607         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70608         LDKChannelManager channelmanager_conv;
70609         channelmanager_conv.inner = untag_ptr(channelmanager);
70610         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70611         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70612         channelmanager_conv.is_owned = false;
70613         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
70614         *ret_conv = pay_invoice(&invoice_conv, retry_strategy_conv, &channelmanager_conv);
70615         return tag_ptr(ret_conv, true);
70616 }
70617
70618 int64_t  CS_LDK_pay_invoice_with_id(int64_t invoice, int8_tArray payment_id, int64_t retry_strategy, int64_t channelmanager) {
70619         LDKBolt11Invoice invoice_conv;
70620         invoice_conv.inner = untag_ptr(invoice);
70621         invoice_conv.is_owned = ptr_is_owned(invoice);
70622         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70623         invoice_conv.is_owned = false;
70624         LDKThirtyTwoBytes payment_id_ref;
70625         CHECK(payment_id->arr_len == 32);
70626         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
70627         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70628         CHECK_ACCESS(retry_strategy_ptr);
70629         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70630         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70631         LDKChannelManager channelmanager_conv;
70632         channelmanager_conv.inner = untag_ptr(channelmanager);
70633         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70634         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70635         channelmanager_conv.is_owned = false;
70636         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
70637         *ret_conv = pay_invoice_with_id(&invoice_conv, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
70638         return tag_ptr(ret_conv, true);
70639 }
70640
70641 int64_t  CS_LDK_pay_zero_value_invoice(int64_t invoice, int64_t amount_msats, int64_t retry_strategy, int64_t channelmanager) {
70642         LDKBolt11Invoice invoice_conv;
70643         invoice_conv.inner = untag_ptr(invoice);
70644         invoice_conv.is_owned = ptr_is_owned(invoice);
70645         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70646         invoice_conv.is_owned = false;
70647         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70648         CHECK_ACCESS(retry_strategy_ptr);
70649         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70650         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70651         LDKChannelManager channelmanager_conv;
70652         channelmanager_conv.inner = untag_ptr(channelmanager);
70653         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70654         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70655         channelmanager_conv.is_owned = false;
70656         LDKCResult_ThirtyTwoBytesPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ThirtyTwoBytesPaymentErrorZ), "LDKCResult_ThirtyTwoBytesPaymentErrorZ");
70657         *ret_conv = pay_zero_value_invoice(&invoice_conv, amount_msats, retry_strategy_conv, &channelmanager_conv);
70658         return tag_ptr(ret_conv, true);
70659 }
70660
70661 int64_t  CS_LDK_pay_zero_value_invoice_with_id(int64_t invoice, int64_t amount_msats, int8_tArray payment_id, int64_t retry_strategy, int64_t channelmanager) {
70662         LDKBolt11Invoice invoice_conv;
70663         invoice_conv.inner = untag_ptr(invoice);
70664         invoice_conv.is_owned = ptr_is_owned(invoice);
70665         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70666         invoice_conv.is_owned = false;
70667         LDKThirtyTwoBytes payment_id_ref;
70668         CHECK(payment_id->arr_len == 32);
70669         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
70670         void* retry_strategy_ptr = untag_ptr(retry_strategy);
70671         CHECK_ACCESS(retry_strategy_ptr);
70672         LDKRetry retry_strategy_conv = *(LDKRetry*)(retry_strategy_ptr);
70673         retry_strategy_conv = Retry_clone((LDKRetry*)untag_ptr(retry_strategy));
70674         LDKChannelManager channelmanager_conv;
70675         channelmanager_conv.inner = untag_ptr(channelmanager);
70676         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70677         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70678         channelmanager_conv.is_owned = false;
70679         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
70680         *ret_conv = pay_zero_value_invoice_with_id(&invoice_conv, amount_msats, payment_id_ref, retry_strategy_conv, &channelmanager_conv);
70681         return tag_ptr(ret_conv, true);
70682 }
70683
70684 int64_t  CS_LDK_preflight_probe_invoice(int64_t invoice, int64_t channelmanager, int64_t liquidity_limit_multiplier) {
70685         LDKBolt11Invoice invoice_conv;
70686         invoice_conv.inner = untag_ptr(invoice);
70687         invoice_conv.is_owned = ptr_is_owned(invoice);
70688         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70689         invoice_conv.is_owned = false;
70690         LDKChannelManager channelmanager_conv;
70691         channelmanager_conv.inner = untag_ptr(channelmanager);
70692         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70693         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70694         channelmanager_conv.is_owned = false;
70695         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
70696         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
70697         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
70698         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
70699         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
70700         *ret_conv = preflight_probe_invoice(&invoice_conv, &channelmanager_conv, liquidity_limit_multiplier_conv);
70701         return tag_ptr(ret_conv, true);
70702 }
70703
70704 int64_t  CS_LDK_preflight_probe_zero_value_invoice(int64_t invoice, int64_t amount_msat, int64_t channelmanager, int64_t liquidity_limit_multiplier) {
70705         LDKBolt11Invoice invoice_conv;
70706         invoice_conv.inner = untag_ptr(invoice);
70707         invoice_conv.is_owned = ptr_is_owned(invoice);
70708         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
70709         invoice_conv.is_owned = false;
70710         LDKChannelManager channelmanager_conv;
70711         channelmanager_conv.inner = untag_ptr(channelmanager);
70712         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70713         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70714         channelmanager_conv.is_owned = false;
70715         void* liquidity_limit_multiplier_ptr = untag_ptr(liquidity_limit_multiplier);
70716         CHECK_ACCESS(liquidity_limit_multiplier_ptr);
70717         LDKCOption_u64Z liquidity_limit_multiplier_conv = *(LDKCOption_u64Z*)(liquidity_limit_multiplier_ptr);
70718         liquidity_limit_multiplier_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(liquidity_limit_multiplier));
70719         LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ), "LDKCResult_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbingErrorZ");
70720         *ret_conv = preflight_probe_zero_value_invoice(&invoice_conv, amount_msat, &channelmanager_conv, liquidity_limit_multiplier_conv);
70721         return tag_ptr(ret_conv, true);
70722 }
70723
70724 void  CS_LDK_PaymentError_free(int64_t this_ptr) {
70725         if (!ptr_is_owned(this_ptr)) return;
70726         void* this_ptr_ptr = untag_ptr(this_ptr);
70727         CHECK_ACCESS(this_ptr_ptr);
70728         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
70729         FREE(untag_ptr(this_ptr));
70730         PaymentError_free(this_ptr_conv);
70731 }
70732
70733 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
70734         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70735         *ret_copy = PaymentError_clone(arg);
70736         int64_t ret_ref = tag_ptr(ret_copy, true);
70737         return ret_ref;
70738 }
70739 int64_t  CS_LDK_PaymentError_clone_ptr(int64_t arg) {
70740         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
70741         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
70742         return ret_conv;
70743 }
70744
70745 int64_t  CS_LDK_PaymentError_clone(int64_t orig) {
70746         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
70747         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70748         *ret_copy = PaymentError_clone(orig_conv);
70749         int64_t ret_ref = tag_ptr(ret_copy, true);
70750         return ret_ref;
70751 }
70752
70753 int64_t  CS_LDK_PaymentError_invoice(jstring a) {
70754         LDKStr a_conv = str_ref_to_owned_c(a);
70755         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70756         *ret_copy = PaymentError_invoice(a_conv);
70757         int64_t ret_ref = tag_ptr(ret_copy, true);
70758         return ret_ref;
70759 }
70760
70761 int64_t  CS_LDK_PaymentError_sending(int32_t a) {
70762         LDKRetryableSendFailure a_conv = LDKRetryableSendFailure_from_cs(a);
70763         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
70764         *ret_copy = PaymentError_sending(a_conv);
70765         int64_t ret_ref = tag_ptr(ret_copy, true);
70766         return ret_ref;
70767 }
70768
70769 jboolean  CS_LDK_PaymentError_eq(int64_t a, int64_t b) {
70770         LDKPaymentError* a_conv = (LDKPaymentError*)untag_ptr(a);
70771         LDKPaymentError* b_conv = (LDKPaymentError*)untag_ptr(b);
70772         jboolean ret_conv = PaymentError_eq(a_conv, b_conv);
70773         return ret_conv;
70774 }
70775
70776 void  CS_LDK_ProbingError_free(int64_t this_ptr) {
70777         if (!ptr_is_owned(this_ptr)) return;
70778         void* this_ptr_ptr = untag_ptr(this_ptr);
70779         CHECK_ACCESS(this_ptr_ptr);
70780         LDKProbingError this_ptr_conv = *(LDKProbingError*)(this_ptr_ptr);
70781         FREE(untag_ptr(this_ptr));
70782         ProbingError_free(this_ptr_conv);
70783 }
70784
70785 static inline uint64_t ProbingError_clone_ptr(LDKProbingError *NONNULL_PTR arg) {
70786         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70787         *ret_copy = ProbingError_clone(arg);
70788         int64_t ret_ref = tag_ptr(ret_copy, true);
70789         return ret_ref;
70790 }
70791 int64_t  CS_LDK_ProbingError_clone_ptr(int64_t arg) {
70792         LDKProbingError* arg_conv = (LDKProbingError*)untag_ptr(arg);
70793         int64_t ret_conv = ProbingError_clone_ptr(arg_conv);
70794         return ret_conv;
70795 }
70796
70797 int64_t  CS_LDK_ProbingError_clone(int64_t orig) {
70798         LDKProbingError* orig_conv = (LDKProbingError*)untag_ptr(orig);
70799         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70800         *ret_copy = ProbingError_clone(orig_conv);
70801         int64_t ret_ref = tag_ptr(ret_copy, true);
70802         return ret_ref;
70803 }
70804
70805 int64_t  CS_LDK_ProbingError_invoice(jstring a) {
70806         LDKStr a_conv = str_ref_to_owned_c(a);
70807         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70808         *ret_copy = ProbingError_invoice(a_conv);
70809         int64_t ret_ref = tag_ptr(ret_copy, true);
70810         return ret_ref;
70811 }
70812
70813 int64_t  CS_LDK_ProbingError_sending(int64_t a) {
70814         void* a_ptr = untag_ptr(a);
70815         CHECK_ACCESS(a_ptr);
70816         LDKProbeSendFailure a_conv = *(LDKProbeSendFailure*)(a_ptr);
70817         a_conv = ProbeSendFailure_clone((LDKProbeSendFailure*)untag_ptr(a));
70818         LDKProbingError *ret_copy = MALLOC(sizeof(LDKProbingError), "LDKProbingError");
70819         *ret_copy = ProbingError_sending(a_conv);
70820         int64_t ret_ref = tag_ptr(ret_copy, true);
70821         return ret_ref;
70822 }
70823
70824 jboolean  CS_LDK_ProbingError_eq(int64_t a, int64_t b) {
70825         LDKProbingError* a_conv = (LDKProbingError*)untag_ptr(a);
70826         LDKProbingError* b_conv = (LDKProbingError*)untag_ptr(b);
70827         jboolean ret_conv = ProbingError_eq(a_conv, b_conv);
70828         return ret_conv;
70829 }
70830
70831 int64_t  CS_LDK_create_phantom_invoice(int64_t amt_msat, int64_t payment_hash, jstring description, int32_t invoice_expiry_delta_secs, int64_tArray phantom_route_hints, int64_t entropy_source, int64_t node_signer, int64_t logger, int32_t network, int64_t min_final_cltv_expiry_delta, int64_t duration_since_epoch) {
70832         void* amt_msat_ptr = untag_ptr(amt_msat);
70833         CHECK_ACCESS(amt_msat_ptr);
70834         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
70835         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
70836         void* payment_hash_ptr = untag_ptr(payment_hash);
70837         CHECK_ACCESS(payment_hash_ptr);
70838         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
70839         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
70840         LDKStr description_conv = str_ref_to_owned_c(description);
70841         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
70842         phantom_route_hints_constr.datalen = phantom_route_hints->arr_len;
70843         if (phantom_route_hints_constr.datalen > 0)
70844                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
70845         else
70846                 phantom_route_hints_constr.data = NULL;
70847         int64_t* phantom_route_hints_vals = phantom_route_hints->elems;
70848         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
70849                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
70850                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
70851                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
70852                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
70853                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
70854                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
70855                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
70856         }
70857         FREE(phantom_route_hints);
70858         void* entropy_source_ptr = untag_ptr(entropy_source);
70859         CHECK_ACCESS(entropy_source_ptr);
70860         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
70861         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
70862                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70863                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
70864         }
70865         void* node_signer_ptr = untag_ptr(node_signer);
70866         CHECK_ACCESS(node_signer_ptr);
70867         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70868         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
70869                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70870                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
70871         }
70872         void* logger_ptr = untag_ptr(logger);
70873         CHECK_ACCESS(logger_ptr);
70874         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
70875         if (logger_conv.free == LDKLogger_JCalls_free) {
70876                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70877                 LDKLogger_JCalls_cloned(&logger_conv);
70878         }
70879         LDKCurrency network_conv = LDKCurrency_from_cs(network);
70880         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
70881         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
70882         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
70883         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
70884         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
70885         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_conv, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, entropy_source_conv, node_signer_conv, logger_conv, network_conv, min_final_cltv_expiry_delta_conv, duration_since_epoch);
70886         return tag_ptr(ret_conv, true);
70887 }
70888
70889 int64_t  CS_LDK_create_phantom_invoice_with_description_hash(int64_t amt_msat, int64_t payment_hash, int32_t invoice_expiry_delta_secs, int64_t description_hash, int64_tArray phantom_route_hints, int64_t entropy_source, int64_t node_signer, int64_t logger, int32_t network, int64_t min_final_cltv_expiry_delta, int64_t duration_since_epoch) {
70890         void* amt_msat_ptr = untag_ptr(amt_msat);
70891         CHECK_ACCESS(amt_msat_ptr);
70892         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
70893         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
70894         void* payment_hash_ptr = untag_ptr(payment_hash);
70895         CHECK_ACCESS(payment_hash_ptr);
70896         LDKCOption_ThirtyTwoBytesZ payment_hash_conv = *(LDKCOption_ThirtyTwoBytesZ*)(payment_hash_ptr);
70897         payment_hash_conv = COption_ThirtyTwoBytesZ_clone((LDKCOption_ThirtyTwoBytesZ*)untag_ptr(payment_hash));
70898         LDKSha256 description_hash_conv;
70899         description_hash_conv.inner = untag_ptr(description_hash);
70900         description_hash_conv.is_owned = ptr_is_owned(description_hash);
70901         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
70902         description_hash_conv = Sha256_clone(&description_hash_conv);
70903         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
70904         phantom_route_hints_constr.datalen = phantom_route_hints->arr_len;
70905         if (phantom_route_hints_constr.datalen > 0)
70906                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
70907         else
70908                 phantom_route_hints_constr.data = NULL;
70909         int64_t* phantom_route_hints_vals = phantom_route_hints->elems;
70910         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
70911                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
70912                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
70913                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
70914                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
70915                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
70916                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
70917                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
70918         }
70919         FREE(phantom_route_hints);
70920         void* entropy_source_ptr = untag_ptr(entropy_source);
70921         CHECK_ACCESS(entropy_source_ptr);
70922         LDKEntropySource entropy_source_conv = *(LDKEntropySource*)(entropy_source_ptr);
70923         if (entropy_source_conv.free == LDKEntropySource_JCalls_free) {
70924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70925                 LDKEntropySource_JCalls_cloned(&entropy_source_conv);
70926         }
70927         void* node_signer_ptr = untag_ptr(node_signer);
70928         CHECK_ACCESS(node_signer_ptr);
70929         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70930         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
70931                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70932                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
70933         }
70934         void* logger_ptr = untag_ptr(logger);
70935         CHECK_ACCESS(logger_ptr);
70936         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
70937         if (logger_conv.free == LDKLogger_JCalls_free) {
70938                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70939                 LDKLogger_JCalls_cloned(&logger_conv);
70940         }
70941         LDKCurrency network_conv = LDKCurrency_from_cs(network);
70942         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
70943         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
70944         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
70945         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
70946         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
70947         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, payment_hash_conv, invoice_expiry_delta_secs, description_hash_conv, phantom_route_hints_constr, entropy_source_conv, node_signer_conv, logger_conv, network_conv, min_final_cltv_expiry_delta_conv, duration_since_epoch);
70948         return tag_ptr(ret_conv, true);
70949 }
70950
70951 int64_t  CS_LDK_create_invoice_from_channelmanager(int64_t channelmanager, int64_t node_signer, int64_t logger, int32_t network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
70952         LDKChannelManager channelmanager_conv;
70953         channelmanager_conv.inner = untag_ptr(channelmanager);
70954         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70955         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70956         channelmanager_conv.is_owned = false;
70957         void* node_signer_ptr = untag_ptr(node_signer);
70958         CHECK_ACCESS(node_signer_ptr);
70959         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70960         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
70961                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70962                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
70963         }
70964         void* logger_ptr = untag_ptr(logger);
70965         CHECK_ACCESS(logger_ptr);
70966         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
70967         if (logger_conv.free == LDKLogger_JCalls_free) {
70968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70969                 LDKLogger_JCalls_cloned(&logger_conv);
70970         }
70971         LDKCurrency network_conv = LDKCurrency_from_cs(network);
70972         void* amt_msat_ptr = untag_ptr(amt_msat);
70973         CHECK_ACCESS(amt_msat_ptr);
70974         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
70975         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
70976         LDKStr description_conv = str_ref_to_owned_c(description);
70977         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
70978         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
70979         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
70980         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
70981         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
70982         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
70983         return tag_ptr(ret_conv, true);
70984 }
70985
70986 int64_t  CS_LDK_create_invoice_from_channelmanager_with_description_hash(int64_t channelmanager, int64_t node_signer, int64_t logger, int32_t network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
70987         LDKChannelManager channelmanager_conv;
70988         channelmanager_conv.inner = untag_ptr(channelmanager);
70989         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
70990         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
70991         channelmanager_conv.is_owned = false;
70992         void* node_signer_ptr = untag_ptr(node_signer);
70993         CHECK_ACCESS(node_signer_ptr);
70994         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
70995         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
70996                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
70997                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
70998         }
70999         void* logger_ptr = untag_ptr(logger);
71000         CHECK_ACCESS(logger_ptr);
71001         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71002         if (logger_conv.free == LDKLogger_JCalls_free) {
71003                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71004                 LDKLogger_JCalls_cloned(&logger_conv);
71005         }
71006         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71007         void* amt_msat_ptr = untag_ptr(amt_msat);
71008         CHECK_ACCESS(amt_msat_ptr);
71009         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71010         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71011         LDKSha256 description_hash_conv;
71012         description_hash_conv.inner = untag_ptr(description_hash);
71013         description_hash_conv.is_owned = ptr_is_owned(description_hash);
71014         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
71015         description_hash_conv = Sha256_clone(&description_hash_conv);
71016         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71017         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71018         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71019         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71020         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71021         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
71022         return tag_ptr(ret_conv, true);
71023 }
71024
71025 int64_t  CS_LDK_create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(int64_t channelmanager, int64_t node_signer, int64_t logger, int32_t network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
71026         LDKChannelManager channelmanager_conv;
71027         channelmanager_conv.inner = untag_ptr(channelmanager);
71028         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
71029         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
71030         channelmanager_conv.is_owned = false;
71031         void* node_signer_ptr = untag_ptr(node_signer);
71032         CHECK_ACCESS(node_signer_ptr);
71033         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
71034         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
71035                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71036                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
71037         }
71038         void* logger_ptr = untag_ptr(logger);
71039         CHECK_ACCESS(logger_ptr);
71040         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71041         if (logger_conv.free == LDKLogger_JCalls_free) {
71042                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71043                 LDKLogger_JCalls_cloned(&logger_conv);
71044         }
71045         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71046         void* amt_msat_ptr = untag_ptr(amt_msat);
71047         CHECK_ACCESS(amt_msat_ptr);
71048         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71049         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71050         LDKSha256 description_hash_conv;
71051         description_hash_conv.inner = untag_ptr(description_hash);
71052         description_hash_conv.is_owned = ptr_is_owned(description_hash);
71053         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
71054         description_hash_conv = Sha256_clone(&description_hash_conv);
71055         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71056         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71057         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71058         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71059         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71060         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
71061         return tag_ptr(ret_conv, true);
71062 }
71063
71064 int64_t  CS_LDK_create_invoice_from_channelmanager_and_duration_since_epoch(int64_t channelmanager, int64_t node_signer, int64_t logger, int32_t network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs, int64_t min_final_cltv_expiry_delta) {
71065         LDKChannelManager channelmanager_conv;
71066         channelmanager_conv.inner = untag_ptr(channelmanager);
71067         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
71068         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
71069         channelmanager_conv.is_owned = false;
71070         void* node_signer_ptr = untag_ptr(node_signer);
71071         CHECK_ACCESS(node_signer_ptr);
71072         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
71073         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
71074                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71075                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
71076         }
71077         void* logger_ptr = untag_ptr(logger);
71078         CHECK_ACCESS(logger_ptr);
71079         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71080         if (logger_conv.free == LDKLogger_JCalls_free) {
71081                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71082                 LDKLogger_JCalls_cloned(&logger_conv);
71083         }
71084         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71085         void* amt_msat_ptr = untag_ptr(amt_msat);
71086         CHECK_ACCESS(amt_msat_ptr);
71087         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71088         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71089         LDKStr description_conv = str_ref_to_owned_c(description);
71090         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71091         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71092         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71093         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71094         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71095         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs, min_final_cltv_expiry_delta_conv);
71096         return tag_ptr(ret_conv, true);
71097 }
71098
71099 int64_t  CS_LDK_create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(int64_t channelmanager, int64_t node_signer, int64_t logger, int32_t network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs, int8_tArray payment_hash, int64_t min_final_cltv_expiry_delta) {
71100         LDKChannelManager channelmanager_conv;
71101         channelmanager_conv.inner = untag_ptr(channelmanager);
71102         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
71103         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
71104         channelmanager_conv.is_owned = false;
71105         void* node_signer_ptr = untag_ptr(node_signer);
71106         CHECK_ACCESS(node_signer_ptr);
71107         LDKNodeSigner node_signer_conv = *(LDKNodeSigner*)(node_signer_ptr);
71108         if (node_signer_conv.free == LDKNodeSigner_JCalls_free) {
71109                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71110                 LDKNodeSigner_JCalls_cloned(&node_signer_conv);
71111         }
71112         void* logger_ptr = untag_ptr(logger);
71113         CHECK_ACCESS(logger_ptr);
71114         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71115         if (logger_conv.free == LDKLogger_JCalls_free) {
71116                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71117                 LDKLogger_JCalls_cloned(&logger_conv);
71118         }
71119         LDKCurrency network_conv = LDKCurrency_from_cs(network);
71120         void* amt_msat_ptr = untag_ptr(amt_msat);
71121         CHECK_ACCESS(amt_msat_ptr);
71122         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
71123         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
71124         LDKStr description_conv = str_ref_to_owned_c(description);
71125         LDKThirtyTwoBytes payment_hash_ref;
71126         CHECK(payment_hash->arr_len == 32);
71127         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
71128         void* min_final_cltv_expiry_delta_ptr = untag_ptr(min_final_cltv_expiry_delta);
71129         CHECK_ACCESS(min_final_cltv_expiry_delta_ptr);
71130         LDKCOption_u16Z min_final_cltv_expiry_delta_conv = *(LDKCOption_u16Z*)(min_final_cltv_expiry_delta_ptr);
71131         min_final_cltv_expiry_delta_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(min_final_cltv_expiry_delta));
71132         LDKCResult_Bolt11InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceSignOrCreationErrorZ), "LDKCResult_Bolt11InvoiceSignOrCreationErrorZ");
71133         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(&channelmanager_conv, node_signer_conv, logger_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs, payment_hash_ref, min_final_cltv_expiry_delta_conv);
71134         return tag_ptr(ret_conv, true);
71135 }
71136
71137 int64_t  CS_LDK_SiPrefix_from_str(jstring s) {
71138         LDKStr s_conv = str_ref_to_owned_c(s);
71139         LDKCResult_SiPrefixBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixBolt11ParseErrorZ), "LDKCResult_SiPrefixBolt11ParseErrorZ");
71140         *ret_conv = SiPrefix_from_str(s_conv);
71141         return tag_ptr(ret_conv, true);
71142 }
71143
71144 int64_t  CS_LDK_Bolt11Invoice_from_str(jstring s) {
71145         LDKStr s_conv = str_ref_to_owned_c(s);
71146         LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ), "LDKCResult_Bolt11InvoiceParseOrSemanticErrorZ");
71147         *ret_conv = Bolt11Invoice_from_str(s_conv);
71148         return tag_ptr(ret_conv, true);
71149 }
71150
71151 int64_t  CS_LDK_SignedRawBolt11Invoice_from_str(jstring s) {
71152         LDKStr s_conv = str_ref_to_owned_c(s);
71153         LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ), "LDKCResult_SignedRawBolt11InvoiceBolt11ParseErrorZ");
71154         *ret_conv = SignedRawBolt11Invoice_from_str(s_conv);
71155         return tag_ptr(ret_conv, true);
71156 }
71157
71158 jstring  CS_LDK_Bolt11ParseError_to_str(int64_t o) {
71159         LDKBolt11ParseError* o_conv = (LDKBolt11ParseError*)untag_ptr(o);
71160         LDKStr ret_str = Bolt11ParseError_to_str(o_conv);
71161         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71162         Str_free(ret_str);
71163         return ret_conv;
71164 }
71165
71166 jstring  CS_LDK_ParseOrSemanticError_to_str(int64_t o) {
71167         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
71168         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
71169         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71170         Str_free(ret_str);
71171         return ret_conv;
71172 }
71173
71174 jstring  CS_LDK_Bolt11Invoice_to_str(int64_t o) {
71175         LDKBolt11Invoice o_conv;
71176         o_conv.inner = untag_ptr(o);
71177         o_conv.is_owned = ptr_is_owned(o);
71178         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
71179         o_conv.is_owned = false;
71180         LDKStr ret_str = Bolt11Invoice_to_str(&o_conv);
71181         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71182         Str_free(ret_str);
71183         return ret_conv;
71184 }
71185
71186 jstring  CS_LDK_SignedRawBolt11Invoice_to_str(int64_t o) {
71187         LDKSignedRawBolt11Invoice o_conv;
71188         o_conv.inner = untag_ptr(o);
71189         o_conv.is_owned = ptr_is_owned(o);
71190         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
71191         o_conv.is_owned = false;
71192         LDKStr ret_str = SignedRawBolt11Invoice_to_str(&o_conv);
71193         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71194         Str_free(ret_str);
71195         return ret_conv;
71196 }
71197
71198 jstring  CS_LDK_Currency_to_str(int64_t o) {
71199         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
71200         LDKStr ret_str = Currency_to_str(o_conv);
71201         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71202         Str_free(ret_str);
71203         return ret_conv;
71204 }
71205
71206 jstring  CS_LDK_SiPrefix_to_str(int64_t o) {
71207         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
71208         LDKStr ret_str = SiPrefix_to_str(o_conv);
71209         jstring ret_conv = str_ref_to_cs(ret_str.chars, ret_str.len);
71210         Str_free(ret_str);
71211         return ret_conv;
71212 }
71213
71214 void  CS_LDK_RapidGossipSync_free(int64_t this_obj) {
71215         LDKRapidGossipSync this_obj_conv;
71216         this_obj_conv.inner = untag_ptr(this_obj);
71217         this_obj_conv.is_owned = ptr_is_owned(this_obj);
71218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
71219         RapidGossipSync_free(this_obj_conv);
71220 }
71221
71222 int64_t  CS_LDK_RapidGossipSync_new(int64_t network_graph, int64_t logger) {
71223         LDKNetworkGraph network_graph_conv;
71224         network_graph_conv.inner = untag_ptr(network_graph);
71225         network_graph_conv.is_owned = ptr_is_owned(network_graph);
71226         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
71227         network_graph_conv.is_owned = false;
71228         void* logger_ptr = untag_ptr(logger);
71229         CHECK_ACCESS(logger_ptr);
71230         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
71231         if (logger_conv.free == LDKLogger_JCalls_free) {
71232                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
71233                 LDKLogger_JCalls_cloned(&logger_conv);
71234         }
71235         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv, logger_conv);
71236         int64_t ret_ref = 0;
71237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
71238         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
71239         return ret_ref;
71240 }
71241
71242 int64_t  CS_LDK_RapidGossipSync_sync_network_graph_with_file_path(int64_t this_arg, jstring sync_path) {
71243         LDKRapidGossipSync this_arg_conv;
71244         this_arg_conv.inner = untag_ptr(this_arg);
71245         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71247         this_arg_conv.is_owned = false;
71248         LDKStr sync_path_conv = str_ref_to_owned_c(sync_path);
71249         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
71250         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
71251         return tag_ptr(ret_conv, true);
71252 }
71253
71254 int64_t  CS_LDK_RapidGossipSync_update_network_graph(int64_t this_arg, int8_tArray update_data) {
71255         LDKRapidGossipSync this_arg_conv;
71256         this_arg_conv.inner = untag_ptr(this_arg);
71257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71259         this_arg_conv.is_owned = false;
71260         LDKu8slice update_data_ref;
71261         update_data_ref.datalen = update_data->arr_len;
71262         update_data_ref.data = update_data->elems;
71263         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
71264         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
71265         FREE(update_data);
71266         return tag_ptr(ret_conv, true);
71267 }
71268
71269 int64_t  CS_LDK_RapidGossipSync_update_network_graph_no_std(int64_t this_arg, int8_tArray update_data, int64_t current_time_unix) {
71270         LDKRapidGossipSync this_arg_conv;
71271         this_arg_conv.inner = untag_ptr(this_arg);
71272         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71274         this_arg_conv.is_owned = false;
71275         LDKu8slice update_data_ref;
71276         update_data_ref.datalen = update_data->arr_len;
71277         update_data_ref.data = update_data->elems;
71278         void* current_time_unix_ptr = untag_ptr(current_time_unix);
71279         CHECK_ACCESS(current_time_unix_ptr);
71280         LDKCOption_u64Z current_time_unix_conv = *(LDKCOption_u64Z*)(current_time_unix_ptr);
71281         current_time_unix_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(current_time_unix));
71282         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
71283         *ret_conv = RapidGossipSync_update_network_graph_no_std(&this_arg_conv, update_data_ref, current_time_unix_conv);
71284         FREE(update_data);
71285         return tag_ptr(ret_conv, true);
71286 }
71287
71288 jboolean  CS_LDK_RapidGossipSync_is_initial_sync_complete(int64_t this_arg) {
71289         LDKRapidGossipSync this_arg_conv;
71290         this_arg_conv.inner = untag_ptr(this_arg);
71291         this_arg_conv.is_owned = ptr_is_owned(this_arg);
71292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
71293         this_arg_conv.is_owned = false;
71294         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
71295         return ret_conv;
71296 }
71297
71298 void  CS_LDK_GraphSyncError_free(int64_t this_ptr) {
71299         if (!ptr_is_owned(this_ptr)) return;
71300         void* this_ptr_ptr = untag_ptr(this_ptr);
71301         CHECK_ACCESS(this_ptr_ptr);
71302         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
71303         FREE(untag_ptr(this_ptr));
71304         GraphSyncError_free(this_ptr_conv);
71305 }
71306
71307 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
71308         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71309         *ret_copy = GraphSyncError_clone(arg);
71310         int64_t ret_ref = tag_ptr(ret_copy, true);
71311         return ret_ref;
71312 }
71313 int64_t  CS_LDK_GraphSyncError_clone_ptr(int64_t arg) {
71314         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
71315         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
71316         return ret_conv;
71317 }
71318
71319 int64_t  CS_LDK_GraphSyncError_clone(int64_t orig) {
71320         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
71321         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71322         *ret_copy = GraphSyncError_clone(orig_conv);
71323         int64_t ret_ref = tag_ptr(ret_copy, true);
71324         return ret_ref;
71325 }
71326
71327 int64_t  CS_LDK_GraphSyncError_decode_error(int64_t a) {
71328         void* a_ptr = untag_ptr(a);
71329         CHECK_ACCESS(a_ptr);
71330         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
71331         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
71332         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71333         *ret_copy = GraphSyncError_decode_error(a_conv);
71334         int64_t ret_ref = tag_ptr(ret_copy, true);
71335         return ret_ref;
71336 }
71337
71338 int64_t  CS_LDK_GraphSyncError_lightning_error(int64_t a) {
71339         LDKLightningError a_conv;
71340         a_conv.inner = untag_ptr(a);
71341         a_conv.is_owned = ptr_is_owned(a);
71342         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
71343         a_conv = LightningError_clone(&a_conv);
71344         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
71345         *ret_copy = GraphSyncError_lightning_error(a_conv);
71346         int64_t ret_ref = tag_ptr(ret_copy, true);
71347         return ret_ref;
71348 }
71349